Commit 4c0c1fff authored by Saj Goonatilleke's avatar Saj Goonatilleke Committed by antirez
Browse files

Truncate short write from the AOF

If Redis only manages to write out a partial buffer, the AOF file won't
load back into Redis the next time it starts up.  It is better to
discard the short write than waste time running redis-check-aof.
parent f00b0844
...@@ -250,6 +250,13 @@ void flushAppendOnlyFile(int force) { ...@@ -250,6 +250,13 @@ void flushAppendOnlyFile(int force) {
strerror(errno), strerror(errno),
(long)nwritten, (long)nwritten,
(long)sdslen(server.aof_buf)); (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); exit(1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment