diff options
author | Cheahuychou Mao <mao.cheahuychou@gmail.com> | 2021-01-22 19:54:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-25 16:32:51 +0000 |
commit | ca9f854ac4b7f9197a0574f72e450a8317696286 (patch) | |
tree | b97609abe60d7ccba576b6e05dd2bc4af1844adc | |
parent | 2497bf18a4f2959501582f4084ad27212698b574 (diff) | |
download | mongo-ca9f854ac4b7f9197a0574f72e450a8317696286.tar.gz |
SERVER-53981 Make TenantMigrationAccessBlocker::setCommitOpTime and setAbortOpTime not try to set completion promise if it is already set
-rw-r--r-- | src/mongo/db/repl/tenant_migration_access_blocker.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/repl/tenant_migration_access_blocker.cpp b/src/mongo/db/repl/tenant_migration_access_blocker.cpp index a601ddd6d8f..a145c40cbad 100644 --- a/src/mongo/db/repl/tenant_migration_access_blocker.cpp +++ b/src/mongo/db/repl/tenant_migration_access_blocker.cpp @@ -243,6 +243,11 @@ void TenantMigrationAccessBlocker::setCommitOpTime(OperationContext* opCtx, repl } stdx::unique_lock<Latch> lk(_mutex); + if (_completionPromise.getFuture().isReady()) { + // onMajorityCommitPointUpdate() was called during the time that this thread is not holding + // the lock. + return; + } _onMajorityCommitCommitOpTime(lk); } @@ -266,6 +271,11 @@ void TenantMigrationAccessBlocker::setAbortOpTime(OperationContext* opCtx, repl: } stdx::unique_lock<Latch> lk(_mutex); + if (_completionPromise.getFuture().isReady()) { + // onMajorityCommitPointUpdate() was called during the time that this thread is not holding + // the lock. + return; + } _onMajorityCommitAbortOpTime(lk); } @@ -305,7 +315,9 @@ void TenantMigrationAccessBlocker::_onMajorityCommitCommitOpTime(stdx::unique_lo } void TenantMigrationAccessBlocker::_onMajorityCommitAbortOpTime(stdx::unique_lock<Latch>& lk) { + invariant(_state != State::kReject); invariant(!_commitOpTime); + invariant(_state != State::kAborted); invariant(_abortOpTime); _state = State::kAborted; |