ctdb-daemon: Log a message when vfork() takes long time
authorAmitay Isaacs <amitay@gmail.com>
Thu, 15 Sep 2016 06:10:49 +0000 (16:10 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 19 Sep 2016 10:18:15 +0000 (12:18 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Sep 19 12:18:15 CEST 2016 on sn-devel-144

ctdb/server/ctdb_logging.c

index 692df73b1b74ffbdfdfeee939f8fbc8ab91f29fc..fbafe9be3405d752f2f17a3c727b22c8dc3f52eb 100644 (file)
@@ -29,6 +29,7 @@
 #include "lib/util/dlinklist.h"
 #include "lib/util/debug.h"
 #include "lib/util/blocking.h"
+#include "lib/util/time.h"
 
 #include "ctdb_private.h"
 #include "ctdb_client.h"
@@ -200,6 +201,8 @@ struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
        struct tevent_fd *fde;
        char **argv;
        int i;
+       struct timeval before;
+       double delta_t;
 
        log = talloc_zero(mem_ctx, struct ctdb_log_state);
        CTDB_NO_MEMORY_NULL(ctdb, log);
@@ -230,6 +233,8 @@ struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
                argv[i+2] = discard_const(helper_argv[i]);
        }
 
+       before = timeval_current();
+
        *pid = vfork();
        if (*pid == 0) {
                execv(helper, argv);
@@ -243,6 +248,11 @@ struct ctdb_log_state *ctdb_vfork_with_logging(TALLOC_CTX *mem_ctx,
                goto free_log;
        }
 
+       delta_t = timeval_elapsed(&before);
+       if (delta_t > 3.0) {
+               DEBUG(DEBUG_WARNING, ("vfork() took %lf seconds\n", delta_t));
+       }
+
        ctdb_track_child(ctdb, *pid);
 
        log->pfd = p[0];