{"record":{"id":"7fb507df6e9759f0","repo":"nats-io/nats-server","slug":"evicted-peers-v-cluster-size-is-now-d","errorCode":null,"errorMessage":"Evicted peers %+v, cluster size is now %d","messagePattern":"Evicted peers %\\+v, cluster size is now (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":1222,"sourceCode":"\t\t(slices.Contains(peers, n.membChange.peer) || n.pendingSelfRemoval()) {\n\t\tn.revertMembershipChange()\n\t}\n\tvar evicted []string\n\tfor _, peer := range peers {\n\t\t// Never evict ourselves, and never empty out the group.\n\t\tif peer == n.id || len(n.peers) <= 1 {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := n.peers[peer]; !ok {\n\t\t\tcontinue\n\t\t}\n\t\t// Marks the peer as removed so it can not rejoin or be re-added\n\t\t// automatically, adjusts cluster size and quorum, and persists.\n\t\tn.removePeer(peer)\n\t\tevicted = append(evicted, peer)\n\t}\n\tif len(evicted) > 0 {\n\t\tn.warn(\"Evicted peers %+v, cluster size is now %d\", evicted, n.csz)\n\t}\n\treturn evicted, nil\n}\n\nfunc (n *raft) MembershipChangeInProgress() bool {\n\tn.RLock()\n\tdefer n.RUnlock()\n\treturn n.membChange != nil\n}\n\n// pendingSelfRemoval reports whether we have an uncommitted removal of ourselves.\n// We're speculatively dropped from our own peer set at append time, but the meta\n// layer can still consider us a member until the removal commits.\n// Lock should be held.\nfunc (n *raft) pendingSelfRemoval() bool {\n\t// A removal tracks the previous membership state, an addition does not.\n\treturn n.membChange != nil && n.membChange.peer == n.id && n.membChange.prev != nil\n}","sourceCodeStart":1204,"sourceCodeEnd":1240,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L1204-L1240","documentation":"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.","triggerScenarios":"Thrown at server/raft.go:1222 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the eviction was expected (e.g. planned peer removal)","Re-add an evicted peer explicitly if it was unintentional","Check cluster size remains adequate for quorum after evictions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}