diff options
author | Silvia Surroca <silvia.surroca@mongodb.com> | 2023-04-25 08:09:41 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-25 09:06:53 +0000 |
commit | 8263eaa084ca236a1b0499ea4379160e00e16be8 (patch) | |
tree | b82ee5ce1edd4a7bae689eb3eae726d85f354fcb | |
parent | 166faa458013545f0a0afcf12d424198c6290d02 (diff) | |
download | mongo-8263eaa084ca236a1b0499ea4379160e00e16be8.tar.gz |
SERVER-75082 Make balancer migrations throttling configurable
-rw-r--r-- | src/mongo/db/s/balancer/balancer.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/s/sharding_config_server_parameters.idl | 11 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp index 36f53d7a5fc..3a49362f62e 100644 --- a/src/mongo/db/s/balancer/balancer.cpp +++ b/src/mongo/db/s/balancer/balancer.cpp @@ -80,12 +80,6 @@ MONGO_FAIL_POINT_DEFINE(overrideBalanceRoundInterval); const Milliseconds kBalanceRoundDefaultInterval(10 * 1000); -// Sleep between balancer rounds in the case where the last round found some chunks which needed to -// be balanced. This value should be set sufficiently low so that imbalanced clusters will quickly -// reach balanced state, but setting it too low may cause CRUD operations to start failing due to -// not being able to establish a stable shard version. -const Milliseconds kBalancerMigrationsThrottling(1 * 1000); - /** * Balancer status response */ @@ -819,7 +813,8 @@ void Balancer::_mainThread() { _sleepFor(opCtx.get(), forcedBalancerRoundInterval ? *forcedBalancerRoundInterval - timeSinceLastMigration - : kBalancerMigrationsThrottling - timeSinceLastMigration); + : Milliseconds(balancerMigrationsThrottlingMs.load()) - + timeSinceLastMigration); _balancedLastTime = _moveChunks(opCtx.get(), chunksToRebalance, chunksToDefragment); @@ -835,8 +830,8 @@ void Balancer::_mainThread() { .ignore(); LOGV2_DEBUG(6679500, 1, "End balancing round"); - // Migration throttling of kBalancerMigrationsThrottling will be applied before - // the next call to _moveChunks, so don't sleep here. + // Migration throttling of `balancerMigrationsThrottlingMs` will be applied + // before the next call to _moveChunks, so don't sleep here. _endRound(opCtx.get(), Milliseconds(0)); } } diff --git a/src/mongo/db/s/sharding_config_server_parameters.idl b/src/mongo/db/s/sharding_config_server_parameters.idl index 1c6402a10db..89b0bea726a 100644 --- a/src/mongo/db/s/sharding_config_server_parameters.idl +++ b/src/mongo/db/s/sharding_config_server_parameters.idl @@ -47,6 +47,17 @@ server_parameters: gte: 0 default: 1000 + balancerMigrationsThrottlingMs: + # Sleep between balancer rounds in the case where the last round found some chunks which needed to + # be balanced. This value should be set sufficiently low so that imbalanced clusters will quickly + # reach balanced state, but setting it too low may cause CRUD operations to start failing due to + # not being able to establish a stable shard version. + description: The minimum amount of time between two consecutive balancing rounds + set_at: [startup, runtime] + cpp_vartype: AtomicWord<int32_t> + cpp_varname: balancerMigrationsThrottlingMs + default: 1000 # 1 sec + balancerChunksSelectionTimeoutMs: description: >- Maximum time in milliseconds the balancer will spend deciding which ranges to move in |