From 81e2bc1124aa6b78bb222c5ea7cc41925f29a476 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Wed, 3 Jul 2024 15:44:52 -0400 Subject: [PATCH] rgw: make sure min objs per shard is appropriate The admin has control over the rgw_max_objs_per_shard configuration option. Currently the minimum objects per shard is hard-coded. If that max is lowered then we need to be certain that the minimum is an appropriate value, certainly less than the max. Signed-off-by: J. Eric Ivancich --- src/rgw/driver/rados/rgw_reshard.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rgw/driver/rados/rgw_reshard.cc b/src/rgw/driver/rados/rgw_reshard.cc index 3d38aa29aa034..b57eabb099e1c 100644 --- a/src/rgw/driver/rados/rgw_reshard.cc +++ b/src/rgw/driver/rados/rgw_reshard.cc @@ -32,7 +32,7 @@ const string reshard_lock_name = "reshard_process"; const string bucket_instance_lock_name = "bucket_instance_lock"; // key reduction values; NB maybe expose some in options -constexpr uint64_t min_objs_per_shard = 10000; +constexpr uint64_t default_min_objs_per_shard = 10000; constexpr uint32_t min_dynamic_shards = 11; /* All primes up to 2000 used to attempt to make dynamic sharding use @@ -95,9 +95,7 @@ void RGWBucketReshard::calculate_preferred_shards( const DoutPrefixProvider* dpp, const uint32_t max_dynamic_shards, const uint64_t max_objs_per_shard, -// const uint64_t min_objs_per_shard, const bool is_multisite, -// const uint64_t min_dynamic_shards, FIX THIS!!!!!! const uint64_t num_objs, const uint32_t current_num_shards, bool& need_resharding, @@ -109,6 +107,11 @@ void RGWBucketReshard::calculate_preferred_shards( constexpr uint32_t multisite_multiplier = 8; const char* verb = "n/a"; + // in case admin lowers max_objs_per_shard, we need to avoid thrashing + const uint64_t min_objs_per_shard = + std::min(default_min_objs_per_shard, + (uint64_t) std::ceil(max_objs_per_shard / 100.0)); + if (current_num_shards < max_dynamic_shards && num_objs > current_num_shards * max_objs_per_shard) { need_resharding = true; -- 2.39.5