diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-03-21 13:14:40 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-03-21 21:36:47 -0400 |
commit | be36aeb7166b2e06dd47dd0769ea28cbb7250041 (patch) | |
tree | d95db70de0f2ac6cf1d6bc62ef85c657c6cff2f5 /src/mongo/db/s/transaction_coordinator.cpp | |
parent | 78eaa3cf538764d5aa5a09c5997532a4c3b2bca8 (diff) | |
download | mongo-be36aeb7166b2e06dd47dd0769ea28cbb7250041.tar.gz |
SERVER-40223 Use the AsyncWorkScheduler to run local command when recovering a coordinator decision
Diffstat (limited to 'src/mongo/db/s/transaction_coordinator.cpp')
-rw-r--r-- | src/mongo/db/s/transaction_coordinator.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mongo/db/s/transaction_coordinator.cpp b/src/mongo/db/s/transaction_coordinator.cpp index 6e7d4d377ed..5ba843566a6 100644 --- a/src/mongo/db/s/transaction_coordinator.cpp +++ b/src/mongo/db/s/transaction_coordinator.cpp @@ -79,7 +79,7 @@ TransactionCoordinator::TransactionCoordinator(ServiceContext* serviceContext, _lsid(lsid), _txnNumber(txnNumber), _scheduler(std::move(scheduler)), - _driver(serviceContext, _scheduler->makeChildScheduler()) { + _driver(serviceContext, *_scheduler) { if (coordinateCommitDeadline) { _deadlineScheduler = _scheduler->makeChildScheduler(); _deadlineScheduler @@ -93,10 +93,11 @@ TransactionCoordinator::TransactionCoordinator(ServiceContext* serviceContext, } TransactionCoordinator::~TransactionCoordinator() { - _cancelTimeoutWaitForCommitTask(); + cancelIfCommitNotYetStarted(); + // Wait for all scheduled asynchronous activity to complete if (_deadlineScheduler) - _deadlineScheduler.reset(); + _deadlineScheduler->join(); stdx::lock_guard<stdx::mutex> lk(_mutex); invariant(_state == TransactionCoordinator::CoordinatorState::kDone); @@ -231,13 +232,11 @@ Future<void> TransactionCoordinator::_sendDecisionToParticipants( invariant(_state == CoordinatorState::kPreparing); _decisionPromise.emplaceValue(decision.decision); - // Send the decision to all participants. switch (decision.decision) { case txn::CommitDecision::kCommit: _state = CoordinatorState::kCommitting; - invariant(decision.commitTimestamp); return _driver.sendCommit( - participantShards, _lsid, _txnNumber, decision.commitTimestamp.get()); + participantShards, _lsid, _txnNumber, *decision.commitTimestamp); case txn::CommitDecision::kAbort: _state = CoordinatorState::kAborting; return _driver.sendAbort(participantShards, _lsid, _txnNumber); |