Skip to content

Commit 81e2bc1

Browse files
committed
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 <[email protected]>
1 parent cf51417 commit 81e2bc1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/rgw/driver/rados/rgw_reshard.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const string reshard_lock_name = "reshard_process";
3232
const string bucket_instance_lock_name = "bucket_instance_lock";
3333

3434
// key reduction values; NB maybe expose some in options
35-
constexpr uint64_t min_objs_per_shard = 10000;
35+
constexpr uint64_t default_min_objs_per_shard = 10000;
3636
constexpr uint32_t min_dynamic_shards = 11;
3737

3838
/* All primes up to 2000 used to attempt to make dynamic sharding use
@@ -95,9 +95,7 @@ void RGWBucketReshard::calculate_preferred_shards(
9595
const DoutPrefixProvider* dpp,
9696
const uint32_t max_dynamic_shards,
9797
const uint64_t max_objs_per_shard,
98-
// const uint64_t min_objs_per_shard,
9998
const bool is_multisite,
100-
// const uint64_t min_dynamic_shards, FIX THIS!!!!!!
10199
const uint64_t num_objs,
102100
const uint32_t current_num_shards,
103101
bool& need_resharding,
@@ -109,6 +107,11 @@ void RGWBucketReshard::calculate_preferred_shards(
109107
constexpr uint32_t multisite_multiplier = 8;
110108
const char* verb = "n/a";
111109

110+
// in case admin lowers max_objs_per_shard, we need to avoid thrashing
111+
const uint64_t min_objs_per_shard =
112+
std::min(default_min_objs_per_shard,
113+
(uint64_t) std::ceil(max_objs_per_shard / 100.0));
114+
112115
if (current_num_shards < max_dynamic_shards &&
113116
num_objs > current_num_shards * max_objs_per_shard) {
114117
need_resharding = true;

0 commit comments

Comments
 (0)