summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-08-29 14:30:00 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-08-29 14:30:16 -0400
commit0a30697f653ab8a58b509a52ef0c8337c90c7552 (patch)
tree9cbd5c709883fc3313f636ea9c86373db1c70b48
parent1ae76f594ed0dfdb7659b085b93352c0c956c167 (diff)
downloadmongo-0a30697f653ab8a58b509a52ef0c8337c90c7552.tar.gz
SERVER-27725 Do not perform orphan check while doing range deletion as part of chunk receive
-rw-r--r--src/mongo/db/s/metadata_manager.cpp2
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp19
-rw-r--r--src/mongo/db/s/migration_destination_manager_legacy_commands.cpp16
3 files changed, 19 insertions, 18 deletions
diff --git a/src/mongo/db/s/metadata_manager.cpp b/src/mongo/db/s/metadata_manager.cpp
index 0bba1ff478e..afda09358f2 100644
--- a/src/mongo/db/s/metadata_manager.cpp
+++ b/src/mongo/db/s/metadata_manager.cpp
@@ -192,8 +192,6 @@ void MetadataManager::beginReceive(const ChunkRange& range) {
auto itRecv = _receivingChunks.find(overlapChunkMin.first);
invariant(itRecv != _receivingChunks.end());
- const ChunkRange receivingRange(itRecv->first, itRecv->second.getMaxKey());
-
_receivingChunks.erase(itRecv);
}
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index 8dae501c57e..72284059c07 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -665,6 +665,12 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* txn,
wunit.commit();
}
+ Status status = _notePending(txn, _nss, min, max, epoch);
+ if (!status.isOK()) {
+ setState(FAIL);
+ return;
+ }
+
timing.done(1);
MONGO_FAIL_POINT_PAUSE_WHILE_SET(migrateThreadHangAtStep1);
}
@@ -680,7 +686,12 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* txn,
// results
deleterOptions.waitForOpenCursors = false;
deleterOptions.fromMigrate = true;
- deleterOptions.onlyRemoveOrphanedDocs = true;
+
+ // There is no need to perform checking for orphaned docs as part of the range deletion,
+ // because the call above (to _notePending) will ensure that the chunk which is coming in is
+ // not currently owned by this shard and the scopedRegisterReceiveChunk would prevent this
+ // chunk from getting received while range deletion is running.
+ deleterOptions.onlyRemoveOrphanedDocs = false;
deleterOptions.removeSaverReason = "preCleanup";
if (!getDeleter()->deleteNow(txn, deleterOptions, &errmsg)) {
@@ -689,12 +700,6 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* txn,
return;
}
- Status status = _notePending(txn, _nss, min, max, epoch);
- if (!status.isOK()) {
- setState(FAIL);
- return;
- }
-
timing.done(2);
MONGO_FAIL_POINT_PAUSE_WHILE_SET(migrateThreadHangAtStep2);
}
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 ac9752fd96d..4c28de35b44 100644
--- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp
+++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp
@@ -111,11 +111,16 @@ public:
}
}
-
const NamespaceString nss(cmdObj.firstElement().String());
-
const auto chunkRange = uassertStatusOK(ChunkRange::fromBSON(cmdObj));
+ 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)));
+
// Refresh our collection manager from the config server, we need a collection manager to
// start registering pending chunks. We force the remote refresh here to make the behavior
// consistent and predictable, generally we'd refresh anyway, and to be paranoid.
@@ -147,13 +152,6 @@ public:
return false;
}
- 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.