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)
This commit is contained in:
Wang Yuan 2020-11-22 20:12:45 +08:00 committed by GitHub
parent e6fa47380a
commit f207e1682f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -826,18 +826,16 @@ void syncCommand(client *c) {
/* CASE 3: There is no BGSAVE is progress. */ /* CASE 3: There is no BGSAVE is progress. */
} else { } 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 /* Diskless replication RDB child is created inside
* replicationCron() since we want to delay its start a * replicationCron() since we want to delay its start a
* few seconds to wait for more slaves to arrive. */ * few seconds to wait for more slaves to arrive. */
if (server.repl_diskless_sync_delay) serverLog(LL_NOTICE,"Delay next BGSAVE for diskless SYNC");
serverLog(LL_NOTICE,"Delay next BGSAVE for diskless SYNC");
else
startBgsaveForReplication(c->slave_capa);
} else { } else {
/* Target is disk (or the slave is not capable of supporting /* We don't have a BGSAVE in progress, let's start one. Diskless
* diskless replication) and we don't have a BGSAVE in progress, * or disk-based mode is determined by replica's capacity. */
* let's start one. */
if (!hasActiveChildProcess()) { if (!hasActiveChildProcess()) {
startBgsaveForReplication(c->slave_capa); startBgsaveForReplication(c->slave_capa);
} else { } else {