diff options
author | Rachita Dhawan <rachita.dhawan@gmail.com> | 2023-01-11 17:43:07 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-23 22:41:56 +0000 |
commit | db9f4329fe249dcd2a31f7edebcd1bc5a68d98b5 (patch) | |
tree | a49b10daee6e5c88f338671e6b96d2ab8de99bc4 | |
parent | 126bac30396cb6b4f2d571e96997eae1e4eb2df2 (diff) | |
download | mongo-db9f4329fe249dcd2a31f7edebcd1bc5a68d98b5.tar.gz |
SERVER-68388 Limit concurrency setting
(cherry picked from commit 07b44516a04e0d3b3ebadc4fa554142788095bb9)
-rw-r--r-- | jstests/sharding/move_chunk_concurrent_cloning.js | 4 | ||||
-rw-r--r-- | src/mongo/db/s/migration_batch_fetcher.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/s/migration_batch_fetcher.h | 2 | ||||
-rw-r--r-- | src/mongo/db/s/migration_batch_fetcher_test.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_runtime_d_params.h | 13 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_runtime_d_params.idl | 6 |
6 files changed, 21 insertions, 20 deletions
diff --git a/jstests/sharding/move_chunk_concurrent_cloning.js b/jstests/sharding/move_chunk_concurrent_cloning.js index 3166f823351..dfd04e3eb5e 100644 --- a/jstests/sharding/move_chunk_concurrent_cloning.js +++ b/jstests/sharding/move_chunk_concurrent_cloning.js @@ -38,10 +38,10 @@ const runParallelMoveChunk = (numThreads) => { const kInitialLoadFinalKey = shardKeyVal; - print(`Running tests with migrationConcurrency == ${kThreadCount}`); + print(`Running tests with chunkMigrationConcurrency == ${kThreadCount}`); st._rs.forEach((replSet) => { assert.commandWorked(replSet.test.getPrimary().adminCommand( - {setParameter: 1, migrationConcurrency: kThreadCount})); + {setParameter: 1, chunkMigrationConcurrency: kThreadCount})); }); const configCollEntry = diff --git a/src/mongo/db/s/migration_batch_fetcher.cpp b/src/mongo/db/s/migration_batch_fetcher.cpp index 4611cd91ec7..8622379449f 100644 --- a/src/mongo/db/s/migration_batch_fetcher.cpp +++ b/src/mongo/db/s/migration_batch_fetcher.cpp @@ -50,16 +50,16 @@ MigrationBatchFetcher<Inserter>::MigrationBatchFetcher( std::shared_ptr<MigrationCloningProgressSharedState> migrationProgress, bool parallelFetchingSupported) : _nss{std::move(nss)}, - _migrationConcurrency{ + _chunkMigrationConcurrency{ mongo::feature_flags::gConcurrencyInChunkMigration.isEnabledAndIgnoreFCV() - ? migrationConcurrency.load() + ? chunkMigrationConcurrency.load() : 1}, _sessionId{std::move(sessionId)}, _inserterWorkers{[&]() { ThreadPool::Options options; options.poolName = "ChunkMigrationInserters"; - options.minThreads = _migrationConcurrency; - options.maxThreads = _migrationConcurrency; + options.minThreads = _chunkMigrationConcurrency; + options.maxThreads = _chunkMigrationConcurrency; options.onCreateThread = Inserter::onCreateThread; return std::make_unique<ThreadPool>(options); }()}, @@ -95,7 +95,7 @@ BSONObj MigrationBatchFetcher<Inserter>::_fetchBatch(OperationContext* opCtx) { template <typename Inserter> void MigrationBatchFetcher<Inserter>::fetchAndScheduleInsertion() { - auto numFetchers = _isParallelFetchingSupported ? _migrationConcurrency : 1; + auto numFetchers = _isParallelFetchingSupported ? _chunkMigrationConcurrency : 1; auto fetchersThreadPool = [&]() { ThreadPool::Options options; options.poolName = "ChunkMigrationFetchers"; @@ -164,7 +164,7 @@ void MigrationBatchFetcher<Inserter>::_runFetcher() try { _collectionUuid, _migrationProgress, _migrationId, - _migrationConcurrency}; + _chunkMigrationConcurrency}; _inserterWorkers->schedule([batchSize, fetchTime, diff --git a/src/mongo/db/s/migration_batch_fetcher.h b/src/mongo/db/s/migration_batch_fetcher.h index d402c3a92e6..b26f72153b1 100644 --- a/src/mongo/db/s/migration_batch_fetcher.h +++ b/src/mongo/db/s/migration_batch_fetcher.h @@ -107,7 +107,7 @@ private: NamespaceString _nss; // Size of thread pools. - int _migrationConcurrency; + int _chunkMigrationConcurrency; MigrationSessionId _sessionId; diff --git a/src/mongo/db/s/migration_batch_fetcher_test.cpp b/src/mongo/db/s/migration_batch_fetcher_test.cpp index f86368b321b..890189a3693 100644 --- a/src/mongo/db/s/migration_batch_fetcher_test.cpp +++ b/src/mongo/db/s/migration_batch_fetcher_test.cpp @@ -182,7 +182,7 @@ TEST_F(MigrationBatchFetcherTestFixture, BasicEmptyFetchingTest) { int concurrency = 30; RAIIServerParameterControllerForTest featureFlagController( "featureFlagConcurrencyInChunkMigration", true); - RAIIServerParameterControllerForTest setMigrationConcurrencyParam{"migrationConcurrency", + RAIIServerParameterControllerForTest setMigrationConcurrencyParam{"chunkMigrationConcurrency", concurrency}; AlternativeClientRegion acr(newClient); @@ -237,7 +237,7 @@ TEST_F(MigrationBatchFetcherTestFixture, BasicFetching) { int concurrency = 30; RAIIServerParameterControllerForTest featureFlagController( "featureFlagConcurrencyInChunkMigration", true); - RAIIServerParameterControllerForTest setMigrationConcurrencyParam{"migrationConcurrency", + RAIIServerParameterControllerForTest setMigrationConcurrencyParam{"chunkMigrationConcurrency", concurrency}; auto fetcher = std::make_unique<MigrationBatchFetcher<MigrationBatchMockInserter>>( diff --git a/src/mongo/db/s/sharding_runtime_d_params.h b/src/mongo/db/s/sharding_runtime_d_params.h index 00dd1fddfed..7c9b8576818 100644 --- a/src/mongo/db/s/sharding_runtime_d_params.h +++ b/src/mongo/db/s/sharding_runtime_d_params.h @@ -37,19 +37,20 @@ namespace mongo { -inline Status validateMigrationConcurrency(const int& migrationConcurrency) { +inline Status validateChunkMigrationConcurrency(const int& chunkMigrationConcurrency) { + const int maxConcurrency = 500; if (!mongo::feature_flags::gConcurrencyInChunkMigration.isEnabledAndIgnoreFCV()) { return Status{ErrorCodes::InvalidOptions, "Cannot set migration concurrency number without enabling migration " "concurrency feature flag"}; } - int maxConcurrency = ProcessInfo::getNumCores(); - if (migrationConcurrency <= 0 || - (migrationConcurrency > maxConcurrency && !getTestCommandsEnabled())) { + + if (chunkMigrationConcurrency <= 0 || + (chunkMigrationConcurrency > maxConcurrency && !getTestCommandsEnabled())) { return Status{ ErrorCodes::InvalidOptions, - fmt::format( - "Migration concurrency level must be positive and less than the number of cores.")}; + fmt::format("Chunk migration concurrency level must be positive and less than {}.", + maxConcurrency)}; } return Status::OK(); } diff --git a/src/mongo/db/s/sharding_runtime_d_params.idl b/src/mongo/db/s/sharding_runtime_d_params.idl index 271e2cf6882..af5722d6f6f 100644 --- a/src/mongo/db/s/sharding_runtime_d_params.idl +++ b/src/mongo/db/s/sharding_runtime_d_params.idl @@ -31,15 +31,15 @@ global: - "mongo/db/s/sharding_runtime_d_params.h" server_parameters: - migrationConcurrency: + chunkMigrationConcurrency: description: >- The number of threads doing insertions on the recipient during a chunk migration and also the number of _migrateClone requests that the recipient sends to the source in parallel. set_at: [startup, runtime] cpp_vartype: AtomicWord<int> - cpp_varname: migrationConcurrency + cpp_varname: chunkMigrationConcurrency validator: - callback: validateMigrationConcurrency + callback: validateChunkMigrationConcurrency default: 1 rangeDeleterBatchSize: |