Skip to content

Commit

Permalink
fix(spanner): release resources in TransactionManager (#3638)
Browse files Browse the repository at this point in the history
* fix(spanner): release resources in TransactionManager

* fix(spanner): lint fix

* chore(spanner): fix comment
  • Loading branch information
harshachinta authored Feb 13, 2025
1 parent b2ba1f3 commit e0a3e5b
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public void commit() {
} catch (SpannerException e2) {
txnState = TransactionState.COMMIT_FAILED;
throw e2;
} finally {
// At this point, if the TransactionState is not ABORTED, then the transaction has reached an
// end state.
// We can safely call close() to release resources.
if (getState() != TransactionState.ABORTED) {
close();
}
}
}

Expand All @@ -92,6 +99,9 @@ public void rollback() {
txn.rollback();
} finally {
txnState = TransactionState.ROLLED_BACK;
// At this point, the TransactionState is ROLLED_BACK which is an end state.
// We can safely call close() to release resources.
close();
}
}

Expand Down

0 comments on commit e0a3e5b

Please sign in to comment.