]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/lc: enforce consistent rgw_lc_debug_interval start times
authorCasey Bodley <cbodley@redhat.com>
Thu, 18 Sep 2025 18:00:05 +0000 (14:00 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 24 Sep 2025 18:14:04 +0000 (14:14 -0400)
when configured, rgw_lc_debug_interval causes lifecycle processing to
run every interval. but different workers/radosgws could start these
intervals at different times, making it difficult for already_run_today()
to determine which buckets should be skipped in the current interval

schedule_next_start_time() now chooses start times (in seconds since
epoch) that are divisible by the rgw_lc_debug_interval to ensure that
all workers use the same intervals

already_run_today() uses this same logic to calculate the beginning of
its current interval for comparison with the last time the bucket's
processing started

Fixes: https://tracker.ceph.com/issues/72943
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_lc.cc

index 8981c26dc81beff96abf80ae39651f30190877df..b335e4758f50453b56edb809ea93796b47b4b03d 100644 (file)
@@ -2250,11 +2250,11 @@ static inline bool already_run_today(CephContext* cct, time_t start_date)
   utime_t now = ceph_clock_now();
   localtime_r(&start_date, &bdt);
 
-  if (cct->_conf->rgw_lc_debug_interval > 0) {
-    if (now - start_date < cct->_conf->rgw_lc_debug_interval)
-      return true;
-    else
-      return false;
+  if (const auto interval = cct->_conf->rgw_lc_debug_interval; interval > 0) {
+    // compare start_date against the beginning of the current interval
+    const auto remainder = now.sec() % interval;
+    const time_t interval_start = now.sec() - remainder;
+    return start_date >= interval_start;
   }
 
   bdt.tm_hour = 0;
@@ -2642,8 +2642,10 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
 {
   int secs;
 
-  if (cct->_conf->rgw_lc_debug_interval > 0) {
-       secs = start + cct->_conf->rgw_lc_debug_interval - now;
+  if (const auto interval = cct->_conf->rgw_lc_debug_interval; interval > 0) {
+       // schedule for the next interval
+       const auto remainder = now.sec() % interval;
+       secs = interval - remainder;
        if (secs < 0)
          secs = 0;
        return (secs);