Skip to content
This repository

Truncate short write from the AOF #587

Merged
merged 1 commit into from over 1 year ago

2 participants

Saj Goonatilleke Salvatore Sanfilippo
Saj Goonatilleke
saj commented July 17, 2012

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 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 July 27, 2012
Salvatore Sanfilippo antirez closed this July 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 18, 2012
Saj Goonatilleke 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  src/aof.c
7  src/aof.c
@@ -250,6 +250,13 @@ void flushAppendOnlyFile(int force) {
250 250
                                    strerror(errno),
251 251
                                    (long)nwritten,
252 252
                                    (long)sdslen(server.aof_buf));
  253
+
  254
+            if (ftruncate(server.aof_fd, server.aof_current_size) == -1) {
  255
+                redisLog(REDIS_WARNING, "Could not remove short write "
  256
+                         "from the append-only file.  Redis may refuse "
  257
+                         "to load the AOF the next time it starts.  "
  258
+                         "ftruncate: %s", strerror(errno));
  259
+            }
253 260
         }
254 261
         exit(1);
255 262
     }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.