Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spanner: return transaction outcome unknown
If a DEADLINE_EXCEEDED or CANCELED error occurs while a COMMIT request is in flight, the outcome of the transaction is unknown as the request might have been received and processed by the server. The client library now returns a Spanner error with a TransactionOutcomeUnknownError error wrapped when this happens. A user application can check specifically for this condition by checking for the presence of such an error in the error chain: _, err := client.ReadWriteTransaction(ctx, func(ctx context.Context, tx *ReadWriteTransaction) error { tx.BufferWrite([]*Mutation{ Insert("FOO", []string{"ID", "NAME"}, []interface{}{int64(1), "bar"}), }) return nil }) var outcomeUnknown *TransactionOutcomeUnknownError if errorAs(err, &outcomeUnknown) { // DEADLINE_EXCEEDED or CANCELED occurred during commit. // The outcome of the transaction cannot be guaranteed. // Do custom error handling for this specific case. } Fixes #1781. Change-Id: Iff5b2eb89b738d23c2a0fd1cc0418f38c736beb4 Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/52370 Reviewed-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Hengfeng Li <hengfeng@google.com>
- Loading branch information
Showing
6 changed files
with
117 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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