Pārlūkot izejas kodu

raft: update lead for follower sm when receiving msgApp

Or follower may take `none` as its leader forever if it just launched
a failed election whose term is the same as the current leader.
Yicheng Qin 11 gadi atpakaļ
vecāks
revīzija
690edb2c56
1 mainītis faili ar 1 papildinājumiem un 0 dzēšanām
  1. 1 0
      raft/raft.go

+ 1 - 0
raft/raft.go

@@ -411,6 +411,7 @@ func stepFollower(sm *stateMachine, m Message) bool {
 		m.To = sm.lead.Get()
 		sm.send(m)
 	case msgApp:
+		sm.lead.Set(m.From)
 		sm.handleAppendEntries(m)
 	case msgSnap:
 		sm.handleSnapshot(m)