From 72980c7005f0c7ee1ea97a25229af3a7bc6edd96 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Sat, 21 Jun 2014 11:14:05 -0400 Subject: Cancel SHUTDOWN if initial AOF is being written Fixes #1826 (and many other reports of the same problem) --- src/redis.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/redis.c b/src/redis.c index 8d4cecef7..f6d4abf1f 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2288,6 +2288,12 @@ int prepareForShutdown(int flags) { /* Kill the AOF saving child as the AOF we already have may be longer * but contains the full dataset anyway. */ if (server.aof_child_pid != -1) { + /* If we have AOF enabled but haven't written the AOF yet, don't + * shutdown or else the dataset will be lost. */ + if (server.aof_state == REDIS_AOF_WAIT_REWRITE) { + redisLog(REDIS_WARNING, "Writing initial AOF, can't exit."); + return REDIS_ERR; + } redisLog(REDIS_WARNING, "There is a child rewriting the AOF. Killing it!"); kill(server.aof_child_pid,SIGUSR1); -- cgit v1.2.1