From: Adam C. Emerson Date: Wed, 27 Jan 2021 01:30:58 +0000 (-0500) Subject: rgw: Prune datalog generations in the renew loop X-Git-Tag: v16.2.2~8^2~9^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad5a2fadf0fb16d4fc3066811fe11fc53c868263;p=ceph.git rgw: Prune datalog generations in the renew loop Every 150 times through, which is a bit less than an hour between runs by default. Signed-off-by: Adam C. Emerson (cherry picked from commit 8f4291291b0dea4b4701894da0775149266a1373) Signed-off-by: Adam C. Emerson Conflicts: src/rgw/rgw_datalog.cc --- diff --git a/src/rgw/rgw_datalog.cc b/src/rgw/rgw_datalog.cc index 3ecab432646..d81d955ef6f 100644 --- a/src/rgw/rgw_datalog.cc +++ b/src/rgw/rgw_datalog.cc @@ -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 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));