summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2021-03-08 21:38:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-08 23:01:08 +0000
commitd729c92c37bb1679f03fab1547f6e5b102b8594c (patch)
tree194ab37bc2015a0e4b5278dade675aab9e409716
parenteac3f95269c6da5723abdf5f7d5c614e14b917ca (diff)
downloadmongo-d729c92c37bb1679f03fab1547f6e5b102b8594c.tar.gz
SERVER-54919: TenantMigrationRecipientService should not create an OperationContext while holding the instance mutex
-rw-r--r--src/mongo/db/repl/tenant_migration_recipient_service.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
index 10a1dd880b2..8f77823007e 100644
--- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp
+++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp
@@ -1272,14 +1272,13 @@ Future<void> TenantMigrationRecipientService::Instance::_startTenantAllDatabaseC
return {Future<void>::makeReady()};
}
- auto opCtx = cc().makeOperationContext();
- _tenantAllDatabaseCloner =
- std::make_unique<TenantAllDatabaseCloner>(_sharedData.get(),
- _client->getServerHostAndPort(),
- _client.get(),
- repl::StorageInterface::get(opCtx.get()),
- _writerPool.get(),
- _tenantId);
+ _tenantAllDatabaseCloner = std::make_unique<TenantAllDatabaseCloner>(
+ _sharedData.get(),
+ _client->getServerHostAndPort(),
+ _client.get(),
+ repl::StorageInterface::get(cc().getServiceContext()),
+ _writerPool.get(),
+ _tenantId);
LOGV2_DEBUG(4881100,
1,
"Starting TenantAllDatabaseCloner",
@@ -1309,7 +1308,6 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::_onCloneSuccess() {
return SemiFuture<void>::makeReady();
}
- auto opCtx = cc().makeOperationContext();
{
stdx::lock_guard<TenantMigrationSharedData> sharedDatalk(*_sharedData);
auto lastVisibleMajorityCommittedDonorOpTime =
@@ -1318,7 +1316,7 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::_onCloneSuccess() {
_stateDoc.setDataConsistentStopDonorOpTime(lastVisibleMajorityCommittedDonorOpTime);
}
_stateDoc.setCloneFinishedRecipientOpTime(
- repl::ReplicationCoordinator::get(opCtx.get())->getMyLastAppliedOpTime());
+ repl::ReplicationCoordinator::get(cc().getServiceContext())->getMyLastAppliedOpTime());
return ExecutorFuture(**_scopedExecutor)
.then([this, self = shared_from_this(), stateDoc = _stateDoc] {
@@ -1727,13 +1725,13 @@ SemiFuture<void> TenantMigrationRecipientService::Instance::run(
// If our state is initialized and we haven't fulfilled the
// '_stateDocPersistedPromise' yet, it means we are restarting the future
// chain due to recipient failover.
- auto opCtx = cc().makeOperationContext();
_stateDoc.setNumRestartsDueToRecipientFailure(
_stateDoc.getNumRestartsDueToRecipientFailure() + 1);
const auto stateDoc = _stateDoc;
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();