diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2014-06-23 10:07:13 +0200 |
---|---|---|
committer | Salvatore Sanfilippo <antirez@gmail.com> | 2014-06-23 10:07:13 +0200 |
commit | af7647b20d42f0544944ca83492d5353617bb2b8 (patch) | |
tree | 56138127534d3d159ea313c25c98ee0ab38825aa | |
parent | 1206bdf13f3afbc242a52ee1ce190ef48432fa90 (diff) | |
parent | 72980c7005f0c7ee1ea97a25229af3a7bc6edd96 (diff) | |
download | redis-af7647b20d42f0544944ca83492d5353617bb2b8.tar.gz |
Merge pull request #1829 from mattsta/stop-aof-dataloss
Cancel SHUTDOWN if initial AOF is being written
-rw-r--r-- | src/redis.c | 6 |
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); |