Skip to content
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

Discard connection in ensure, not rescue #48740

Merged
merged 1 commit into from Aug 1, 2023

Conversation

nicholasdower
Copy link
Contributor

Motivation / Background

Partially Fixes #48164. Followup to #48200.

Detail

within_new_transaction currently discards connections if an error is raised which may have left the connection in a transaction. This change updates that logic to discard connections in an ensure block to handle cases where an error is not raised, for instance if the thread is killed.

Additional information

Replaces #48224.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Partially Fixes rails#48164. Followup to rails#48200.

`within_new_transaction` currently discards connections if an error
is raised which may have left the connection in a transaction. This change
updates that logic to discard connections in an `ensure` block to handle
cases where an error is not raised, for instance if the thread is killed.

Connections are now discarded in this case.

*Nick Dower*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is already a changelog entry on line 216 for the previous change. I wasn't sure whether it was ok to simply update that entry. I'm also not sure this fix warrants a changelog entry.

@rafaelfranca rafaelfranca merged commit 834aa41 into rails:main Aug 1, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ActiveRecord Transaction Unexpectedly Left Open
2 participants