Merge pull request #5919 from gyuho/raft-lead

raft: set leader id in stepFollower
This commit is contained in:
Gyu-Ho Lee 2016-07-11 18:34:07 -07:00 committed by GitHub
commit 8a21be721f
2 changed files with 5 additions and 0 deletions

View File

@ -827,6 +827,7 @@ func stepFollower(r *raft, m pb.Message) {
r.handleHeartbeat(m)
case pb.MsgSnap:
r.electionElapsed = 0
r.lead = m.From
r.handleSnapshot(m)
case pb.MsgVote:
if (r.Vote == None || r.Vote == m.From) && r.raftLog.isUpToDate(m.Index, m.LogTerm) {

View File

@ -1901,6 +1901,10 @@ func TestRestoreFromSnapMsg(t *testing.T) {
sm := newTestRaft(2, []uint64{1, 2}, 10, 1, NewMemoryStorage())
sm.Step(m)
if sm.lead != uint64(1) {
t.Errorf("sm.lead = %d, want 1", sm.lead)
}
// TODO(bdarnell): what should this test?
}