jackc / jackc/pgx

Add a bug check for incorrect concurrently use

Open
#2,459 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

**Is your feature request related to a problem? Please describe.**
Of course, we shouldn't use a single session(aka. connection) in multi threads(goroutines) without lock.
But there's still a chance that someone might shoot themselves in the foot. In that cases, we might got a simple and unclear message: "bad connection". It's not good, right?

**Describe the solution you'd like**
Maybe we can add a bugcheck, if someone do the unclever things, let them know.

**Additional context**
The pesudo-code
```go
_:=conn.BeginTx() // begin a transaction
for i:=0;i <10; i++ {
go func(){
for {
conn.Query(...) // boom!
}
}()
}
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the Go connection entry points used by BeginTx and Query, then inspect how the existing "bad connection" message is produced. Define how concurrent use should be detected and reported, and verify the result against the goroutine example in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.