From 6f67e51b39ef76ecdbd2558f44ffa592d9b4dc21 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Fri, 22 May 2020 17:43:46 -0400 Subject: [PATCH] rgwlc: add lifecycle perf counters Historically, RGW lifecycle processing has not provided perfcounters. A single expire counter was added in recent parallel lifecycle changes, but granular counters for current expiration non-current expiration delete-marker expiration current transition non-current transition mpu aborts are arguably much more useful, and can be summed in reports. Fixes: https://tracker.ceph.com/issues/45667 Signed-off-by: Matt Benjamin (cherry picked from commit 57d0bcf57d7d5774b63465ae46dafd0253afde04) --- src/rgw/rgw_lc.cc | 68 ++++++++++++++++++++++++++---------- src/rgw/rgw_lc.h | 1 + src/rgw/rgw_perf_counters.cc | 15 +++++++- src/rgw/rgw_perf_counters.h | 8 ++++- 4 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 46e17d12f89b6..d3091388608a0 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -585,10 +585,6 @@ static int remove_expired_obj(lc_op_ctx& oc, bool remove_indeed) del_op.params.obj_owner = obj_owner; del_op.params.unmod_since = meta.mtime; - if (perfcounter) { - perfcounter->inc(l_rgw_lc_remove_expired, 1); - } - return del_op.delete_obj(null_yield); } /* remove_expired_obj */ @@ -842,20 +838,26 @@ int RGWLC::handle_multipart_expiration( return; } RGWObjectCtx rctx(store); - ret = abort_multipart_upload(store, cct, &rctx, bucket_info, mp_obj); - if (ret < 0 && ret != -ERR_NO_SUCH_UPLOAD) { - ldpp_dout(wk->get_lc(), 0) - << "ERROR: abort_multipart_upload failed, ret=" << ret - << wq->thr_name() - << ", meta:" << obj.key - << dendl; - } else if (ret == -ERR_NO_SUCH_UPLOAD) { - ldpp_dout(wk->get_lc(), 5) - << "ERROR: abort_multipart_upload failed, ret=" << ret - << wq->thr_name() - << ", meta:" << obj.key - << dendl; - } + int ret = abort_multipart_upload(store, cct, &rctx, bucket_info, mp_obj); + if (ret == 0) { + if (perfcounter) { + perfcounter->inc(l_rgw_lc_abort_mpu, 1); + } + } else { + if (ret == -ERR_NO_SUCH_UPLOAD) { + ldpp_dout(wk->get_lc(), 5) + << "ERROR: abort_multipart_upload failed, ret=" << ret + << wq->thr_name() + << ", meta:" << obj.key + << dendl; + } else { + ldpp_dout(wk->get_lc(), 0) + << "ERROR: abort_multipart_upload failed, ret=" << ret + << wq->thr_name() + << ", meta:" << obj.key + << dendl; + } + } /* abort failed */ } /* expired */ }; @@ -1087,6 +1089,9 @@ public: << oc.wq->thr_name() << dendl; return r; } + if (perfcounter) { + perfcounter->inc(l_rgw_lc_expire_current, 1); + } ldout(oc.cct, 2) << "DELETED:" << oc.bucket_info.bucket << ":" << o.key << " " << oc.wq->thr_name() << dendl; } @@ -1132,6 +1137,9 @@ public: << " " << oc.wq->thr_name() << dendl; return r; } + if (perfcounter) { + perfcounter->inc(l_rgw_lc_expire_noncurrent, 1); + } ldout(oc.cct, 2) << "DELETED:" << oc.bucket_info.bucket << ":" << o.key << " (non-current expiration) " << oc.wq->thr_name() << dendl; @@ -1174,6 +1182,9 @@ public: << dendl; return r; } + if (perfcounter) { + perfcounter->inc(l_rgw_lc_expire_dm, 1); + } ldout(oc.cct, 2) << "DELETED:" << oc.bucket_info.bucket << ":" << o.key << " (delete marker expiration) " << oc.wq->thr_name() << dendl; @@ -1282,6 +1293,15 @@ protected: public: LCOpAction_CurrentTransition(const transition_action& _transition) : LCOpAction_Transition(_transition) {} + int process(lc_op_ctx& oc) { + int r = LCOpAction_Transition::process(oc); + if (r == 0) { + if (perfcounter) { + perfcounter->inc(l_rgw_lc_transition_current, 1); + } + } + return r; + } }; class LCOpAction_NonCurrentTransition : public LCOpAction_Transition { @@ -1298,6 +1318,15 @@ public: const transition_action& _transition) : LCOpAction_Transition(_transition) {} + int process(lc_op_ctx& oc) { + int r = LCOpAction_Transition::process(oc); + if (r == 0) { + if (perfcounter) { + perfcounter->inc(l_rgw_lc_transition_noncurrent, 1); + } + } + return r; + } }; void LCOpRule::build() @@ -1899,7 +1928,8 @@ void RGWLifecycleConfiguration::generate_test_instances( o.push_back(new RGWLifecycleConfiguration); } -void get_lc_oid(CephContext *cct, const string& shard_id, string *oid) +static inline void get_lc_oid(CephContext *cct, + const string& shard_id, string *oid) { int max_objs = (cct->_conf->rgw_lc_max_objs > HASH_PRIME ? HASH_PRIME : diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 03209b7ea987d..ff8be4c0efc52 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -473,6 +473,7 @@ public: WorkPool* workpool{nullptr}; public: + using lock_guard = std::lock_guard; using unique_lock = std::unique_lock; diff --git a/src/rgw/rgw_perf_counters.cc b/src/rgw/rgw_perf_counters.cc index 951bf54fee7b2..3336c4855e044 100644 --- a/src/rgw/rgw_perf_counters.cc +++ b/src/rgw/rgw_perf_counters.cc @@ -35,7 +35,20 @@ int rgw_perf_start(CephContext *cct) plb.add_u64_counter(l_rgw_keystone_token_cache_miss, "keystone_token_cache_miss", "Keystone token cache miss"); plb.add_u64_counter(l_rgw_gc_retire, "gc_retire_object", "GC object retires"); - plb.add_u64_counter(l_rgw_lc_remove_expired, "lc_remove_expired", "LC removed objects"); + + plb.add_u64_counter(l_rgw_lc_expire_current, "lc_expire_current", + "Lifecycle current expiration"); + plb.add_u64_counter(l_rgw_lc_expire_noncurrent, "lc_expire_noncurrent", + "Lifecycle non-current expiration"); + plb.add_u64_counter(l_rgw_lc_expire_dm, "lc_expire_dm", + "Lifecycle delete-marker expiration"); + plb.add_u64_counter(l_rgw_lc_transition_current, "lc_transition_current", + "Lifecycle current transition"); + plb.add_u64_counter(l_rgw_lc_transition_noncurrent, + "lc_transition_noncurrent", + "Lifecycle non-current transition"); + plb.add_u64_counter(l_rgw_lc_abort_mpu, "lc_abort_mpu", + "Lifecycle abort multipart upload"); plb.add_u64_counter(l_rgw_pubsub_event_triggered, "pubsub_event_triggered", "Pubsub events with at least one topic"); plb.add_u64_counter(l_rgw_pubsub_event_lost, "pubsub_event_lost", "Pubsub events lost"); diff --git a/src/rgw/rgw_perf_counters.h b/src/rgw/rgw_perf_counters.h index e07a3d9897c2a..a3c10d9a947d2 100644 --- a/src/rgw/rgw_perf_counters.h +++ b/src/rgw/rgw_perf_counters.h @@ -32,7 +32,13 @@ enum { l_rgw_keystone_token_cache_miss, l_rgw_gc_retire, - l_rgw_lc_remove_expired, + + l_rgw_lc_expire_current, + l_rgw_lc_expire_noncurrent, + l_rgw_lc_expire_dm, + l_rgw_lc_transition_current, + l_rgw_lc_transition_noncurrent, + l_rgw_lc_abort_mpu, l_rgw_pubsub_event_triggered, l_rgw_pubsub_event_lost, -- 2.39.5