Skip to content

Commit 25a3d99

Browse files
committed
Diskless replication: remove 40 bytes EOF mark from end of RDB file.
1 parent 0c5a06f commit 25a3d99

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/replication.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,16 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
918918
}
919919
server.repl_transfer_read += nread;
920920

921+
/* Delete the last 40 bytes from the file if we reached EOF. */
922+
if (usemark && eof_reached) {
923+
if (ftruncate(server.repl_transfer_fd,
924+
server.repl_transfer_read - REDIS_RUN_ID_SIZE) == -1)
925+
{
926+
redisLog(REDIS_WARNING,"Error truncating the RDB file received from the master for SYNC: %s", strerror(errno));
927+
goto error;
928+
}
929+
}
930+
921931
/* Sync data on disk from time to time, otherwise at the end of the transfer
922932
* we may suffer a big delay as the memory buffers are copied into the
923933
* actual disk. */

0 commit comments

Comments
 (0)