From: Salvatore Sanfilippo Date: Fri, 27 Jul 2012 10:56:48 +0000 (-0700) Subject: Merge pull request #587 from saj/truncate-short-write-from-aof X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/ed7b308c1c369d7a004b6f7a72e01ad1eddb5ac3?ds=inline;hp=-c Merge pull request #587 from saj/truncate-short-write-from-aof Truncate short write from the AOF --- ed7b308c1c369d7a004b6f7a72e01ad1eddb5ac3 diff --combined src/aof.c index 1df60b94,7c9bbdcb..441ccaf1 --- a/src/aof.c +++ b/src/aof.c @@@ -250,6 -250,13 +250,13 @@@ void flushAppendOnlyFile(int force) strerror(errno), (long)nwritten, (long)sdslen(server.aof_buf)); + + if (ftruncate(server.aof_fd, server.aof_current_size) == -1) { + redisLog(REDIS_WARNING, "Could not remove short write " + "from the append-only file. Redis may refuse " + "to load the AOF the next time it starts. " + "ftruncate: %s", strerror(errno)); + } } exit(1); } @@@ -1093,8 -1100,6 +1100,8 @@@ void backgroundRewriteDoneHandler(int e server.aof_buf = sdsempty(); } + server.aof_lastbgrewrite_status = REDIS_OK; + redisLog(REDIS_NOTICE, "Background AOF rewrite finished successfully"); /* Change state from WAIT_REWRITE to ON if needed */ if (server.aof_state == REDIS_AOF_WAIT_REWRITE) @@@ -1106,13 -1111,9 +1113,13 @@@ redisLog(REDIS_VERBOSE, "Background AOF rewrite signal handler took %lldus", ustime()-now); } else if (!bysignal && exitcode != 0) { + server.aof_lastbgrewrite_status = REDIS_ERR; + redisLog(REDIS_WARNING, "Background AOF rewrite terminated with error"); } else { + server.aof_lastbgrewrite_status = REDIS_ERR; + redisLog(REDIS_WARNING, "Background AOF rewrite terminated by signal %d", bysignal); }