diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-11-11 16:32:18 -0500 |
---|---|---|
committer | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-11-14 10:31:42 -0500 |
commit | 508aae2223da2390b7b22c9d04d7707af7e131a8 (patch) | |
tree | 7a478411dd83f9e5612316c4f5268de6bfcdea4d /src/mongo/db/s/migration_destination_manager_legacy_commands.cpp | |
parent | 493b1f4bb89d721e630bcd99b1aac2808c8a5161 (diff) | |
download | mongo-508aae2223da2390b7b22c9d04d7707af7e131a8.tar.gz |
SERVER-27004 move check for pending RangeDeleter deletes to after registering the receive chunk
Diffstat (limited to 'src/mongo/db/s/migration_destination_manager_legacy_commands.cpp')
-rw-r--r-- | src/mongo/db/s/migration_destination_manager_legacy_commands.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp index 781029b7405..a20db670259 100644 --- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp +++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp @@ -93,19 +93,6 @@ public: BSONObjBuilder& result) { ShardingState* const shardingState = ShardingState::get(txn); - // Pending deletes (for migrations) are serialized by the distributed collection lock, - // we are sure we registered a delete for a range *before* we can migrate-in a - // subrange. - const size_t numDeletes = getDeleter()->getTotalDeletes(); - if (numDeletes > 0) { - errmsg = str::stream() << "can't accept new chunks because " - << " there are still " << numDeletes - << " deletes from previous migration"; - - warning() << errmsg; - return false; - } - const ShardId toShard(cmdObj["toShardName"].String()); const ShardId fromShard(cmdObj["fromShardName"].String()); @@ -163,9 +150,23 @@ public: const MigrationSessionId migrationSessionId( uassertStatusOK(MigrationSessionId::extractFromBSON(cmdObj))); + // Ensure this shard is not currently receiving or donating any chunks. auto scopedRegisterReceiveChunk( uassertStatusOK(shardingState->registerReceiveChunk(nss, chunkRange, fromShard))); + // Even if this shard is not currently donating any chunks, it may still have pending + // deletes from a previous migration, particularly if there are still open cursors on the + // range pending deletion. + const size_t numDeletes = getDeleter()->getTotalDeletes(); + if (numDeletes > 0) { + errmsg = str::stream() << "can't accept new chunks because " + << " there are still " << numDeletes + << " deletes from previous migration"; + + warning() << errmsg; + return appendCommandStatus(result, {ErrorCodes::ChunkRangeCleanupPending, errmsg}); + } + uassertStatusOK(shardingState->migrationDestinationManager()->start( nss, std::move(scopedRegisterReceiveChunk), |