diff --git a/ctdb/common/ctdb_fork.c b/ctdb/common/ctdb_fork.c index a11f75a6de5..9e3a06d889c 100644 --- a/ctdb/common/ctdb_fork.c +++ b/ctdb/common/ctdb_fork.c @@ -27,7 +27,7 @@ * This function forks a child process and drops the realtime * scheduler for the child process. */ -pid_t ctdb_fork(struct ctdb_context *ctdb) +pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb) { pid_t pid; char *process; @@ -60,8 +60,6 @@ pid_t ctdb_fork(struct ctdb_context *ctdb) } ctdb->can_send_controls = false; - ctdb_log_ringbuffer_free(); - return 0; } @@ -75,6 +73,17 @@ pid_t ctdb_fork(struct ctdb_context *ctdb) return pid; } +pid_t ctdb_fork(struct ctdb_context *ctdb) +{ + pid_t pid; + + pid = ctdb_fork_no_free_ringbuffer(ctdb); + if (pid == 0) { + ctdb_log_ringbuffer_free(); + } + + return pid; +} static void ctdb_sigchld_handler(struct tevent_context *ev, diff --git a/ctdb/common/ctdb_logging.c b/ctdb/common/ctdb_logging.c index 105b4df5996..de5ca6e68f6 100644 --- a/ctdb/common/ctdb_logging.c +++ b/ctdb/common/ctdb_logging.c @@ -163,7 +163,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr) /* spawn a child process to marshall the huge log blob and send it back to the ctdb tool using a MESSAGE */ - child = ctdb_fork(ctdb); + child = ctdb_fork_no_free_ringbuffer(ctdb); if (child == (pid_t)-1) { DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n")); return -1; diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index cf850aa6915..7794c4c1c8a 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -1072,6 +1072,7 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb); struct tevent_signal *ctdb_init_sigchld(struct ctdb_context *ctdb); pid_t ctdb_fork(struct ctdb_context *ctdb); +pid_t ctdb_fork_no_free_ringbuffer(struct ctdb_context *ctdb); int ctdb_kill(struct ctdb_context *ctdb, pid_t pid, int signum); int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb, diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index bffe2bed4a1..95172a1fd77 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -2126,7 +2126,7 @@ static void getlog_handler(struct ctdb_context *ctdb, uint64_t srvid, } log_addr = (struct ctdb_get_log_addr *)data.dptr; - child = ctdb_fork(ctdb); + child = ctdb_fork_no_free_ringbuffer(ctdb); if (child == (pid_t)-1) { DEBUG(DEBUG_ERR,("Failed to fork a log collector child\n")); return; @@ -4014,7 +4014,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) ctdb->ctdbd_pid = getpid(); - ctdb->recoverd_pid = ctdb_fork(ctdb); + ctdb->recoverd_pid = ctdb_fork_no_free_ringbuffer(ctdb); if (ctdb->recoverd_pid == -1) { return -1; } @@ -4035,6 +4035,9 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) srandom(getpid() ^ time(NULL)); + /* Clear the log ringbuffer */ + ctdb_clear_log(ctdb); + if (switch_from_server_to_client(ctdb, "recoverd") != 0) { DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n")); exit(1);