Odd Conn busy error with Pool.Acquire and Begin
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 14.3k
- Forks
- 1.1k
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 11
Description
I have found a workaround to my problem but I think this may point to a deeper bug. The code below works most of the time, but under odd conditions that I noticed "Conn closed" errors. The second code block, while functionally identical for my purposes has not yet manifested the "Conn closed" error.
...
var pool *pgxpool.Pool
...
conn, err := pool.Acquire(ctx)
// error returns oddly here
if err != nil {
return err
}
//code never reaches here on error
defer conn.Release()
tx, err = conn.Begin(ctx)
Second code block:
...
var pool *pgxpool.Pool
...
tx, err = pool.Begin(ctx)
// pool.Begin successfully establishes a connection and initializes a transaction.
// No "Conn closed" error observed as of yet.
Apparently, starting the transaction directly from the pool avoids this issue. Is there any insight as to why this might be the case?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Acquire-then-Begin and pool.Begin call sequences shown in the issue, and compare how each handles the connection. Reproduce the intermittent "Conn closed" error under the reported odd conditions; done means identifying the cause and determining the appropriate behavior or fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100