]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Prune datalog generations in the renew loop
authorAdam C. Emerson <aemerson@redhat.com>
Wed, 27 Jan 2021 01:30:58 +0000 (20:30 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 29 Mar 2021 16:25:58 +0000 (12:25 -0400)
Every 150 times through, which is a bit less than an hour between runs
by default.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_datalog.cc

index 9f919f4efe8962ee4adabd66e6dee1ad42f54974..a8d1cd1684193404cd246ad753f6af9f11f18ae8 100644 (file)
@@ -931,6 +931,8 @@ RGWDataChangesLog::~RGWDataChangesLog() {
 }
 
 void RGWDataChangesLog::renew_run() noexcept {
+  static constexpr auto runs_per_prune = 150;
+  auto run = 0;
   for (;;) {
     dout(2) << "RGWDataChangesLog::ChangesRenewThread: start" << dendl;
     int r = renew_entries();
@@ -941,6 +943,25 @@ void RGWDataChangesLog::renew_run() noexcept {
     if (going_down())
       break;
 
+    if (run == runs_per_prune) {
+      std::optional<uint64_t> through;
+      dout(2) << "RGWDataChangesLog::ChangesRenewThread: pruning old generations" << dendl;
+      trim_generations(through);
+      if (r < 0) {
+       derr << "RGWDataChangesLog::ChangesRenewThread: failed pruning r="
+            << r << dendl;
+      } else if (through) {
+       dout(2) << "RGWDataChangesLog::ChangesRenewThread: pruned generations "
+               << "through " << *through << "." << dendl;
+      } else {
+       dout(2) << "RGWDataChangesLog::ChangesRenewThread: nothing to prune."
+               << dendl;
+      }
+      run = 0;
+    } else {
+      ++run;
+    }
+
     int interval = cct->_conf->rgw_data_log_window * 3 / 4;
     std::unique_lock locker{renew_lock};
     renew_cond.wait_for(locker, std::chrono::seconds(interval));