Node#add_server: idempotent for returning members#30
Merged
Conversation
- Known id + new non-empty address: replaces the peer in the list with the same id/role but new address, appends a configuration entry so the change replicates, returns true. - Known id + same or empty address: no-op, returns true (no log entry). - Known id == own id: returns false (self-guard, mirrors remove_server). - New id: unchanged (adds as Learner, returns true). Fixes the LavinMQ rejoin crash-loop where a wiped node whose id is still in the leader's configuration received add_server→false→HTTP 400 and exhausted its retry budget. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`add_server` previously returned `false` for any already-known node id. That made it impossible to re-admit a returning member, and turned a benign rejoin into a hard error at the consumer's HTTP layer.
New behavior:
node_id == @id→ returns false (self-guard, mirrors `remove_server`).Address updates preserve the peer's existing role — a returning voter stays a voter rather than being silently demoted to learner.
Why
Fixes the LavinMQ rejoin crash-loop: a wiped node whose id is still in the leader's configuration received `add_server` → `false` → HTTP 400 → exhausted its retry budget and never rejoined. The common rejoin case (same id, same address) is now a true no-op; an address change replicates correctly.
Notes
{ |p| p.foo }→(&.foo)) in `cancel_pending_reads`, `persist_state`, `serialize_peers` — behavior-identical.Test plan
🤖 Generated with Claude Code