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
fix: kill connection on commit/rollback error #14535
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sdepold
reviewed
May 24, 2022
Regarding the test, I guess you could stub rollbackTransaction / commitTransaction during a test? |
Yes, I think that's how I'll do that :) |
sdepold
reviewed
May 25, 2022
sdepold
previously approved these changes
May 25, 2022
I approved it. Don't know how strong I feel about the .length change. You decide |
sdepold
approved these changes
May 27, 2022
🎉 This PR is included in version 6.20.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
yarn test
oryarn test-DIALECT
pass with this change (including linting)?Description Of Change
This is an attempt at fixing #10858. I don't know if it'll completely fix it, so in doubt I'm not closing that issue.
What was going on?
If an error occurred during a transaction commit or rollback (such as a network error), Sequelize would call
transaction.cleanup()
, which released the connection to the pool.The problem is that if an error occurred, we cannot guarantee that the transaction did actually commit or roll back. It may still be active. Releasing the connection to the pool does not kill the connection, and it will end up used by other queries - unknowingly running in another transaction.
The fix
This PR changes that by taking the drastic approach of killing the connection if an error occurred during
COMMIT TRANSACTION
orROLLBACK TRANSACTION
.