googleapis / java-spanner Public
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: AsyncTransactionManager should rollback on close #505
Conversation
AsyncTransctionManager should rollback the transaction if close is called while the transaction is still in state STARTED. Failing to do so, will keep the transaction open on the backend for longer than necessary, holding on to locks until it is garbage collected after 10 seconds. Fixes #504
Codecov Report
@@ Coverage Diff @@
## master #505 +/- ##
============================================
- Coverage 84.03% 84.00% -0.03%
+ Complexity 2539 2538 -1
============================================
Files 140 140
Lines 13871 13889 +18
Branches 1328 1329 +1
============================================
+ Hits 11656 11668 +12
- Misses 1672 1679 +7
+ Partials 543 542 -1
Continue to review full report at Codecov.
|
@@ -54,6 +54,9 @@ public void setSpan(Span span) { | |||
|
|||
@Override | |||
public void close() { | |||
if (txnState == TransactionState.STARTED) { | |||
rollbackAsync(); |
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.
Can there be a version of close()
that propagates the ApiFutrue
from rollbackAsync()
back to the caller? Otherwise the application could shut down (or, in my case, the test terminate) before the rollback happens.
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.
I've added a closeAsync()
method to the AsyncTransactionManager
interface that returns an ApiFuture
that is done when everything has been rolled back and released. PTAL.
AsyncTransctionManager should rollback the transaction if close is called while the transaction is still in state STARTED. Failing to do so, will keep the transaction open on the backend for longer than necessary, holding on to locks until it is garbage collected after 10 seconds.
Fixes #504