test(spanner): add integration test for inline-begin error handling (step 3)#5322
Draft
olavloite wants to merge 7 commits intogoogleapis:mainfrom
Draft
test(spanner): add integration test for inline-begin error handling (step 3)#5322olavloite wants to merge 7 commits intogoogleapis:mainfrom
olavloite wants to merge 7 commits intogoogleapis:mainfrom
Conversation
Adds support for inlining the BeginTransaction with the first query in a read-only transaction. This saves one round-trip to Spanner for multi-use read-only transactions. This implementation is intentionally simple: 1. It does not support parallel queries at the start of the transaction. 2. It does not include error handling for the first query. 3. It only supports read-only transactions. This is step 1. Follow-up pull requests addresses the above points.
Adds error handling for inline-begin-transaction. If the first statement in a transaction fails, and that statement included a BeginTransaction option, then the transaction has not been started. In order to keep the semantics of the transaction consistent for an 'outside observer', we need to do the following: 1. Catch the error that was thrown by the initial statement. 2. Start the transaction using an explicit BeginTransaction RPC. 3. Retry the initial statement, but now using the transaction ID from step 2. 4. Return the error or result for the retried initial statement. The above makes sure that: 1. The transaction is actually started when the first statement is executed, also when the statement failed. 2. The statement becomes part of the transaction, and the result of the statement is consistent with the read-timestamp of the transaction. The second part is important in order to comply with Spanner's strong consistency guarantees; If for example a statement returns a 'Table not found' error, then that error is only valid for the read timestamp that was used for executing the statement. This is the reason that we retry the statement after the BeginTransaction RPC to be able to return a result that is guaranteed to be consistent with any other queries/reads that will be executed in the same transaction.
Adds error handling for inline-begin-transaction. If the first statement in a transaction fails, and that statement included a BeginTransaction option, then the transaction has not been started. In order to keep the semantics of the transaction consistent for an 'outside observer', we need to do the following: 1. Catch the error that was thrown by the initial statement. 2. Start the transaction using an explicit BeginTransaction RPC. 3. Retry the initial statement, but now using the transaction ID from step 2. 4. Return the error or result for the retried initial statement. The above makes sure that: 1. The transaction is actually started when the first statement is executed, also when the statement failed. 2. The statement becomes part of the transaction, and the result of the statement is consistent with the read-timestamp of the transaction. The second part is important in order to comply with Spanner's strong consistency guarantees; If for example a statement returns a 'Table not found' error, then that error is only valid for the read timestamp that was used for executing the statement. This is the reason that we retry the statement after the BeginTransaction RPC to be able to return a result that is guaranteed to be consistent with any other queries/reads that will be executed in the same transaction.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5322 +/- ##
==========================================
+ Coverage 97.79% 97.81% +0.02%
==========================================
Files 220 220
Lines 45845 46632 +787
==========================================
+ Hits 44832 45614 +782
- Misses 1013 1018 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6db264c to
3f52671
Compare
Adds an integration test for error handling for inline-begin-transaction. This test uses a gRPC proxy to intercept calls from the client to Spanner to be able to deterministically emulate specific concurrency issues. This test shows how a query that failed during the first attempt, and thereby also failed to start the transaction, could succeed during a retry after the transaction has been started with an explicit BeginTransaction RPC.
3f52671 to
0efcab8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not merge: Depends on #5321
Adds an integration test for error handling for inline-begin-transaction. This test uses
a gRPC proxy to intercept calls from the client to Spanner to be able to deterministically
emulate specific concurrency issues. This test shows how a query that failed during the
first attempt, and thereby also failed to start the transaction, could succeed during a
retry after the transaction has been started with an explicit BeginTransaction RPC.
This is step 3 of the implementation of inline-begin-transaction for Spanner. A preliminary view of the full implementation after all steps can be seen in #5307