From 25a3d9965e0a130705d974ae6a8a6a51e7fabe95 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 17 Oct 2014 10:23:11 +0200 Subject: [PATCH] Diskless replication: remove 40 bytes EOF mark from end of RDB file. --- src/replication.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/replication.c b/src/replication.c index 050abfd03..7dd4a4436 100644 --- a/src/replication.c +++ b/src/replication.c @@ -918,6 +918,16 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) { } server.repl_transfer_read += nread; + /* Delete the last 40 bytes from the file if we reached EOF. */ + if (usemark && eof_reached) { + if (ftruncate(server.repl_transfer_fd, + server.repl_transfer_read - REDIS_RUN_ID_SIZE) == -1) + { + redisLog(REDIS_WARNING,"Error truncating the RDB file received from the master for SYNC: %s", strerror(errno)); + goto error; + } + } + /* Sync data on disk from time to time, otherwise at the end of the transfer * we may suffer a big delay as the memory buffers are copied into the * actual disk. */ -- GitLab