From dc9cb4b4bac138963783ff53874b5880c0268af0 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Sat, 4 Oct 2014 09:45:15 +0800 Subject: [PATCH] raft: fix send send should not attach current term to msgProp. Send should simply do proxy for msgProp without changing its term. msgProp has a special term 0, which indicates that it is a local message. --- raft/raft.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/raft/raft.go b/raft/raft.go index 323e596a9..47a07031e 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -184,7 +184,12 @@ func (r *raft) poll(id int64, v bool) (granted int) { // send persists state to stable storage and then sends to its mailbox. func (r *raft) send(m pb.Message) { m.From = r.id - m.Term = r.Term + // do not attach term to msgProp + // proposals are a way to forward to the leader and + // should be treated as local message. + if m.Type != msgProp { + m.Term = r.Term + } r.msgs = append(r.msgs, m) }