diff options
author | antirez <antirez@gmail.com> | 2015-11-27 16:05:52 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-11-27 16:11:05 +0100 |
commit | da82723858215e1b42c9b5b744e082418644d7d8 (patch) | |
tree | f5b0aab88576743142a9a78842d1218d787f2808 | |
parent | a0d41e51c24bd2299d3e46a2164fc5408de220dc (diff) | |
download | redis-da82723858215e1b42c9b5b744e082418644d7d8.tar.gz |
Handle wait3() errors.
My guess was that wait3() with WNOHANG could never return -1 and an
error. However issue #2897 may possibly indicate that this could happen
under non clear conditions. While we try to understand this better,
better to handle a return value of -1 explicitly, otherwise in the
case a BGREWRITE is in progress but wait3() returns -1, the effect is to
match the first branch of the if/else block since server.rdb_child_pid
is -1, and call backgroundSaveDoneHandler() without a good reason, that
will, in turn, crash the Redis server with an assertion.
-rw-r--r-- | src/server.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/server.c b/src/server.c index a9e994362..17bfcbbef 100644 --- a/src/server.c +++ b/src/server.c @@ -1198,7 +1198,13 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { if (WIFSIGNALED(statloc)) bysignal = WTERMSIG(statloc); - if (pid == server.rdb_child_pid) { + if (pid == -1) { + serverLog(LL_WARNING,"wait3() returned an error: %s. " + "rdb_child_pid = %d, aof_child_pid = %d", + strerror(errno), + (int) server.rdb_child_pid, + (int) server.aof_child_pid); + } else if (pid == server.rdb_child_pid) { backgroundSaveDoneHandler(exitcode,bysignal); } else if (pid == server.aof_child_pid) { backgroundRewriteDoneHandler(exitcode,bysignal); |