From f9dcaa70c247f0e7e147291294af113de7e8eee5 Mon Sep 17 00:00:00 2001 From: Jordi Serra Torrens Date: Mon, 16 May 2022 13:49:54 +0000 Subject: [PATCH] BF-25230 fix --- .../db/s/migration_destination_manager.cpp | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index f8063e03ddc..05e71fe0467 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -501,16 +501,6 @@ Status MigrationDestinationManager::restoreRecoveredMigrationState( LOGV2(6064500, "Recovering migration recipient", "sessionId"_attr = *_sessionId); - RecoverableCriticalSectionService::get(opCtx)->acquireRecoverableCriticalSectionBlockWrites( - opCtx, _nss, criticalSectionReason(*_sessionId), ShardingCatalogClient::kLocalWriteConcern); - - LOGV2_DEBUG(6064501, - 2, - "Reacquired migration recipient critical section", - "sessionId"_attr = *_sessionId); - - _state = kEnteredCritSec; - if (_migrateThreadHandle.joinable()) { _migrateThreadHandle.join(); } @@ -1598,7 +1588,7 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx, // Enter critical section RecoverableCriticalSectionService::get(opCtx) ->acquireRecoverableCriticalSectionBlockWrites( - opCtx, _nss, critSecReason, ShardingCatalogClient::kLocalWriteConcern); + opCtx, _nss, critSecReason, ShardingCatalogClient::kMajorityWriteConcern); LOGV2(5899114, "Entered migration recipient critical section", logAttrs(_nss)); timeInCriticalSection.emplace(); @@ -1634,6 +1624,20 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx, auto opCtx = newOpCtxPtr.get(); if (skipToCritSecTaken) { + RecoverableCriticalSectionService::get(opCtx) + ->acquireRecoverableCriticalSectionBlockWrites( + opCtx, + _nss, + criticalSectionReason(*_sessionId), + ShardingCatalogClient::kMajorityWriteConcern); + + LOGV2_DEBUG(6064501, + 2, + "Reacquired migration recipient critical section", + "sessionId"_attr = *_sessionId); + + _state = kEnteredCritSec; + timeInCriticalSection.emplace(); } invariant(timeInCriticalSection); -- 2.17.1