You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix checking cancelled connections back into the connection pool (go-sql-driver#1095)
If
* BeginTx is called with a non-default isolation level,
* The context is canceled before SET TRANSACTION ISOLATION LEVEL
completes,
then the connection:
* has the cancelled property set to "context cancelled",
* has the closed property set to true,
and,
* BeginTx returns "context canceled"
Because of this, the connection gets put back into the connection pool.
When it is checked out again, if BeginTx is called on it again _without_
an isolation level,
* then we fall into the mc.closed.IsSet() check in begin(),
* so we return ErrBadConn,
* so the driver kicks the broken connection out of the pool
* (and transparently retries to get a new connection that isn't
broken too).
However, if BeginTx is called on the connection _with_ an isolation
level, then we return a context canceled error from the SET TRANSACTION
ISOLATION LEVEL call.
That means the broken connection will stick around in the pool forever
(or until it's checked out for some other operation that correctly
returns ErrBadConn).
The fix is to check for the connection being closed before executing SET
TRANSACTION ISOLATION LEVEL.
0 commit comments