ctdb-vacuum: Only schedule next vacuum event if vacuuuming is scheduled
authorMartin Schwenke <martin@meltin.net>
Tue, 15 Oct 2019 05:36:44 +0000 (16:36 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 24 Oct 2019 04:06:43 +0000 (04:06 +0000)
At the moment vacuuming is always scheduled.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_vacuum.c

index b21e0954cd427773fa0fd8c985e81eb397560571..8df362be233ed0e7d3caf51022b5096ec104b100 100644 (file)
@@ -54,6 +54,7 @@ struct ctdb_vacuum_child_context {
        pid_t child_pid;
        enum vacuum_child_status status;
        struct timeval start_time;
+       bool scheduled;
 };
 
 struct ctdb_vacuum_handle {
@@ -1326,9 +1327,14 @@ static int vacuum_child_destructor(struct ctdb_vacuum_child_context *child_ctx)
 
        ctdb->vacuumer = NULL;
 
-       tevent_add_timer(ctdb->ev, child_ctx->vacuum_handle,
-                        timeval_current_ofs(get_vacuum_interval(ctdb_db), 0),
-                        ctdb_vacuum_event, child_ctx->vacuum_handle);
+       if (child_ctx->scheduled) {
+               tevent_add_timer(
+                       ctdb->ev,
+                       child_ctx->vacuum_handle,
+                       timeval_current_ofs(get_vacuum_interval(ctdb_db), 0),
+                       ctdb_vacuum_event,
+                       child_ctx->vacuum_handle);
+       }
 
        return 0;
 }
@@ -1380,6 +1386,7 @@ static void vacuum_child_handler(struct tevent_context *ev,
  */
 static int vacuum_db_child(TALLOC_CTX *mem_ctx,
                           struct ctdb_db_context *ctdb_db,
+                          bool scheduled,
                           bool full_vacuum_run,
                           struct ctdb_vacuum_child_context **out)
 {
@@ -1455,6 +1462,7 @@ static int vacuum_db_child(TALLOC_CTX *mem_ctx,
        close(child_ctx->fd[1]);
 
        child_ctx->status = VACUUM_RUNNING;
+       child_ctx->scheduled = scheduled;
        child_ctx->start_time = timeval_current();
 
        ctdb->vacuumer = child_ctx;
@@ -1517,6 +1525,7 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
 
        ret = vacuum_db_child(vacuum_handle,
                              ctdb_db,
+                             true,
                              full_vacuum_run,
                              &child_ctx);