-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
102098: kv: support Rollback in Txn closure r=arulajmani a=nvanbenschoten This commit adds support for the following pattern in a transaction closure: ```go db.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error { return txn.Rollback(ctx) }) ``` Surprisingly, this would previously return an error: ``` TransactionStatusError: client already committed or rolled back the transaction. Trying to execute: 1 EndTxn (REASON_UNKNOWN) ``` This was because the txn retry loop in `txn.exec` would attempt to commit the rolled back transaction and encounter the `TransactionStatusError`. The loop is now made aware of the client finalization state, and uses this to decide whether to auto-commit. Epic: None Release note: None Co-authored-by: Nathan VanBenschoten <[email protected]>
- Loading branch information
Showing
6 changed files
with
70 additions
and
20 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