From 80a57a3d514770da3476aa2b95cc4dbc32d63ee7 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Sun, 9 Apr 2023 08:01:36 -0700 Subject: [PATCH] Remove peers from string intern map Signed-off-by: Derek Collison --- server/raft.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/raft.go b/server/raft.go index f6cabce7..6241290e 100644 --- a/server/raft.go +++ b/server/raft.go @@ -2096,8 +2096,6 @@ func (n *raft) handleForwardedRemovePeerProposal(sub *subscription, c *client, _ n.warn("Received invalid peer name for remove proposal: %q", msg) return } - // Need to copy since this is underlying client/route buffer. - peer := string(copyBytes(msg)) n.RLock() prop, werr := n.prop, n.werr @@ -2108,7 +2106,9 @@ func (n *raft) handleForwardedRemovePeerProposal(sub *subscription, c *client, _ return } - prop.push(newEntry(EntryRemovePeer, []byte(peer))) + // Need to copy since this is underlying client/route buffer. + peer := copyBytes(msg) + prop.push(newEntry(EntryRemovePeer, peer)) } // Called when a peer has forwarded a proposal. @@ -2603,6 +2603,9 @@ func (n *raft) applyCommit(index uint64) error { n.stepdown.push(n.selectNextLeader()) } + // Remove from string intern map. + peers.Delete(peer) + // We pass these up as well. committed = append(committed, e) }