From e498d9ee3ee55c29000ed80914473ac18d32b672 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 19 May 2017 11:10:36 +0200 Subject: [PATCH] Collect fork() timing info only if fork succeeded. --- src/rdb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rdb.c b/src/rdb.c index 1a5a7b2c5..570ffa843 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1870,9 +1870,6 @@ int rdbSaveToSlavesSockets(rdbSaveInfo *rsi) { exitFromChild((retval == C_OK) ? 0 : 1); } else { /* Parent */ - server.stat_fork_time = ustime()-start; - server.stat_fork_rate = (double) zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024); /* GB per second. */ - latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000); if (childpid == -1) { serverLog(LL_WARNING,"Can't save in background: fork: %s", strerror(errno)); @@ -1896,6 +1893,10 @@ int rdbSaveToSlavesSockets(rdbSaveInfo *rsi) { close(pipefds[1]); closeChildInfoPipe(); } else { + server.stat_fork_time = ustime()-start; + server.stat_fork_rate = (double) zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024); /* GB per second. */ + latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000); + serverLog(LL_NOTICE,"Background RDB transfer started by pid %d", childpid); server.rdb_save_time_start = time(NULL);