From f5478fa83231e400d78f353d12ac4f10d2b2ad63 Mon Sep 17 00:00:00 2001 From: reubenninan Date: Tue, 16 Jul 2024 15:15:39 +0000 Subject: [PATCH] startup stacktrace and pterm logging --- server/raft.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/raft.go b/server/raft.go index 429e7341095..6a1a4ec42e2 100644 --- a/server/raft.go +++ b/server/raft.go @@ -502,6 +502,7 @@ func (s *Server) startRaftNode(accName string, cfg *RaftConfig, labels pprofLabe return nil, err } + debug.PrintStack() n.debug("Started") // Check if we need to start in observer mode due to lame duck status. @@ -1887,18 +1888,18 @@ func (n *raft) run() { func (n *raft) debug(format string, args ...any) { if n.dflag { - nf := fmt.Sprintf("RAFT [%s - %s - %d/%d/%d/%d] %s", n.id, n.group, n.term, n.pindex, n.commit, n.applied, format) + nf := fmt.Sprintf("RAFT [%s - %s - term:%d p:%d/%d sm:%d/%d] %s", n.id, n.group, n.term, n.pterm, n.pindex, n.commit, n.applied, format) n.s.Debugf(nf, args...) } } func (n *raft) warn(format string, args ...any) { - nf := fmt.Sprintf("RAFT [%s - %s- %d/%d/%d/%d] %s", n.id, n.group, n.term, n.pindex, n.commit, n.applied, format) + nf := fmt.Sprintf("RAFT [%s - %s - term:%d p:%d/%d sm:%d/%d] %s", n.id, n.group, n.term, n.pterm, n.pindex, n.commit, n.applied, format) n.s.RateLimitWarnf(nf, args...) } func (n *raft) error(format string, args ...any) { - nf := fmt.Sprintf("RAFT [%s - %s- %d/%d/%d/%d] %s", n.id, n.group, n.term, n.pindex, n.commit, n.applied, format) + nf := fmt.Sprintf("RAFT [%s - %s - term:%d p:%d/%d sm:%d/%d] %s", n.id, n.group, n.term, n.pterm, n.pindex, n.commit, n.applied, format) n.s.Errorf(nf, args...) } @@ -3295,7 +3296,7 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) { n.debug("Term higher than ours and we are not a follower: %v, stepping down to %q", n.State(), ae.leader) n.stepdownLocked(ae.leader) } - } else if ae.term < n.term && !catchingUp{ + } else if ae.term < n.term && !catchingUp { n.debug("ignoring ae req from a leader (%s) with term %d which is less than ours", ae.leader, ae.term) n.Unlock() return