From f207e1682fadfe343c55102a1324b9b5c830e074 Mon Sep 17 00:00:00 2001 From: Wang Yuan Date: Sun, 22 Nov 2020 20:12:45 +0800 Subject: [PATCH] Fix diskless replication failure when has non-rdb child process (#8070) If we enable diskless replication, set repl-diskless-sync-delay to 0, and master has non-rdb child process such as rewrite aof child, master will try to start to a new BGSAVE but fails immediately (before fork) when replicas ask for full synchronization, and master always fails to start a new BGSAVE and disconnects with replicas until non-rdb child process exists. this bug was introduced in #6271 (not yet released in 6.0.x) --- src/replication.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/replication.c b/src/replication.c index 745d317ca..a288478ff 100644 --- a/src/replication.c +++ b/src/replication.c @@ -826,18 +826,16 @@ void syncCommand(client *c) { /* CASE 3: There is no BGSAVE is progress. */ } else { - if (server.repl_diskless_sync && (c->slave_capa & SLAVE_CAPA_EOF)) { + if (server.repl_diskless_sync && (c->slave_capa & SLAVE_CAPA_EOF) && + server.repl_diskless_sync_delay) + { /* Diskless replication RDB child is created inside * replicationCron() since we want to delay its start a * few seconds to wait for more slaves to arrive. */ - if (server.repl_diskless_sync_delay) - serverLog(LL_NOTICE,"Delay next BGSAVE for diskless SYNC"); - else - startBgsaveForReplication(c->slave_capa); + serverLog(LL_NOTICE,"Delay next BGSAVE for diskless SYNC"); } else { - /* Target is disk (or the slave is not capable of supporting - * diskless replication) and we don't have a BGSAVE in progress, - * let's start one. */ + /* We don't have a BGSAVE in progress, let's start one. Diskless + * or disk-based mode is determined by replica's capacity. */ if (!hasActiveChildProcess()) { startBgsaveForReplication(c->slave_capa); } else {