diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2017-02-24 12:42:37 -0500 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2018-04-13 16:52:27 -0400 |
commit | f0299d35a0e91246fa95005c78319bcabd43494d (patch) | |
tree | 1836ce6fc6a5c543f8d2412dfe77b1edafffa2aa | |
parent | 0509284a4fedf0943c724108099f7ea94e88bf27 (diff) | |
download | mongo-f0299d35a0e91246fa95005c78319bcabd43494d.tar.gz |
SERVER-27941 change the shardVersion check to an epoch check when entering the critical section.
(cherry picked from commit ce23378926659bc50604032782485c2f962c37ac)
-rw-r--r-- | src/mongo/db/s/migration_source_manager.cpp | 10 |
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.")}; } |