From 21971ac83cbab9bb8e28324f3b0182c3aa759642 Mon Sep 17 00:00:00 2001 From: Andrey Bugaevskiy Date: Wed, 19 Sep 2018 19:58:39 +0300 Subject: [PATCH] Prevent RDB autosave from overwriting full resync results During the full database resync we may still have unsaved changes on the receiving side. This causes a race condition between synced data rename/load and the rename of rdbSave tempfile. --- src/replication.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/replication.c b/src/replication.c index 3b4059c33..d8478fbbc 100644 --- a/src/replication.c +++ b/src/replication.c @@ -1806,6 +1806,13 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) { } } + /* Stop background saving for obsolete database state. */ + server.dirty = 0; + if (server.rdb_child_pid != -1) { + kill(server.rdb_child_pid,SIGUSR1); + rdbRemoveTempFile(server.rdb_child_pid); + } + /* Prepare a suitable temp file for bulk transfer */ while(maxtries--) { snprintf(tmpfile,256, -- GitLab