summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2014-06-21 11:14:05 -0400
committerantirez <antirez@gmail.com>2014-06-23 11:44:34 +0200
commitef897a41e80eb03a18d131d6a3c4d1d868f38ea0 (patch)
tree56138127534d3d159ea313c25c98ee0ab38825aa
parent1206bdf13f3afbc242a52ee1ce190ef48432fa90 (diff)
downloadredis-ef897a41e80eb03a18d131d6a3c4d1d868f38ea0.tar.gz
Cancel SHUTDOWN if initial AOF is being written
Fixes #1826 (and many other reports of the same problem)
-rw-r--r--src/redis.c6
1 files changed, 6 insertions, 0 deletions
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);