@@ -33,7 +33,7 @@ const string reshard_lock_name = "reshard_process";
3333const string bucket_instance_lock_name = " bucket_instance_lock" ;
3434
3535// key reduction values; NB maybe expose some in options
36- constexpr uint64_t min_objs_per_shard = 10000 ;
36+ constexpr uint64_t default_min_objs_per_shard = 10000 ;
3737constexpr uint32_t min_dynamic_shards = 11 ;
3838
3939/* All primes up to 2000 used to attempt to make dynamic sharding use
@@ -96,9 +96,7 @@ void RGWBucketReshard::calculate_preferred_shards(
9696 const DoutPrefixProvider* dpp,
9797 const uint32_t max_dynamic_shards,
9898 const uint64_t max_objs_per_shard,
99- // const uint64_t min_objs_per_shard,
10099 const bool is_multisite,
101- // const uint64_t min_dynamic_shards, FIX THIS!!!!!!
102100 const uint64_t num_objs,
103101 const uint32_t current_num_shards,
104102 bool & need_resharding,
@@ -110,6 +108,11 @@ void RGWBucketReshard::calculate_preferred_shards(
110108 constexpr uint32_t multisite_multiplier = 8 ;
111109 const char * verb = " n/a" ;
112110
111+ // in case admin lowers max_objs_per_shard, we need to avoid thrashing
112+ const uint64_t min_objs_per_shard =
113+ std::min (default_min_objs_per_shard,
114+ (uint64_t ) std::ceil (max_objs_per_shard / 100.0 ));
115+
113116 if (current_num_shards < max_dynamic_shards &&
114117 num_objs > current_num_shards * max_objs_per_shard) {
115118 need_resharding = true ;
0 commit comments