Make sure to not process AR when no longer leader

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2021-02-16 15:58:46 -08:00
parent eecec2aed1
commit ddc4cc79d2

View File

@@ -2230,8 +2230,13 @@ func (n *raft) processPeerState(ps *peerState) {
writePeerState(n.sd, ps)
}
// handleAppendEntryResponse just places the decoded response on the appropriate channel.
// handleAppendEntryResponse processes responses to append entries.
func (n *raft) handleAppendEntryResponse(sub *subscription, c *client, subject, reply string, msg []byte) {
// Ignore if not the leader.
if !n.Leader() {
n.debug("Ignoring append entry response, no longer leader")
return
}
ar := n.decodeAppendEntryResponse(msg)
if reply != _EMPTY_ {
ar.reply = reply