Would you tell me the statle leader how to start an election after becoming follower


尹秋霞
 

Hi ,DAOS:
        I'm looking at the raft's code. 
        func (r *Raft) run() {
for {
// Check if we are doing a shutdown
select {
case <-r.shutdownCh:
// Clear the leader to prevent forwarding
r.setLeader("")
return
default:
}

// Enter into a sub-FSM
switch r.getState() {
case Follower:
r.runFollower()
case Candidate:
r.runCandidate()
case Leader:
r.runLeader()
}
}
}
When leader became follower,  the function runLeader() must return, so  that the follower state machine can be run.
If the runLeader() need to return, the function leaderLoop must return.
But the leaderLoop function returns only when r.shutdownCh has a value.
So I wonder the statle leader how to start or join the election after  becoming the follower?


Join daos@daos.groups.io to automatically receive all group messages.