]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc: re-hook RGWRados::process_lc()
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 9 Apr 2020 19:31:51 +0000 (15:31 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 21 Apr 2020 17:40:05 +0000 (13:40 -0400)
Allow the admin command to force a (single threaded) lifecycle
pass, do not instantiate background threads to do this.

Fix an apparent shutdown hang (found in the process_lc() path,
but actually general).

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h
src/rgw/rgw_rados.cc

index feef32e69daf10861f98907e4a4b4c5e7b1c7a41..77a898311740a72a94131405abf245fbd755b95d 100644 (file)
@@ -214,7 +214,7 @@ void *RGWLC::LCWorker::entry() {
     utime_t start = ceph_clock_now();
     if (should_work(start)) {
       ldpp_dout(dpp, 2) << "life cycle: start" << dendl;
-      int r = lc->process(this);
+      int r = lc->process(this, false /* once */);
       if (r < 0) {
         ldpp_dout(dpp, 0) << "ERROR: do life cycle process() returned error r="
                          << r << dendl;
@@ -1547,7 +1547,7 @@ static inline vector<int> random_sequence(uint32_t n)
   return v;
 }
 
-int RGWLC::process(LCWorker* worker)
+int RGWLC::process(LCWorker* worker, bool once = false)
 {
   int max_secs = cct->_conf->rgw_lc_lock_max_time;
 
@@ -1555,7 +1555,7 @@ int RGWLC::process(LCWorker* worker)
    * that might be running in parallel */
   vector<int> shard_seq = random_sequence(max_objs);
   for (auto index : shard_seq) {
-    int ret = process(index, max_secs, worker);
+    int ret = process(index, max_secs, worker, once);
     if (ret < 0)
       return ret;
   }
@@ -1589,7 +1589,8 @@ time_t RGWLC::thread_stop_at()
   return time(nullptr) + interval;
 }
 
-int RGWLC::process(int index, int max_lock_secs, LCWorker* worker)
+int RGWLC::process(int index, int max_lock_secs, LCWorker* worker,
+  bool once = false)
 {
   dout(5) << "RGWLC::process(): ENTER: "
          << "index: " << index << " worker ix: " << worker->ix
@@ -1702,11 +1703,13 @@ int RGWLC::process(int index, int max_lock_secs, LCWorker* worker)
     l.unlock(&store->getRados()->lc_pool_ctx, obj_names[index]);
     ret = bucket_lc_process(entry.bucket, worker, thread_stop_at());
     bucket_lc_post(index, max_lock_secs, entry, ret, worker);
-  } while(1);
+  } while(1 && !once);
+
+  return 0;
 
 exit:
-    l.unlock(&store->getRados()->lc_pool_ctx, obj_names[index]);
-    return 0;
+  l.unlock(&store->getRados()->lc_pool_ctx, obj_names[index]);
+  return 0;
 }
 
 void RGWLC::start_processor()
@@ -1810,7 +1813,6 @@ int RGWLC::LCWorker::schedule_next_start_time(utime_t &start, utime_t& now)
 
 RGWLC::LCWorker::~LCWorker()
 {
-  workpool->drain();
   delete workpool;
 } /* ~LCWorker */
 
index fd8b565f2ae60b463b375c0c662c07431cb96845..9aa64f65b07f101f47d52863711946e3f97fa4a4 100644 (file)
@@ -500,8 +500,8 @@ public:
   void initialize(CephContext *_cct, rgw::sal::RGWRadosStore *_store);
   void finalize();
 
-  int process(LCWorker* worker);
-  int process(int index, int max_secs, LCWorker* worker);
+  int process(LCWorker* worker, bool once);
+  int process(int index, int max_secs, LCWorker* worker, bool once);
   bool if_already_run_today(time_t start_date);
   bool expired_session(time_t started);
   time_t thread_stop_at();
index a989b5a87c7d809db0d5b01a753f6046f8373c7b..8c8a5af9898596993c8c64b71f4466036708e5ba 100644 (file)
@@ -8048,7 +8048,12 @@ int RGWRados::list_lc_progress(const string& marker, uint32_t max_entries,
 
 int RGWRados::process_lc()
 {
-  return lc->process(nullptr);
+  RGWLC lc;
+  lc.initialize(cct, this->store);
+  RGWLC::LCWorker worker(&lc, cct, &lc, 0);
+  auto ret = lc.process(&worker, true /* once */);
+  lc.stop_processor(); // sets down_flag, but returns immediately
+  return ret;
 }
 
 bool RGWRados::process_expire_objects()