diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2021-06-25 15:04:59 +0000 |
---|---|---|
committer | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2021-06-25 15:04:59 +0000 |
commit | 996f8eb8f5540143790df5cff7f761f82e30444d (patch) | |
tree | f68ab9d9ecf1afa0d9a9843f62b93b15a6a9897b | |
parent | 4470421a5cb13051cfd5d0fccd48cd0cff72aa98 (diff) | |
download | mongo-996f8eb8f5540143790df5cff7f761f82e30444d.tar.gz |
Revert "SERVER-52906 Applying metadata update before dispatching rollback task in moveChunk"
This reverts commit 51b58488decbaa166b3b8069cc2b18288899f904.
-rw-r--r-- | jstests/libs/chunk_manipulation_util.js | 4 | ||||
-rw-r--r-- | jstests/sharding/migration_waits_for_majority_commit.js | 6 | ||||
-rw-r--r-- | src/mongo/db/s/migration_destination_manager.cpp | 48 |
3 files changed, 24 insertions, 34 deletions
diff --git a/jstests/libs/chunk_manipulation_util.js b/jstests/libs/chunk_manipulation_util.js index 177e5af18ea..99a7e100b32 100644 --- a/jstests/libs/chunk_manipulation_util.js +++ b/jstests/libs/chunk_manipulation_util.js @@ -158,8 +158,8 @@ function waitForMoveChunkStep(shardConnection, stepNumber) { } var migrateStepNames = { - copiedIndexes: 1, - deletedPriorDataInRange: 2, + deletedPriorDataInRange: 1, + copiedIndexes: 2, cloned: 3, catchup: 4, // About to enter steady state. steady: 5, diff --git a/jstests/sharding/migration_waits_for_majority_commit.js b/jstests/sharding/migration_waits_for_majority_commit.js index 6292bee5636..8fbf88ffb39 100644 --- a/jstests/sharding/migration_waits_for_majority_commit.js +++ b/jstests/sharding/migration_waits_for_majority_commit.js @@ -28,7 +28,7 @@ assert.commandWorked(st.s.adminCommand( assert.eq(1, testDB.foo.find().readConcern("majority").itcount()); // Advance a migration to the beginning of the cloning phase. -pauseMigrateAtStep(st.rs1.getPrimary(), migrateStepNames.deletedPriorDataInRange); +pauseMigrateAtStep(st.rs1.getPrimary(), 2); // For startParallelOps to write its state let staticMongod = MongoRunner.runMongod({}); @@ -43,7 +43,7 @@ let awaitMigration = moveChunkParallel(staticMongod, // Wait for the migration to reach the failpoint and allow any writes to become majority committed // before pausing replication. -waitForMigrateStep(st.rs1.getPrimary(), migrateStepNames.deletedPriorDataInRange); +waitForMigrateStep(st.rs1.getPrimary(), 2); st.rs1.awaitLastOpCommitted(); // Disable replication on the recipient shard's secondary node, so the recipient shard's majority @@ -52,7 +52,7 @@ const destinationSec = st.rs1.getSecondary(); stopServerReplication(destinationSec); // Allow the migration to begin cloning. -unpauseMigrateAtStep(st.rs1.getPrimary(), migrateStepNames.deletedPriorDataInRange); +unpauseMigrateAtStep(st.rs1.getPrimary(), 2); // Check the migration coordinator document, because the moveChunk command itself // will hang on trying to remove the recipient's range deletion entry with majority writeConcern diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index 82198024785..a1cd12a5e93 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -967,33 +967,6 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx) { auto fromShard = uassertStatusOK(Grid::get(outerOpCtx)->shardRegistry()->getShard(outerOpCtx, _fromShard)); - // The conventional usage of retryable writes is to assign statement id's to all of - // the writes done as part of the data copying so that _recvChunkStart is - // conceptually a retryable write batch. However, we are using an alternate approach to do those - // writes under an AlternativeClientRegion because 1) threading the - // statement id's through to all the places where they are needed would make this code more - // complex, and 2) some of the operations, like creating the collection or building indexes, are - // not currently supported in retryable writes. - { - auto newClient = outerOpCtx->getServiceContext()->makeClient("MigrationCoordinator"); - { - stdx::lock_guard<Client> lk(*newClient.get()); - newClient->setSystemOperationKillableByStepdown(lk); - } - - AlternativeClientRegion acr(newClient); - auto executor = - Grid::get(outerOpCtx->getServiceContext())->getExecutorPool()->getFixedExecutor(); - auto altOpCtx = CancelableOperationContext( - cc().makeOperationContext(), outerOpCtx->getCancellationToken(), executor); - - _dropLocalIndexesIfNecessary(altOpCtx.get(), _nss, donorCollectionOptionsAndIndexes); - cloneCollectionIndexesAndOptions(altOpCtx.get(), _nss, donorCollectionOptionsAndIndexes); - - timing.done(1); - migrateThreadHangAtStep1.pauseWhileSet(); - } - { const ChunkRange range(_min, _max); @@ -1050,21 +1023,38 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx) { outerOpCtx, latestOpTime, WriteConcerns::kMajorityWriteConcern, &ignoreResult)); }); - timing.done(2); - migrateThreadHangAtStep2.pauseWhileSet(); + timing.done(1); + migrateThreadHangAtStep1.pauseWhileSet(); } + // The conventional usage of retryable writes is to assign statement id's to all of + // the writes done as part of the data copying so that _recvChunkStart is + // conceptually a retryable write batch. However, we are using an alternate approach to do those + // writes under an AlternativeClientRegion because 1) threading the + // statement id's through to all the places where they are needed would make this code more + // complex, and 2) some of the operations, like creating the collection or building indexes, are + // not currently supported in retryable writes. auto newClient = outerOpCtx->getServiceContext()->makeClient("MigrationCoordinator"); { stdx::lock_guard<Client> lk(*newClient.get()); newClient->setSystemOperationKillableByStepdown(lk); } + AlternativeClientRegion acr(newClient); auto executor = Grid::get(outerOpCtx->getServiceContext())->getExecutorPool()->getFixedExecutor(); auto newOpCtxPtr = CancelableOperationContext( cc().makeOperationContext(), outerOpCtx->getCancellationToken(), executor); auto opCtx = newOpCtxPtr.get(); + + { + _dropLocalIndexesIfNecessary(opCtx, _nss, donorCollectionOptionsAndIndexes); + cloneCollectionIndexesAndOptions(opCtx, _nss, donorCollectionOptionsAndIndexes); + + timing.done(2); + migrateThreadHangAtStep2.pauseWhileSet(); + } + repl::OpTime lastOpApplied; { // 3. Initial bulk clone |