-
Notifications
You must be signed in to change notification settings - Fork 22.2k
ConncectionPool: Prevent reuse of a connection with open transactions #24493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -507,6 +507,7 @@ def checkout(checkout_timeout = @checkout_timeout) | |
| # +conn+: an AbstractAdapter object, which was obtained by earlier by | ||
| # calling #checkout on this pool. | ||
| def checkin(conn) | ||
| conn.assert_connection_reuseable | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Connections may be checked in (closed) in a dirty state. We should rollback on checkin to close dangling open transactions.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we are resetting connections, but only when they're reaped from the pool. The pg adapter properly resets the conn in-place (cc0d54b) but mysql2 adapter aliases it to a reconnect.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed this only happens in case of progammer error and the earlier we blow up the better. I can think of 2 cases this can happen:
If we roll back on case 1 it'll blow up when the transaction block original tries to release the transaction at [*], as it's already released. That should do as well, but will be a bit harder to see that where the error is coming from. In both case i think the last thing we want is the current behaviour of happily allowing reusing the connection with an opened transaction. I guess mysql close and reconnect should be fine as we'd be calling reset! only if we have open transactions. |
||
| synchronize do | ||
| remove_connection_from_thread_cache conn | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this hack is to be replaced with #24608 or similiar