summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorChristopher Caplinger <christopher.caplinger@mongodb.com>2022-01-24 15:14:10 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-24 15:55:59 +0000
commita94feb562cd9ffb42c10770fbf5b5d489875cc2f (patch)
treedec7fff449e668e2cb7878a6dc148f8005bcc450 /src/mongo/db/repl
parent54a201dff75d61b875d840f1a480c9331f79a147 (diff)
downloadmongo-a94feb562cd9ffb42c10770fbf5b5d489875cc2f.tar.gz
SERVER-62882: Move Recipient Service opctx creation outside of lock
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
index 05ba299b0c0..a8ab0537cd1 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
@@ -994,6 +994,8 @@ ExecutorFuture<void> TenantMigrationRecipientService::Instance::_getDonorFilenam
return;
}
+ auto uniqueOpCtx = cc().makeOperationContext();
+ auto opCtx = uniqueOpCtx.get();
stdx::lock_guard lk(_mutex);
const auto& data = dataStatus.getValue();
@@ -1023,8 +1025,6 @@ ExecutorFuture<void> TenantMigrationRecipientService::Instance::_getDonorFilenam
"filename"_attr = doc["filename"].String(),
"backupCursorId"_attr = data.cursorId);
- auto uniqueOpCtx = cc().makeOperationContext();
- auto opCtx = uniqueOpCtx.get();
auto donatedFilesNs = getDonatedFilesNs(getMigrationUUID());
auto status = writeConflictRetry(
opCtx,
@@ -1847,14 +1847,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() >=
@@ -2387,6 +2386,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());
@@ -2411,7 +2412,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::
@@ -2439,7 +2439,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();