summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp5
1 files changed, 5 insertions, 0 deletions
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);