Skip to content

Commit

Permalink
startup stacktrace and pterm logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenMathew committed Jul 16, 2024
1 parent 5ca2b55 commit f5478fa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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...)
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f5478fa

Please sign in to comment.