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

fix(spanner): release resources in TransactionManager #3638

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 a
// terminal state.
Copy link
Collaborator

Choose a reason for hiding this comment

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

super-nit: I would recommend using end state instead of terminal state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I have used this term from existing code. But end state is more clear in terms of readability.

// 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 a terminal state.
// We can safely call close() to release resources.
close();
}
}

Expand Down
Loading