Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Truncate short write from the AOF #587

Merged
merged 1 commit into from

2 participants

@saj

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.

@saj saj 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.
55302e9
@antirez
Owner

Brillant solution, merging. Thank you.

@antirez antirez merged commit ed7b308 into antirez:unstable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2012
  1. @saj

    Truncate short write from the AOF

    saj authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/aof.c
View
7 src/aof.c
@@ -250,6 +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);
}
Something went wrong with that request. Please try again.