summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp')
-rw-r--r--src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp19
1 files changed, 10 insertions, 9 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 cecca24da1b..e56347589a2 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
@@ -70,15 +70,16 @@ public:
str::stream() << "Collection " << nss->ns() << " does not exist",
_autoColl->getCollection());
- auto css = CollectionShardingState::get(opCtx, *nss);
- uassert(ErrorCodes::IllegalOperation,
- str::stream() << "No active migrations were found for collection " << nss->ns(),
- css->getMigrationSourceManager());
-
- // It is now safe to access the cloner
- _chunkCloner = dynamic_cast<MigrationChunkClonerSourceLegacy*>(
- css->getMigrationSourceManager()->getCloner());
- invariant(_chunkCloner);
+ if (auto msm = MigrationSourceManager::get(CollectionShardingState::get(opCtx, *nss))) {
+ // It is now safe to access the cloner
+ _chunkCloner = dynamic_cast<MigrationChunkClonerSourceLegacy*>(msm->getCloner());
+ invariant(_chunkCloner);
+
+ } else {
+ uasserted(ErrorCodes::IllegalOperation,
+ str::stream() << "No active migrations were found for collection "
+ << nss->ns());
+ }
// Ensure the session ids are correct
uassert(ErrorCodes::IllegalOperation,