pgxpool: fix data race on concurrent conn.Release#2564
Conversation
When the same Conn was released from two goroutines at once, both calls passed the guard, grabbed the same puddle resource, and released it twice. Fixes jackc#2260.
|
A pgxpool.Conn is not concurrency safe. Multiple goroutines releasing the same pgxpool.Conn is a bug in the caller. |
Agreed, but if we can make it no-op we can 'save' some situation with ~zero extra effort :) |
TBH, I think that is counter productive. I want to make application logic errors noisy, not silence them. It seems very unlikely that a pgxpool.Conn could somehow be released from two different goroutines without something very wrong in the calling application. |
When the same Conn was released from two goroutines at once, both
calls passed the guard, grabbed the same puddle resource, and released it
twice.
Fixes #2260.
I tested with a piece of code that reproduced the bug: