nats-io/nats-server · error

Evicted peers %+v, cluster size is now

Error message

Evicted peers %+v, cluster size is now %d

What it means

Informational membership event: after a peer-state change, peers absent from the advertised peer list (and not self, and not emptying the group) were evicted via removePeer — marked so they cannot rejoin automatically, with cluster size and quorum adjusted. The new cluster size is logged.

Solutions

  1. Verify the eviction was expected (e.g. planned peer removal)
  2. Re-add an evicted peer explicitly if it was unintentional
  3. Check cluster size remains adequate for quorum after evictions
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/raft.go:1222 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/7fb507df6e9759f0. Report an issue: GitHub.

Appendix: source

Thrown at server/raft.go:1222

		(slices.Contains(peers, n.membChange.peer) || n.pendingSelfRemoval()) {
		n.revertMembershipChange()
	}
	var evicted []string
	for _, peer := range peers {
		// Never evict ourselves, and never empty out the group.
		if peer == n.id || len(n.peers) <= 1 {
			continue
		}
		if _, ok := n.peers[peer]; !ok {
			continue
		}
		// Marks the peer as removed so it can not rejoin or be re-added
		// automatically, adjusts cluster size and quorum, and persists.
		n.removePeer(peer)
		evicted = append(evicted, peer)
	}
	if len(evicted) > 0 {
		n.warn("Evicted peers %+v, cluster size is now %d", evicted, n.csz)
	}
	return evicted, nil
}

func (n *raft) MembershipChangeInProgress() bool {
	n.RLock()
	defer n.RUnlock()
	return n.membChange != nil
}

// pendingSelfRemoval reports whether we have an uncommitted removal of ourselves.
// We're speculatively dropped from our own peer set at append time, but the meta
// layer can still consider us a member until the removal commits.
// Lock should be held.
func (n *raft) pendingSelfRemoval() bool {
	// A removal tracks the previous membership state, an addition does not.
	return n.membChange != nil && n.membChange.peer == n.id && n.membChange.prev != nil
}

View on GitHub (pinned to 3a66a489d2)