Skip to content

fix: prevent connection pollution on context cancel in BeginTx - #3

Open
jearthliu wants to merge 2 commits into
raimeecas:mainfrom
jearthliu:fix/connection-pollution-on-context-cancel
Open

fix: prevent connection pollution on context cancel in BeginTx#3
jearthliu wants to merge 2 commits into
raimeecas:mainfrom
jearthliu:fix/connection-pollution-on-context-cancel

Conversation

@jearthliu

Copy link
Copy Markdown

When context is canceled during BeginTx, the connection may already have an active transaction on the server. Returning only the context error lets database/sql reuse the dirty connection. This fix returns driver.ErrBadConn to signal the connection should be discarded. Closes #1.

Return driver.ErrBadConn when context is canceled so the
connection is discarded rather than returned to the pool.
Closes raimeecas#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎯 Prevent Connection Pollution by Closing/Resetting Connection on Context Cancellation During BeginTx

1 participant