diff options
author | Alex Taskov <alex.taskov@mongodb.com> | 2020-01-30 21:22:36 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-30 21:22:36 +0000 |
commit | e4fc8b73d3a943cbc9071320876ea1f58f151bb5 (patch) | |
tree | df6c3c22b3fb938d22c999fff5617cd76be1901c /src | |
parent | 94bd81eb2dce3e744a922b27d710ce192a8a3662 (diff) | |
download | mongo-e4fc8b73d3a943cbc9071320876ea1f58f151bb5.tar.gz |
SERVER-45743 Add a flag to allow opting out of using the Resumable RangeDeleter
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/s/migration_destination_manager.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/s/migration_destination_manager.h | 4 | ||||
-rw-r--r-- | src/mongo/db/s/migration_source_manager.cpp | 28 | ||||
-rw-r--r-- | src/mongo/db/s/migration_source_manager.h | 6 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_runtime_d_params.idl | 7 | ||||
-rw-r--r-- | src/mongo/db/s/start_chunk_clone_request.cpp | 10 |
7 files changed, 46 insertions, 27 deletions
diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp index 5ba3a2068e7..b9dd891ed17 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp @@ -44,6 +44,7 @@ #include "mongo/db/repl/replication_process.h" #include "mongo/db/s/collection_sharding_runtime.h" #include "mongo/db/s/migration_source_manager.h" +#include "mongo/db/s/sharding_runtime_d_params_gen.h" #include "mongo/db/s/sharding_statistics.h" #include "mongo/db/s/start_chunk_clone_request.h" #include "mongo/db/service_context.h" @@ -279,7 +280,8 @@ Status MigrationChunkClonerSourceLegacy::startClone(OperationContext* opCtx, BSONObjBuilder cmdBuilder; auto fcvVersion = serverGlobalParams.featureCompatibility.getVersion(); - if (fcvVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { + if (fcvVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44 && + !disableResumableRangeDeleter.load()) { StartChunkCloneRequest::appendAsCommand(&cmdBuilder, _args.getNss(), migrationId, @@ -292,7 +294,8 @@ Status MigrationChunkClonerSourceLegacy::startClone(OperationContext* opCtx, _shardKeyPattern.toBSON(), _args.getSecondaryThrottle()); } else { - // TODO (SERVER-44787): Remove this overload after 4.4 is released. + // TODO (SERVER-44787): Remove this overload after 4.4 is released AND + // disableResumableRangeDeleter has been removed from server parameters. StartChunkCloneRequest::appendAsCommand(&cmdBuilder, _args.getNss(), _sessionId, diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index ad170299a1a..a44e6bdda24 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -343,14 +343,15 @@ Status MigrationDestinationManager::start(OperationContext* opCtx, // Note: It is expected that the FCV cannot change while the node is donating or receiving a // chunk. This is guaranteed by the setFCV command serializing with donating and receiving // chunks via the ActiveMigrationsRegistry. - _useFCV44Protocol = - fcvVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44; + _enableResumableRangeDeleter = + fcvVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44 && + !disableResumableRangeDeleter.load(); _state = READY; _stateChangedCV.notify_all(); _errmsg = ""; - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { uassert(ErrorCodes::ConflictingOperationInProgress, "Missing migrationId in FCV 4.4", cloneRequest.hasMigrationId()); @@ -767,7 +768,7 @@ void MigrationDestinationManager::_migrateThread() { _setStateFail(str::stream() << "migrate failed: " << redact(exceptionToStatus())); } - if (!_useFCV44Protocol) { + if (!_enableResumableRangeDeleter) { if (getState() != DONE) { _forgetPending(opCtx.get(), ChunkRange(_min, _max)); } @@ -812,7 +813,7 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* opCtx) { // 2. Ensure any data which might have been left orphaned in the range being moved has been // deleted. - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { while (migrationutil::checkForConflictingDeletions( opCtx, range, donorCollectionOptionsAndIndexes.uuid)) { LOG(0) << "Migration paused because range overlaps with a " diff --git a/src/mongo/db/s/migration_destination_manager.h b/src/mongo/db/s/migration_destination_manager.h index 78ea4741e8e..6be51ce2dd8 100644 --- a/src/mongo/db/s/migration_destination_manager.h +++ b/src/mongo/db/s/migration_destination_manager.h @@ -202,7 +202,9 @@ private: stdx::thread _migrateThreadHandle; - bool _useFCV44Protocol{false}; + // Whether to use the resumable range deleter. This decision is based on whether the FCV 4.2 or + // FCV 4.4 protocol are in use and the disableResumableRangeDeleter option is off. + bool _enableResumableRangeDeleter{true}; UUID _migrationId; NamespaceString _nss; diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp index 728366a814c..1f779820e75 100644 --- a/src/mongo/db/s/migration_source_manager.cpp +++ b/src/mongo/db/s/migration_source_manager.cpp @@ -50,6 +50,7 @@ #include "mongo/db/s/shard_filtering_metadata_refresh.h" #include "mongo/db/s/shard_metadata_util.h" #include "mongo/db/s/sharding_logging.h" +#include "mongo/db/s/sharding_runtime_d_params_gen.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/s/sharding_state_recovery.h" #include "mongo/db/s/sharding_statistics.h" @@ -116,6 +117,12 @@ void refreshRecipientRoutingTable(OperationContext* opCtx, executor->scheduleRemoteCommand(request, noOp).getStatus().ignore(); } +bool isFCVLatest() { + auto fcvVersion = serverGlobalParams.featureCompatibility.getVersion(); + + return fcvVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44; +} + } // namespace MONGO_FAIL_POINT_DEFINE(doNotRefreshRecipientAfterCommit); @@ -143,12 +150,13 @@ MigrationSourceManager::MigrationSourceManager(OperationContext* opCtx, // chunk. This is guaranteed by the setFCV command serializing with donating and receiving // chunks via the ActiveMigrationsRegistry. auto fcvVersion = serverGlobalParams.featureCompatibility.getVersion(); + uassert(ErrorCodes::ConflictingOperationInProgress, "Can't donate chunk while FCV is upgrading/downgrading", fcvVersion != ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo44 && fcvVersion != ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo42); - _useFCV44Protocol = - fcvVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44; + + _enableResumableRangeDeleter = isFCVLatest() && !disableResumableRangeDeleter.load(); // Disallow moving a chunk to ourselves uassert(ErrorCodes::InvalidOptions, @@ -283,7 +291,7 @@ Status MigrationSourceManager::startClone() { auto lockedCsr = CollectionShardingRuntime::CSRLock::lockExclusive(_opCtx, csr); invariant(nullptr == std::exchange(msmForCsr(csr), this)); - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { _coordinator = std::make_unique<migrationutil::MigrationCoordinator>( migrationId, _args.getFromShardId(), @@ -306,7 +314,7 @@ Status MigrationSourceManager::startClone() { _opCtx, readConcernArgs, PrepareConflictBehavior::kEnforce); } - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { _coordinator->startMigration(_opCtx, _args.getWaitForDelete()); } @@ -426,7 +434,7 @@ Status MigrationSourceManager::commitChunkMetadataOnConfig() { ChunkType migratedChunkType; migratedChunkType.setMin(_args.getMinKey()); migratedChunkType.setMax(_args.getMaxKey()); - if (_useFCV44Protocol) { + if (isFCVLatest()) { migratedChunkType.setVersion(_chunkVersion); } @@ -467,7 +475,7 @@ Status MigrationSourceManager::commitChunkMetadataOnConfig() { Shard::CommandResponse::getEffectiveStatus(commitChunkMigrationResponse); if (!migrationCommitStatus.isOK()) { - if (_useFCV44Protocol) { + if (isFCVLatest()) { migrationutil::ensureChunkVersionIsGreaterThan(_opCtx, _args.getRange(), _chunkVersion); } else { // This is the FCV 4.2 and below protocol. @@ -542,7 +550,7 @@ Status MigrationSourceManager::commitChunkMetadataOnConfig() { "have re-received the chunk"}; } - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { _coordinator->setMigrationDecision( migrationutil::MigrationCoordinator::Decision::kAborted); } @@ -555,7 +563,7 @@ Status MigrationSourceManager::commitChunkMetadataOnConfig() { LOG(0) << "Migration succeeded and updated collection version to " << refreshedMetadata->getCollVersion(); - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { _coordinator->setMigrationDecision( migrationutil::MigrationCoordinator::Decision::kCommitted); } @@ -595,7 +603,7 @@ Status MigrationSourceManager::commitChunkMetadataOnConfig() { << "Moved chunks successfully but failed to clean up " << getNss().ns() << " range " << redact(range.toString()) << " due to: "; - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { if (_args.getWaitForDelete()) { log() << "Waiting for cleanup of " << getNss().ns() << " range " << redact(range.toString()); @@ -778,7 +786,7 @@ void MigrationSourceManager::_cleanup() { ShardingStateRecovery::endMetadataOp(_opCtx); } - if (_useFCV44Protocol) { + if (_enableResumableRangeDeleter) { if (_state >= kCloning && _state < kCommittingOnConfig) { invariant(_coordinator); _coordinator->setMigrationDecision( diff --git a/src/mongo/db/s/migration_source_manager.h b/src/mongo/db/s/migration_source_manager.h index e833e2a641c..b0aef2c7327 100644 --- a/src/mongo/db/s/migration_source_manager.h +++ b/src/mongo/db/s/migration_source_manager.h @@ -252,9 +252,9 @@ private: // collection doesn't have UUID. boost::optional<UUID> _collectionUuid; - // Whether to use the FCV 4.2 or FCV 4.4 protocol. After branching for v4.4, this should be - // removed and the FCV 4.4 protocol should always be used. - bool _useFCV44Protocol; + // Whether to use the resumable range deleter. This decision is based on whether the FCV 4.2 or + // FCV 4.4 protocol are in use and the disableResumableRangeDeleter option is off. + bool _enableResumableRangeDeleter; // Contains logic for ensuring the donor's and recipient's config.rangeDeletions entries are // correctly updated based on whether the migration committed or aborted. diff --git a/src/mongo/db/s/sharding_runtime_d_params.idl b/src/mongo/db/s/sharding_runtime_d_params.idl index 44f808d412a..ddb8230386c 100644 --- a/src/mongo/db/s/sharding_runtime_d_params.idl +++ b/src/mongo/db/s/sharding_runtime_d_params.idl @@ -90,3 +90,10 @@ server_parameters: cpp_vartype: AtomicWord<int> cpp_varname: orphanCleanupDelaySecs default: 900 + + disableResumableRangeDeleter: + description: 'Disable the resumable range deleter and revert to prior behavior.' + set_at: [startup, runtime] + cpp_vartype: AtomicWord<bool> + cpp_varname : disableResumableRangeDeleter + default: false diff --git a/src/mongo/db/s/start_chunk_clone_request.cpp b/src/mongo/db/s/start_chunk_clone_request.cpp index 30d2813a428..883bca6b9f7 100644 --- a/src/mongo/db/s/start_chunk_clone_request.cpp +++ b/src/mongo/db/s/start_chunk_clone_request.cpp @@ -74,12 +74,10 @@ StatusWith<StartChunkCloneRequest> StartChunkCloneRequest::createFromCommand(Nam std::move(sessionIdStatus.getValue()), std::move(secondaryThrottleStatus.getValue())); - // TODO (SERVER-44787): Remove this FCV check after 4.4 is released. - if (serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { - if (obj.getField("uuid")) - request._migrationId = UUID::parse(obj); - } + // TODO (SERVER-44787): Remove this existence check after 4.4 is released and the + // disableResumableRangeDeleter option is removed. + if (obj.getField("uuid")) + request._migrationId = UUID::parse(obj); { std::string fromShardConnectionString; |