ctdb-vacuum: Stagger vacuuming child processes
authorAmitay Isaacs <amitay@gmail.com>
Fri, 21 Feb 2014 03:58:00 +0000 (14:58 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 5 Dec 2014 13:43:07 +0000 (14:43 +0100)
This prevents multiple child processes being forked at the same time
for vacuuming TDBs.

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

index 8cd37aa8315e08322ee7f04c9539f659863814da..0f1de19245d039e686996f1aeaff0f32b0572440 100644 (file)
@@ -1451,6 +1451,17 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
                return;
        }
 
+       /* Do not allow multiple vacuuming child processes to be active at the
+        * same time.  If there is vacuuming child process active, delay
+        * new vacuuming event to stagger vacuuming events.
+        */
+       if (ctdb->vacuumers != NULL) {
+               event_add_timed(ctdb->ev, vacuum_handle,
+                               timeval_current_ofs(0, 500*1000),
+                               ctdb_vacuum_event, vacuum_handle);
+               return;
+       }
+
        child_ctx = talloc(vacuum_handle, struct ctdb_vacuum_child_context);
        if (child_ctx == NULL) {
                DEBUG(DEBUG_CRIT, (__location__ " Failed to allocate child context for vacuuming of %s\n", ctdb_db->db_name));