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.
This commit is contained in:
parent
0ba8fe1a43
commit
878c089ec9
13
src/aof.c
13
src/aof.c
@ -727,9 +727,16 @@ uxeof: /* Unexpected AOF end of file. */
|
||||
strerror(errno));
|
||||
}
|
||||
} else {
|
||||
redisLog(REDIS_WARNING,
|
||||
"AOF loaded anyway because aof-load-truncated is enabled");
|
||||
goto loaded_ok;
|
||||
/* Make sure the AOF file descriptor points to the end of the
|
||||
* file after the truncate call. */
|
||||
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.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user