diff --git a/src/replication.cpp b/src/replication.cpp index 9ef578204..4f66bab99 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -31,6 +31,7 @@ #include "server.h" +#include "cluster.h" #include #include @@ -2971,12 +2972,23 @@ void replicationCron(void) { /* First, send PING according to ping_slave_period. */ if ((replication_cron_loops % g_pserver->repl_ping_slave_period) == 0 && - listLength(g_pserver->slaves) && !clientsArePaused()) + listLength(g_pserver->slaves)) { - ping_argv[0] = createStringObject("PING",4); - replicationFeedSlaves(g_pserver->slaves, g_pserver->slaveseldb, - ping_argv, 1); - decrRefCount(ping_argv[0]); + /* Note that we don't send the PING if the clients are paused during + * a Redis Cluster manual failover: the PING we send will otherwise + * alter the replication offsets of master and slave, and will no longer + * match the one stored into 'mf_master_offset' state. */ + int manual_failover_in_progress = + g_pserver->cluster_enabled && + g_pserver->cluster->mf_end && + clientsArePaused(); + + if (!manual_failover_in_progress) { + ping_argv[0] = createStringObject("PING",4); + replicationFeedSlaves(g_pserver->slaves, g_pserver->slaveseldb, + ping_argv, 1); + decrRefCount(ping_argv[0]); + } } /* Second, send a newline to all the slaves in pre-synchronization