From c9d93a2664843d9f42666cb2abfd00317fa2dabb Mon Sep 17 00:00:00 2001 From: reubenninan Date: Mon, 15 Jul 2024 19:00:57 +0000 Subject: [PATCH] AE req logging --- server/raft.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/raft.go b/server/raft.go index d5bcc0c5eee..efaa708d080 100644 --- a/server/raft.go +++ b/server/raft.go @@ -3173,6 +3173,7 @@ func (n *raft) updateLeader(newLeader string) { // to be committed. func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) { n.Lock() + // Don't reset here if we have been asked to assume leader position. if !n.lxfer { n.resetElectionTimeout() @@ -3184,13 +3185,17 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) { return } + // ignore if ae.term < n.term { - // ignore - n.debug("ignoring ae req from a leader with term %d which is less than ours", ae.term) + n.debug("ignoring ae req from a leader (%s) with term %d which is less than ours", ae.leader, ae.term) n.Unlock() return } + // log what append entry we got + n.debug("AE from %s (term:%d, commit: %d, pterm: %d, pindex: %d) with %d entries", ae.leader, ae.term, ae.commit, ae.pterm, ae.pindex, len(ae.entries)) + + // Scratch buffer for responses. var scratch [appendEntryResponseLen]byte arbuf := scratch[:]