From: Martin Schwenke Date: Thu, 2 Apr 2020 03:42:21 +0000 (+1100) Subject: ctdb-vacuum: Reschedule vacuum event if VacuumInterval has increased X-Git-Tag: ldb-2.2.0~972 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8f3d7954da679c225f5f5a1f1baff0b06c88341;p=thirdparty%2Fsamba.git ctdb-vacuum: Reschedule vacuum event if VacuumInterval has increased The vacuuming integration tests set VacuumInterval to a very high number to avoid vacuuming collisions. This is done after the cluster is healthy, so Samba will have already been started and vacuuming will already be scheduled *at the default interval* for databases attached by Samba. This means that vacuuming controls used by vacuuming tests can still collide with the scheduled vacuuming events. Add some logic to reschedule a vacuuming event that has fired but where VacuumInterval has increased since it was originally scheduled. The increase in VacuumInterval is used as the time offset for rescheduling the event. Although this changes production behaviour for the convenience of testing, the new behaviour is completely reasonable and obeys the principle of least surprise. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue Apr 7 03:04:57 UTC 2020 on sn-devel-184 --- diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c index a6ffc13c75a..74d7215bbe8 100644 --- a/ctdb/server/ctdb_vacuum.c +++ b/ctdb/server/ctdb_vacuum.c @@ -1523,6 +1523,22 @@ static void ctdb_vacuum_event(struct tevent_context *ev, bool full_vacuum_run = false; int ret; + if (vacuum_interval > vacuum_handle->vacuum_interval) { + uint32_t d = vacuum_interval - vacuum_handle->vacuum_interval; + + DBG_INFO("Vacuum interval increased from " + "%"PRIu32" to %"PRIu32", rescheduling\n", + vacuum_handle->vacuum_interval, + vacuum_interval); + vacuum_handle->vacuum_interval = vacuum_interval; + tevent_add_timer(ctdb->ev, + vacuum_handle, + timeval_current_ofs(d, 0), + ctdb_vacuum_event, + vacuum_handle); + return; + } + vacuum_handle->vacuum_interval = vacuum_interval; if (vacuum_handle->fast_path_count >= fast_path_max) {