summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/transaction_coordinator_service.cpp
diff options
context:
space:
mode:
authorMatthew Saltz <matthew.saltz@mongodb.com>2020-11-30 22:12:12 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-22 21:04:56 +0000
commit251feeb575e30136547175a8d3eed20e023ea39b (patch)
tree921856bf32753c6f0772fce14c7e2efad7d02483 /src/mongo/db/s/transaction_coordinator_service.cpp
parent351ba424951718aeeab0588e7123b80df6f32cd3 (diff)
downloadmongo-251feeb575e30136547175a8d3eed20e023ea39b.tar.gz
SERVER-50660 Integrate CancelationTokens with OperationContext
Diffstat (limited to 'src/mongo/db/s/transaction_coordinator_service.cpp')
-rw-r--r--src/mongo/db/s/transaction_coordinator_service.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/s/transaction_coordinator_service.cpp b/src/mongo/db/s/transaction_coordinator_service.cpp
index 98f0944d510..d75fc8b3a39 100644
--- a/src/mongo/db/s/transaction_coordinator_service.cpp
+++ b/src/mongo/db/s/transaction_coordinator_service.cpp
@@ -83,7 +83,18 @@ void TransactionCoordinatorService::createCoordinator(OperationContext* opCtx,
auto coordinator = std::make_shared<TransactionCoordinator>(
opCtx, lsid, txnNumber, scheduler.makeChildScheduler(), commitDeadline);
- catalog.insert(opCtx, lsid, txnNumber, coordinator);
+ try {
+ catalog.insert(opCtx, lsid, txnNumber, coordinator);
+ } catch (const DBException&) {
+ // Handle the case where the opCtx has been interrupted and we do not successfully insert
+ // the coordinator into the catalog.
+ coordinator->cancelIfCommitNotYetStarted();
+ // Wait for it to finish processing the error before throwing, since leaving this scope will
+ // cause the newly created coordinator to be destroyed. We ignore the return Status since we
+ // want to just rethrow whatever exception was thrown when inserting into the catalog.
+ [[maybe_unused]] auto status = coordinator->onCompletion().waitNoThrow();
+ throw;
+ }
}