summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-10-17 10:23:11 +0200
committerantirez <antirez@gmail.com>2014-10-17 10:23:11 +0200
commit25a3d9965e0a130705d974ae6a8a6a51e7fabe95 (patch)
tree54faf797a4729ee460b9f8527a6e2c47c174e3f7
parent0c5a06f6bb8aaa6d15ea1a363ed19b637934579a (diff)
downloadredis-25a3d9965e0a130705d974ae6a8a6a51e7fabe95.tar.gz
Diskless replication: remove 40 bytes EOF mark from end of RDB file.
-rw-r--r--src/replication.c10
1 files changed, 10 insertions, 0 deletions
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. */