From 9bea73a633c3f2aa00ec15c1aa8bd8140a27af8c Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Thu, 29 May 2025 15:50:13 -0400 Subject: [PATCH] rgw: trigger resharding of versioned buckets sooner Versioned buckets require more keys per object. So influence the calculation of whether resharding is needed by using a lower max_objs_per_shard value for versioned buckets. Signed-off-by: J. Eric Ivancich --- src/rgw/driver/rados/rgw_rados.cc | 8 +++++--- src/rgw/rgw_quota.cc | 13 +++++++++++-- src/rgw/rgw_quota.h | 5 +++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index d36144741e3f3..e23a17c2f154f 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -10123,10 +10123,12 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, // TODO: consider per-bucket sync policy here? const bool is_multisite = svc.zone->need_to_log_data(); + const bool is_versioned = bucket_info.versioned(); - quota_handler->check_bucket_shards(dpp, max_objs_per_shard, num_source_shards, - num_objs, is_multisite, need_resharding, - &suggested_num_shards); + quota_handler->check_bucket_shards(dpp, max_objs_per_shard, + num_source_shards, num_objs, + is_multisite, is_versioned, + need_resharding, &suggested_num_shards); if (! need_resharding) { return 0; } diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index f1ae34f936809..d487613d526f8 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -963,9 +963,18 @@ public: } void check_bucket_shards(const DoutPrefixProvider *dpp, uint64_t max_objs_per_shard, - uint64_t num_shards, uint64_t num_objs, bool is_multisite, - bool& need_resharding, uint32_t *suggested_num_shards) override + uint64_t num_shards, uint64_t num_objs, + bool is_multisite, bool is_versioned, + bool& need_resharding, uint32_t *suggested_num_shards) override { + if (is_versioned) { + // since versioned buckets have multiple entries per version of + // an object, reduce maximum to try to account for this + constexpr uint64_t min_max_objs_per_shard = 1; + max_objs_per_shard = std::max(min_max_objs_per_shard, + max_objs_per_shard / 3); + } + if (num_objs > num_shards * max_objs_per_shard) { ldpp_dout(dpp, 0) << __func__ << ": resharding needed: stats.num_objects=" << num_objs << " shard max_objects=" << max_objs_per_shard * num_shards << dendl; diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h index 632cb48171b25..33d014b00c95f 100644 --- a/src/rgw/rgw_quota.h +++ b/src/rgw/rgw_quota.h @@ -35,8 +35,9 @@ public: uint64_t num_objs, uint64_t size, optional_yield y) = 0; virtual void check_bucket_shards(const DoutPrefixProvider *dpp, uint64_t max_objs_per_shard, - uint64_t num_shards, uint64_t num_objs, bool is_multisite, - bool& need_resharding, uint32_t *suggested_num_shards) = 0; + uint64_t num_shards, uint64_t num_objs, + bool is_multisite, bool is_versioned, + bool& need_resharding, uint32_t *suggested_num_shards) = 0; virtual void update_stats(const rgw_user& bucket_owner, rgw_bucket& bucket, int obj_delta, uint64_t added_bytes, uint64_t removed_bytes) = 0; -- 2.39.5