old leader rejoin the cluster question

141 views
Skip to first unread message

Zhihao Yao

unread,
May 6, 2016, 2:39:18 AM5/6/16
to raft-dev
Hello,

I have a question about what old leader should do after it rejoin the raft cluster. When network partition happens, leader node1_term1 is partitioned out and cannot accept new requests, a new leader node2_term2 is elected in term 2. After network is recovered and node1_term1 detect node2_term2 is the leader with higher term, then node1_term1 will change to the follower role and increase its term to 2. My problem is after node1_term1 change to follower, it will start a new leader election for term 3, is it the correct way? Because append entries response don't have a hint for current leader. Is this rejoin leader election can be optimized by adding leader_id in AE response?

Thank You
Zhihao Yao 

Oren Eini (Ayende Rahien)

unread,
May 6, 2016, 1:44:37 PM5/6/16
to raft...@googlegroups.com
Why would it start a new term?
It would just convert to a follower.

Note that in most impl, if the leader can't reach a majority of the nodes, it will also step down.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "raft-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raft-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jordan.h...@gmail.com

unread,
May 6, 2016, 2:42:14 PM5/6/16
to raft...@googlegroups.com
It's difficult for me to discern exactly what you're asking, but let's just describe everything that happens when a leader rejoins after a partition.

In your scenario, when the partition heals and node 1 - the leader for term 1 - rejoins the other leader for term 2, the leader for term 1 can step down either as a result of an AppendEntries request from the other leader or response to an AppendEntries RPC from the other leader or a node that knows about the new term. Once node 1 steps down and increments its term to 2, nothing else needs to happen. The old leader - node 1 - will be receiving heartbeats from the new leader and so will never start an election, so I'm not sure why there's discussion of a new election. Only in the event that node 1 stops receiving heartbeats from node 2 (the new leader) will it timeout and start a new election. In that case, node 1 will indeed increment its term again to 3 for the new election. The fact that a node was previously a leader has no bearing on any future elections. The term is all that matters.

In practice, node 1 can actually step down before the partition heals. If a leader is partitioned from a majority of the cluster, it should detect that (if a leader can't contact a majority of the cluster for more than an election timeout you can assume a new leader will be elected) and step down so clients disconnect and try to find a new leader.
--

赵海源

unread,
Nov 16, 2017, 11:39:45 AM11/16/17
to raft-dev
Hi, kuujo,
When an old leader rejoined, his AppendEntriesRpcs received larger term and he steps down immediately. Should(or Must) the old leader reset his election timer  simultaneously? 
otherwise, he will convert to candidate and start to elect because his election timeout elapsed long long ago. 

Ishani Gupta

unread,
Nov 18, 2017, 7:00:59 PM11/18/17
to raft-dev
Actually, as soon as the old leader turns to a follower, the idea of election timeout will occur( which can be said as resetting the election timer).So yes, it resets its election timer immediately it steps down because of entry of higher numbered leader(as partitioning stops).
Reply all
Reply to author
Forward
0 new messages