Explorar o código

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 %!s(int64=11) %!d(string=hai) anos
pai
achega
690edb2c56
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  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)