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

Skip closing cursor if connection held is no longer active #58

Merged
merged 1 commit into from
Oct 29, 2022

Conversation

pedrofcuba
Copy link
Contributor

It avoids issues when a transaction fails, thus the statement to close the cursor will fail.
In addition this obscures the underlying error in the user code due to raising when closing the cursor.

The tests show a toy case of when/how this can occur, however I've ran into similar issues where I wasn't able to figure out the error from application logs since the error I would get would be the one raised from the ensure block.

An alternative approach would be to actually nest a begin/rescue in the ensure block and rescue error to avoid obscuring the underlying error, or be more precise and rescue only ActiveRecord::StatementInvalid. If that is preferred, I could change this PR.

It avoids issues when a transaction fails, thus the statement to close the cursor will fail.
In addition this obscures the underlying error in the user code due to raising when closing the cursor.
@hlascelles
Copy link

@afair Would you consider a release for this please?

@afair afair merged commit e835ed6 into afair:master Oct 29, 2022
@hlascelles
Copy link

Thank you! 🙇

@pedrofcuba pedrofcuba deleted the exception-in-failed-txn branch February 12, 2024 17:26
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.

None yet

3 participants