Commit 878c089e authored by antirez's avatar antirez
Browse files

Seek at the end of AOF after truncate call.

It is not clear if files open in append only mode will automatically fix
their offset after a truncate(2) operation. This commit makes sure that
we reposition the AOF file descriptor offset at the end of the file
after a truncated AOF is loaded and trimmed to the last valid command.
parent 0ba8fe1a
...@@ -727,9 +727,16 @@ uxeof: /* Unexpected AOF end of file. */ ...@@ -727,9 +727,16 @@ uxeof: /* Unexpected AOF end of file. */
strerror(errno)); strerror(errno));
} }
} else { } else {
redisLog(REDIS_WARNING, /* Make sure the AOF file descriptor points to the end of the
"AOF loaded anyway because aof-load-truncated is enabled"); * file after the truncate call. */
goto loaded_ok; if (server.aof_fd != -1 && lseek(server.aof_fd,0,SEEK_END) == -1) {
redisLog(REDIS_WARNING,"Can't seek the end of the AOF file: %s",
strerror(errno));
} else {
redisLog(REDIS_WARNING,
"AOF loaded anyway because aof-load-truncated is enabled");
goto loaded_ok;
}
} }
} }
redisLog(REDIS_WARNING,"Unexpected end of file reading the append only file. You can: 1) Make a backup of your AOF file, then use ./redis-check-aof --fix <filename>. 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server."); redisLog(REDIS_WARNING,"Unexpected end of file reading the append only file. You can: 1) Make a backup of your AOF file, then use ./redis-check-aof --fix <filename>. 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server.");
......
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