diff options
author | Jason Chan <jason.chan@mongodb.com> | 2021-02-19 18:06:06 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-22 22:41:15 +0000 |
commit | 88edee72db9a36bb362acd46c1c61bccb2f26526 (patch) | |
tree | 01cf62514a9a5aa1405b5381a44f02e2f6dbb003 | |
parent | 4b48c797df7dc9871c16aa2347b8af55da455639 (diff) | |
download | mongo-88edee72db9a36bb362acd46c1c61bccb2f26526.tar.gz |
SERVER-54652 Create oplog buffer outside of TenantMigrationRecipientService mutex
-rw-r--r-- | src/mongo/db/repl/tenant_migration_recipient_service.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp index e251adc76c8..297ee928c6f 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp @@ -784,11 +784,13 @@ void TenantMigrationRecipientService::Instance::_startOplogFetcher() { options.dropCollectionAtStartup = false; options.dropCollectionAtShutdown = false; options.useTemporaryCollection = false; - stdx::unique_lock lk(_mutex); - invariant(_stateDoc.getStartFetchingDonorOpTime()); + // Create the oplog buffer outside the mutex to avoid deadlock on a concurrent stepdown. auto oplogBufferNS = getOplogBufferNs(getMigrationUUID()); - _donorOplogBuffer = std::make_unique<OplogBufferCollection>( + auto bufferCollection = std::make_unique<OplogBufferCollection>( StorageInterface::get(opCtx.get()), oplogBufferNS, options); + stdx::unique_lock lk(_mutex); + invariant(_stateDoc.getStartFetchingDonorOpTime()); + _donorOplogBuffer = std::move(bufferCollection); { // Ensure we are primary when trying to startup and create the oplog buffer collection. |