-
Notifications
You must be signed in to change notification settings - Fork 370
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
Rollback is not called if there is a panic #637
Comments
This is also the case for |
I do not think perfect (catching all possible ways code can exist) should be the enemy of good: catching a standard way for Go code to throw an exception when there is a bug in the code it is calling into, and cleaning up. In fact, Go gives you a nice way to cleanup. I would even say that it would simplify existing code. See here. There is so many I can try to do a MR if it would be an acceptable change. |
Fixes #637 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com>
Preflight checklist
Describe the bug
Current use of
BeginTx
,CommitTx
andRollbackTx
in Fosite is problematic because it does not callRollbackTx
when panic happens. We could assume that Fosite itself does not panic, but that is not necessary true for code it calls into. For example, I had a bug inside my storage implementation which triggered panic. As the panic propagated and was handled higher up in my request handler and logged, transaction itself was not rolled back, leaving the connection over it in an inconsistent state. With connection pooling that brought some stability issues.Reproducing the bug
Sadly I do not have a simple reproduction here. One which I was able to do is with Sqlite and setting
SetMaxOpenConns
to 1. Then if a transaction is not rolled back, no other operation can be done on the database and my code hangs. This is how I am now testing that all transactions are properly rolled back.Relevant log output
No response
Relevant configuration
No response
Version
observed on current master branch
On which operating system are you observing this issue?
No response
In which environment are you deploying?
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: