summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/s/migration_source_manager.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp
index 149a7b12397..035d21cbb82 100644
--- a/src/mongo/db/s/migration_source_manager.cpp
+++ b/src/mongo/db/s/migration_source_manager.cpp
@@ -249,16 +249,18 @@ Status MigrationSourceManager::enterCriticalSection(OperationContext* txn) {
ScopedTransaction scopedXact(txn, MODE_IX);
AutoGetCollection autoColl(txn, getNss(), MODE_IX, MODE_X);
+ // Check that the collection has not been dropped or recreated since the migration began.
auto css = CollectionShardingState::get(txn, getNss().ns());
auto metadata = css->getMetadata();
if (!metadata ||
- !metadata->getCollVersion().equals(_collectionMetadata->getCollVersion())) {
+ (metadata->getCollVersion().epoch() != _collectionMetadata->getCollVersion().epoch())) {
return {ErrorCodes::IncompatibleShardingMetadata,
str::stream()
- << "Sharding metadata changed while holding distributed lock. Expected: "
- << _collectionMetadata->getCollVersion().toString()
+ << "The collection was dropped or recreated since the migration began. "
+ << "Expected collection epoch: "
+ << _collectionMetadata->getCollVersion().epoch().toString()
<< ", but found: "
- << (metadata ? metadata->getCollVersion().toString()
+ << (metadata ? metadata->getCollVersion().epoch().toString()
: "unsharded collection.")};
}