ctdb-daemon: Do not force full vacuum on first vacuuming run
authorMartin Schwenke <martin@meltin.net>
Mon, 22 Oct 2018 10:40:22 +0000 (21:40 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 18 Dec 2018 06:12:09 +0000 (07:12 +0100)
When the number of fast path vacuuming runs is 0 then a full vacuuming
run is done.  This means the first one is a full run, which is almost
certainly not what is intended.

Combine the 2 conditionals to only flag a full vacuuming run when the
count exceeds the configured limit.  This means that the
full_vacuum_run flag is set in both parent and child, but this is
harmless... and is better than getting it wrong.

Also tweak the comparison to be less-than-or-equal, since the zeroth
run needs to be counted.

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

index 2194b7f4da75619195355b7fd979264ffe8e6236..9d086917f3c47322cbd5e51c1771880a6cc63f50 100644 (file)
@@ -1205,6 +1205,7 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
        struct ctdb_context *ctdb = ctdb_db->ctdb;
        struct ctdb_vacuum_child_context *child_ctx;
        struct tevent_fd *fde;
+       bool full_vacuum_run = false;
        int ret;
 
        /* we don't vacuum if we are in recovery mode, or db frozen */
@@ -1247,7 +1248,11 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
                return;
        }
 
-       if (vacuum_handle->fast_path_count > ctdb->tunable.vacuum_fast_path_count) {
+       if (vacuum_handle->fast_path_count >=
+           ctdb->tunable.vacuum_fast_path_count) {
+               if (ctdb->tunable.vacuum_fast_path_count > 0) {
+                       full_vacuum_run = true;
+               }
                vacuum_handle->fast_path_count = 0;
        }
 
@@ -1266,7 +1271,6 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
 
        if (child_ctx->child_pid == 0) {
                char cc = 0;
-               bool full_vacuum_run = false;
                close(child_ctx->fd[0]);
 
                DEBUG(DEBUG_INFO,("Vacuuming child process %d for db %s started\n", getpid(), ctdb_db->db_name));
@@ -1276,11 +1280,6 @@ static void ctdb_vacuum_event(struct tevent_context *ev,
                        _exit(1);
                }
 
-               if ((ctdb->tunable.vacuum_fast_path_count > 0) &&
-                   (vacuum_handle->fast_path_count == 0))
-               {
-                       full_vacuum_run = true;
-               }
                cc = ctdb_vacuum_and_repack_db(ctdb_db, full_vacuum_run);
 
                sys_write(child_ctx->fd[1], &cc, 1);