Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Truncate short write from the AOF #587

Merged
merged 1 commit into from

2 participants

Saj Goonatilleke Salvatore Sanfilippo
Saj Goonatilleke

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 Goonatilleke 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
Salvatore Sanfilippo
Owner

Brillant solution, merging. Thank you.

Salvatore Sanfilippo antirez merged commit ed7b308 into from
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 Goonatilleke

    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
7 src/aof.c
View
@@ -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.