Move child termination to readSyncBulkPayload

This commit is contained in:
Andrey Bugaevskiy 2018-09-27 19:38:58 +03:00 committed by antirez
parent 21971ac83c
commit b31c08db8d

View File

@ -1244,6 +1244,12 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
if (eof_reached) {
int aof_is_enabled = server.aof_state != AOF_OFF;
/* Ensure background save doesn't overwrite synced data */
if (server.rdb_child_pid != -1) {
kill(server.rdb_child_pid,SIGUSR1);
rdbRemoveTempFile(server.rdb_child_pid);
}
if (rename(server.repl_transfer_tmpfile,server.rdb_filename) == -1) {
serverLog(LL_WARNING,"Failed trying to rename the temp DB into dump.rdb in MASTER <-> SLAVE synchronization: %s", strerror(errno));
cancelReplicationHandshake();
@ -1806,13 +1812,6 @@ 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,