From 6bb36c88fd5b71cd2a4a4a58905928c0b0c7f060 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Thu, 22 May 2025 16:15:56 -0400 Subject: [PATCH] rgw: make sure max_objs_per_shard is appropriate in debugging scenarios When we have a versioned bucket, we reduce max_objs_per_shard by a factor of 3 to account for the extra bucket index entries required in such buckets. And during debugging, we may want to induce early resharding by setting max_objs_per_shard to an artificially low value. Combined, that math could result in max_objs_per_shard with a value of 0 that would cause a division by zero crash. This fixes that. Signed-off-by: J. Eric Ivancich (cherry picked from commit 27f9c103f1a98b78b9bd58d0e669d557c3851702) --- src/rgw/driver/rados/rgw_rados.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index f60a5e700ebf..230a88420345 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -11147,6 +11147,10 @@ void RGWRados::calculate_preferred_shards(const DoutPrefixProvider* dpp, max_objs_per_shard /= 3; } + // make sure it's at least 1, as in some testing scenarios it's artificially low + constexpr uint64_t min_max_objs_per_shard = 1; + max_objs_per_shard = std::max(min_max_objs_per_shard, max_objs_per_shard); + const bool is_multisite = svc.zone->need_to_log_data(); RGWBucketReshard::calculate_preferred_shards(dpp, -- 2.47.3