Skip to content

ZOOKEEPER-2466: Fix C client skipping servers when reconnecting - #2440

Open
kosa-as wants to merge 1 commit into
apache:masterfrom
kosa-as:ZOOKEEPER-2466
Open

ZOOKEEPER-2466: Fix C client skipping servers when reconnecting#2440
kosa-as wants to merge 1 commit into
apache:masterfrom
kosa-as:ZOOKEEPER-2466

Conversation

@kosa-as

@kosa-as kosa-as commented Aug 17, 2026

Copy link
Copy Markdown

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 server
selection 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() and
remove 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:

  • unpatched client: does not reconnect after the server starts
  • patched client: reconnects successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant