Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: send unexpected MsgAppResp to leader #395

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ type raft struct {
Term uint64
Vote uint64

receiving bool

readStates []ReadState

// the log
Expand Down Expand Up @@ -613,6 +615,7 @@ func (r *raft) reset(term uint64) {
r.Vote = None
}
r.lead = None
r.receiving = false

r.electionElapsed = 0
r.heartbeatElapsed = 0
Expand Down Expand Up @@ -1554,7 +1557,9 @@ func stepFollower(r *raft, m pb.Message) error {
case pb.MsgLogResp:
if r.raftLog.stableTo(m.Index, m.LogTerm) {
r.raftLog.localCommitTo(r.raftLog.committed)
r.send(pb.Message{To: r.lead, Type: pb.MsgAppResp, Index: m.Index})
if r.receiving {
r.send(pb.Message{To: r.lead, Type: pb.MsgAppResp, Index: m.Index, LogTerm: m.LogTerm})
}
}
case pb.MsgApplyResp:
// TODO(james.yin):
Expand Down Expand Up @@ -1630,6 +1635,8 @@ func (r *raft) handleAppendEntries(m pb.Message) {
RejectHint: hintIndex,
LogTerm: hintTerm,
})
} else if !r.receiving {
r.receiving = true
}
}

Expand Down