From 690edb2c567ecc84d16d90af97baa057dcefac04 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 10 Jul 2014 14:06:35 -0700 Subject: [PATCH] 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. --- raft/raft.go | 1 + 1 file changed, 1 insertion(+) diff --git a/raft/raft.go b/raft/raft.go index 33507632d..3f536449e 100644 --- a/raft/raft.go +++ b/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)