From e90dcb18de438b6b6ab02b2c921463fd35b866cb Mon Sep 17 00:00:00 2001 From: Randolph Tan Date: Wed, 17 May 2023 17:36:16 +0000 Subject: SERVER-76546 _migrateClone can deadlock with prepared transactions on secondaries --- src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/mongo/db') diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp index b623db6b16d..8bf95705b43 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp @@ -76,6 +76,11 @@ public: str::stream() << "Collection " << nss->toStringForErrorMsg() << " does not exist", _autoColl->getCollection()); + uassert(ErrorCodes::NotWritablePrimary, + "No longer primary when trying to acquire active migrate cloner", + opCtx->writesAreReplicated() && + repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, *nss)); + { const auto scopedCsr = CollectionShardingRuntime::assertCollectionLockedAndAcquireShared(opCtx, *nss); -- cgit v1.2.1