]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/lc: if the buckets last lc processing time is less than start time of current...
authorkchheda3 <kchheda3@bloomberg.net>
Thu, 18 Sep 2025 20:01:50 +0000 (16:01 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 9 Oct 2025 15:04:45 +0000 (11:04 -0400)
Currently the logic inside expired_session() would consider an LC session valid for almost 2-3 days, so for some bucket where the lc processing POST status update fails, the next lc session would skip the bucket because the expired_session() would return false as it multiplies the num_seconds_day *2. Instead of hardcoding the logic to 2 days, store the start time for each lc session and then compare the bucket update time with lc_start time, if bucket process time is less then current lc start time, then bucket can be processed as previous session is already expired.

Fixes: https://tracker.ceph.com/issues/72572
Resolves: rhbz#2401203

Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
(cherry picked from commit 541d13a6305bac9255348eeeef61d0c5096bf5bf)

src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h

index ad757851b8ef28954cb758439c13d8c4464e3e86..628160a74c04996d1c3e734fdb2864383813a8ad 100644 (file)
@@ -203,6 +203,7 @@ void *RGWLC::LCWorker::entry() {
     std::unique_ptr<rgw::sal::Bucket> all_buckets; // empty restriction
     utime_t start = ceph_clock_now();
     if (should_work(start)) {
+      lc_start_time = time(nullptr);
       ldpp_dout(dpp, 2) << "life cycle: start worker=" << ix << dendl;
       int r = lc->process(this, all_buckets, false /* once */);
       if (r < 0) {
@@ -2077,14 +2078,19 @@ int RGWLC::process(LCWorker* worker,
   return 0;
 }
 
-bool RGWLC::expired_session(time_t started)
-{
+bool RGWLC::expired_session(time_t started, time_t lc_start_time) {
   if (! cct->_conf->rgwlc_auto_session_clear) {
     return false;
   }
-
-  time_t interval = (cct->_conf->rgw_lc_debug_interval > 0)
-    ? cct->_conf->rgw_lc_debug_interval : secs_in_a_day;
+  // lc_start_time is greater than last time when bucket was updated, then
+  // session is confirmed expired
+  if (cct->_conf->rgw_lc_debug_interval <= 0) {
+    if (lc_start_time > started) {
+      return true;
+    }
+    return false;
+  }
+  time_t interval = cct->_conf->rgw_lc_debug_interval;
 
   auto now = time(nullptr);
 
@@ -2140,8 +2146,8 @@ int RGWLC::process_bucket(int index, int max_lock_secs, LCWorker* worker,
                           bucket_entry_marker, entry);
   if (ret >= 0) {
     if (entry.status == lc_processing) {
-      if (expired_session(entry.start_time)) {
-       ldpp_dout(this, 5) << "RGWLC::process_bucket(): STALE lc session found for: " << entry
+      if (expired_session(entry.start_time, worker->lc_start_time)) {
+        ldpp_dout(this, 5) << "RGWLC::process_bucket(): STALE lc session found for: " << entry
                           << " index: " << index << " worker ix: " << worker->ix
                           << " (clearing)"
                           << dendl;
@@ -2407,7 +2413,7 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
 
     if (!entry.bucket.empty()) {
       if (entry.status == lc_processing) {
-        if (expired_session(entry.start_time)) {
+        if (expired_session(entry.start_time, worker->lc_start_time)) {
           ldpp_dout(this, 5)
               << "RGWLC::process(): STALE lc session found for: " << entry
               << " index: " << index << " worker ix: " << worker->ix
index 73305c6f19c2bbdcfcbeb7a34faaf6fdaefd8eda..77fe4dfd81d299a1d3744caf123a43756b350f29 100644 (file)
@@ -589,9 +589,9 @@ public:
      * to cloud. This list is maintained for the duration of each RGWLC::process()
      * post which it is discarded. */
     std::set<std::string> cloud_targets;
+    time_t lc_start_time;
 
-  public:
-
+   public:
     using lock_guard = std::lock_guard<std::mutex>;
     using unique_lock = std::unique_lock<std::mutex>;
 
@@ -642,7 +642,7 @@ public:
   int process(int index, int max_lock_secs, LCWorker* worker, bool once);
   int process_bucket(int index, int max_lock_secs, LCWorker* worker,
                     const std::string& bucket_entry_marker, bool once);
-  bool expired_session(time_t started);
+  bool expired_session(time_t started, time_t lc_start_time);
   time_t thread_stop_at();
   int list_lc_progress(std::string& marker, uint32_t max_entries,
                       std::vector<rgw::sal::LCEntry>&,