diff --git a/src/aof.c b/src/aof.c index a7f32abae..81f5f1fcd 100644 --- a/src/aof.c +++ b/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 . 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server.");