]> 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)
committerkchheda3 <kchheda3@bloomberg.net>
Fri, 19 Sep 2025 20:06:44 +0000 (16:06 -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.
Signed-off-by: kchheda3 <kchheda3@bloomberg.net>
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h

index eaae450c966a14cb02889a010cf91243faf200a2..40f2ac05269f47385fe23fd79b62053cfb1dd352 100644 (file)
@@ -204,6 +204,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) {
@@ -2104,14 +2105,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);
 
@@ -2180,8 +2186,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;
@@ -2447,7 +2453,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 5a4c05adf8d6d08f33dbda38f94c81bc62187e08..250849c783a33cc3da95a3f0863048a443984670 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>&,