From b806a8e7e7f64d973269264854b4a662ce9e4a47 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Mon, 3 Apr 2023 13:40:45 -0700 Subject: [PATCH] Do not opt-out of normal processing for leadership transfers, but make sure they are only processed if explicitly new Signed-off-by: Derek Collison --- server/raft.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/server/raft.go b/server/raft.go index 9bdbe5c3..b098ebe7 100644 --- a/server/raft.go +++ b/server/raft.go @@ -2511,13 +2511,6 @@ func (n *raft) applyCommit(index uint64) error { // We pass these up as well. committed = append(committed, e) - - case EntryLeaderTransfer: - if n.state == Leader { - n.debug("Stepping down") - n.stepdown.push(noLeader) - } - // No-op } } // Pass to the upper layers if we have normal entries. @@ -3056,6 +3049,7 @@ func (n *raft) processAppendEntry(ae *appendEntry, sub *subscription) { for _, e := range ae.entries { switch e.Type { case EntryLeaderTransfer: + // Only process these if they are new, so no replays or catchups. if isNew { maybeLeader := string(e.Data) if maybeLeader == n.id && !n.observer && !n.paused { @@ -3156,7 +3150,7 @@ func (n *raft) buildAppendEntry(entries []*Entry) *appendEntry { // Determine if we should store an entry. func (ae *appendEntry) shouldStore() bool { - return ae != nil && len(ae.entries) > 0 && ae.entries[0].Type != EntryLeaderTransfer + return ae != nil && len(ae.entries) > 0 } // Store our append entry to our WAL.