Skip to content

fix: prevent connection leak on context cancellation in BeginTx - #4

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

fix: prevent connection leak on context cancellation in BeginTx#4
jearthliu wants to merge 2 commits into
raimeecas:mainfrom
jearthliu:fix/connection-leak-on-context-cancellation

Conversation

@jearthliu

Copy link
Copy Markdown

When context is canceled during BeginTx, the connection may have an active transaction on the server. This fix attempts a ROLLBACK first, and if that fails (context expired), returns driver.ErrBadConn so database/sql discards the connection instead of recycling it. Closes #2.

Attempt ROLLBACK when context is canceled. If ROLLBACK fails,
return driver.ErrBadConn to discard the connection.
Closes raimeecas#2
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 Leak to Pool on Context Cancellation during BeginTx()

1 participant