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

chore(spanner): fix mutation only case in rw mux with aborted error #3571

Merged
merged 9 commits into from
Jan 30, 2025

Conversation

harshachinta
Copy link
Contributor

@harshachinta harshachinta commented Dec 26, 2024

This PR fixes the following scenario.

In a mutation-only scenario for a read-write transaction using multiplexed sessions, an explicit BeginTransaction RPC is triggered after the user operation completes.

However, if an ABORT occurs during this BeginTransaction RPC (this can happen if backend is unable to refresh the schema when a mutation key is passed), the client retry mechanism performs an explicit BeginTransaction before the user operation begins. This behavior causes issues in multiplexed sessions because, in mutation-only cases, the BeginTransaction requires a mutation key to generate a precommit token. This precommit token is essential for committing the transaction.

Currently, since the BeginTransaction during a retry is executed before the user operation, no mutation key is available, and consequently, no precommit token is included in the transaction response. This leads to commit failures with an error as shown below

com.google.cloud.spanner.SpannerException: INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: A Commit request for a read-write transaction on a multiplexed session must specify a precommit token.

Fix: The fix involves retrying the BeginTransaction RPC for mutation-only cases with multiplexed sessions when it fails with ABORTED error.

@harshachinta harshachinta requested a review from a team as a code owner December 26, 2024 12:38
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. labels Dec 26, 2024
@harshachinta harshachinta changed the title chore(spanner): fix mutation only case ibn rw using mux with aborted … chore(spanner): fix mutation only case inn rw using mux with aborted … Dec 26, 2024
@harshachinta harshachinta changed the title chore(spanner): fix mutation only case inn rw using mux with aborted … chore(spanner): fix mutation only case in rw using mux with aborted … Dec 26, 2024
@harshachinta harshachinta changed the title chore(spanner): fix mutation only case in rw using mux with aborted … chore(spanner): fix mutation only case in rw mux with aborted error Dec 26, 2024
@olavloite
Copy link
Collaborator

However, if an ABORT occurs during this BeginTransaction RPC

Is this something that can actually happen?

@harshachinta
Copy link
Contributor Author

this can happen if backend is unable to refresh the schema when a mutation key is passed

Yes, this can happen if backend is unable to refresh the schema when a mutation key is passed with a BeginTransaction RPC.

@harshachinta harshachinta requested review from a team as code owners January 30, 2025 10:57
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Jan 30, 2025
@harshachinta
Copy link
Contributor Author

Thanks @olavloite. Updated the approach to solve this problem by following the commit
cafefb6

@harshachinta harshachinta merged commit f4560e5 into googleapis:main Jan 30, 2025
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants