Skip to content

Commit 27f9c10

Browse files
committed
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 <[email protected]>
1 parent b71625d commit 27f9c10

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11151,6 +11151,10 @@ void RGWRados::calculate_preferred_shards(const DoutPrefixProvider* dpp,
1115111151
max_objs_per_shard /= 3;
1115211152
}
1115311153

11154+
// make sure it's at least 1, as in some testing scenarios it's artificially low
11155+
constexpr uint64_t min_max_objs_per_shard = 1;
11156+
max_objs_per_shard = std::max(min_max_objs_per_shard, max_objs_per_shard);
11157+
1115411158
const bool is_multisite = svc.zone->need_to_log_data();
1115511159

1115611160
RGWBucketReshard::calculate_preferred_shards(dpp,

0 commit comments

Comments
 (0)