Skip to content

Commit e2b43be

Browse files
committed
rgw/lc: enforce consistent rgw_lc_debug_interval start times
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 <[email protected]>
1 parent 25577cd commit e2b43be

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/rgw/rgw_lc.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,11 +2250,11 @@ static inline bool already_run_today(CephContext* cct, time_t start_date)
22502250
utime_t now = ceph_clock_now();
22512251
localtime_r(&start_date, &bdt);
22522252

2253-
if (cct->_conf->rgw_lc_debug_interval > 0) {
2254-
if (now - start_date < cct->_conf->rgw_lc_debug_interval)
2255-
return true;
2256-
else
2257-
return false;
2253+
if (const auto interval = cct->_conf->rgw_lc_debug_interval; interval > 0) {
2254+
// compare start_date against the beginning of the current interval
2255+
const auto remainder = now.sec() % interval;
2256+
const time_t interval_start = now.sec() - remainder;
2257+
return start_date >= interval_start;
22582258
}
22592259

22602260
bdt.tm_hour = 0;
@@ -2642,8 +2642,10 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
26422642
{
26432643
int secs;
26442644

2645-
if (cct->_conf->rgw_lc_debug_interval > 0) {
2646-
secs = start + cct->_conf->rgw_lc_debug_interval - now;
2645+
if (const auto interval = cct->_conf->rgw_lc_debug_interval; interval > 0) {
2646+
// schedule for the next interval
2647+
const auto remainder = now.sec() % interval;
2648+
secs = interval - remainder;
26472649
if (secs < 0)
26482650
secs = 0;
26492651
return (secs);

0 commit comments

Comments
 (0)