From 35820549825791a8f188c2870a9069d36edd019d Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 29 Jan 2014 17:19:55 +0100 Subject: [PATCH] Cluster: broadcast pong to other slaves in the same ring. When we schedule a failover, broadcast a PONG to the slaves. The other slaves that plan to get elected will do the same too, this way it is likely that every slave will have a good picture of its own rank. Note that this is N*N messages where N is the number of slaves for the failing master, however usually even large clusters have many master nodes but a limited number of replicas per node, so this is harmless. --- src/cluster.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cluster.c b/src/cluster.c index c937d0d41..2d56643b2 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -2016,6 +2016,10 @@ void clusterHandleSlaveFailover(void) { server.cluster->failover_auth_time - mstime(), server.cluster->failover_auth_rank, replicationGetSlaveOffset()); + /* Now that we have a scheduled election, broadcast our offset + * to all the other slaves so that they'll updated their offsets + * if our offset is better. */ + clusterBroadcastPong(CLUSTER_BROADCAST_LOCAL_SLAVES); return; }