ZOOKEEPER-2466: Fix C client skipping servers when reconnecting - #2440
Open
kosa-as wants to merge 1 commit into
Open
ZOOKEEPER-2466: Fix C client skipping servers when reconnecting#2440kosa-as wants to merge 1 commit into
kosa-as wants to merge 1 commit into
Conversation
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.
Problem
The C client can advance the server address cursor twice for a single
failed connection attempt.
After connection failures,
handle_error()advanced the address cursor,while the next reconnect attempt also selected the next server through
zoo_cycle_next_server(). Once the client falls back from reconfig serverselection to the normal round-robin list, this can skip servers and may
cause the client to keep retrying only part of the server list.
Fix
Keep normal reconnect server cycling in
zoo_cycle_next_server()andremove address cursor advancement from
handle_error().Move the reconnect delay calculation next to the server cycling logic so
the delay is still set when the normal server list wraps.
Also guard read-only mode's read/write server probing cursor advancement
with the existing reconfig lock, so it does not advance the normal address
list while reconfig server selection is active.
Testing
Added a regression test for ZOOKEEPER-2466 by exhausting the configured
server list while all servers are unavailable, then starting one server
and verifying the same client eventually reconnects to it.
Verified locally with a behavior harness: