diff options
author | Christopher Caplinger <christopher.caplinger@mongodb.com> | 2022-01-24 15:14:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-08 17:29:51 +0000 |
commit | 346f9b67ee826fd655a56a5116f9c352f7a18397 (patch) | |
tree | 0387fed7eefc2365332b564500ba4480d46e1622 | |
parent | f7dfccadbb6f19018765b96ca746dcdeb74cf1ec (diff) | |
download | mongo-346f9b67ee826fd655a56a5116f9c352f7a18397.tar.gz |
SERVER-62882: Move Recipient Service opctx creation outside of lock
(cherry picked from commit a94feb562cd9ffb42c10770fbf5b5d489875cc2f)
-rw-r--r-- | src/mongo/db/repl/tenant_migration_recipient_service.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp index 24f5c1bda4d..b1c8e81b0d2 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp @@ -1644,14 +1644,13 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::_advanceStableTimestampToStartApplyingDonorOpTime() { Timestamp startApplyingDonorTimestamp; { + auto opCtx = cc().makeOperationContext(); stdx::lock_guard lk(_mutex); if (_stateDoc.getProtocol() != MigrationProtocolEnum::kShardMerge) { return SemiFuture<void>::makeReady(); } - auto opCtx = cc().makeOperationContext(); - invariant(_stateDoc.getStartApplyingDonorOpTime()); startApplyingDonorTimestamp = _stateDoc.getStartApplyingDonorOpTime()->getTimestamp(); if (opCtx->getServiceContext()->getStorageEngine()->getStableTimestamp() >= @@ -2173,6 +2172,8 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::run( return AsyncTry([this, self = shared_from_this(), executor, token, cancelWhenDurable] { return ExecutorFuture(**executor) .then([this, self = shared_from_this()] { + auto opCtx = cc().makeOperationContext(); + stdx::unique_lock lk(_mutex); // Instance task can be started only once for the current term on a primary. invariant(!_taskState.isDone()); @@ -2197,7 +2198,6 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::run( // retry and we can delete immediately to allow the migration to restart. // Otherwise, there is a real conflict so we should throw // ConflictingInProgress. - auto opCtx = cc().makeOperationContext(); lk.unlock(); auto deleted = uassertStatusOK(tenantMigrationRecipientEntryHelpers:: @@ -2225,7 +2225,6 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::run( lk.unlock(); // Update the state document outside the mutex to avoid a deadlock in the // case of a concurrent stepdown. - auto opCtx = cc().makeOperationContext(); uassertStatusOK(tenantMigrationRecipientEntryHelpers::updateStateDoc( opCtx.get(), stateDoc)); return SemiFuture<void>::makeReady(); |