]> git.apps.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, 5 Apr 2021 17:47:12 +0000 (13:47 -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>
(cherry picked from commit 8f4291291b0dea4b4701894da0775149266a1373)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Conflicts:
src/rgw/rgw_datalog.cc

src/rgw/rgw_datalog.cc

index 3ecab432646c13b67e3916839f83a5c4e60c98f0..d81d955ef6f173c1a354288ec8e9fe0c421b6ebe 100644 (file)
@@ -930,6 +930,8 @@ RGWDataChangesLog::~RGWDataChangesLog() {
 }
 
 void RGWDataChangesLog::renew_run() {
+  static constexpr auto runs_per_prune = 150;
+  auto run = 0;
   for (;;) {
     dout(2) << "RGWDataChangesLog::ChangesRenewThread: start" << dendl;
     int r = renew_entries();
@@ -940,6 +942,25 @@ void RGWDataChangesLog::renew_run() {
     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));