Repository navigation
Name the cause when strict secondary has no replica to read from - #901
Conversation
With --read-preference=secondary and fallback error (or queue, which acts as error), a CLUSTER SLOTS reply that lists no replicas leaves no target for any read, as right after `redis-cli --cluster create`. The run then ends at once with 0 ops. Only the built-in GET-only workload printed a warning (hold_pipeline's no-route stall was limited to ratio.a == 0); keyless and keyed --command reads ended with nothing but "client(s) stopped before reaching their stop condition" (#888). Hold arbitrary-command reads in the same no-route branch, so they behave like the built-in GET-only workload, and when the topology has no replica at all print an error that says so and points at secondaryPreferred or --read-preference-fallback=primary, instead of the "all replicas unreachable" warning. The run still fails as before; no wait is added, since memtier does not refresh the slot map on its own here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks, this looks right to me. Letting A couple of small things:
None of this blocks the merge. The fix and the test look good to me. |
| benchmark_error_log("warning: [thread %lu] all replicas unreachable under read-only workload " | ||
| "(--read-preference=%s); benchmark stalled -- check cluster health or set " | ||
| "--reconnect-on-error.\n", | ||
| (unsigned long) pthread_self(), rp_str); |
There was a problem hiding this comment.
Mixed-command stall drops queued writes
Medium Severity
The new stall treats the next --command as if the whole workload were read-only. When that command is a read and no replica is routable, hold_pipeline parks every connection, including ones that still have cross-shard writes sitting in m_key_index_pools. Mixed SET/GET --command runs can therefore drop already-routed writes and fail instead of sending them to the primary. Nearby holds skip this when a pool is non-empty, and mixed built-in --ratio traffic is still excluded from this branch.
Reviewed by Cursor Bugbot for commit d5540f4. Configure here.
The topology is the same for every client, so -t 4 -c 50 printed the error 200 times: print it once. The warning now also covers --command reads and runs with --reconnect-on-error, so drop "read-only workload" and say what --reconnect-on-error does. Update the comment that named ratio.a==0 only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f46698d. Configure here.
| benchmark_error_log("warning: [thread %lu] all replicas unreachable for reads " | ||
| "(--read-preference=%s); benchmark stalled -- check cluster health " | ||
| "(--reconnect-on-error lets it recover when they return).\n", | ||
| (unsigned long) pthread_self(), rp_str); |
There was a problem hiding this comment.
Read stall parks queued writes
Medium Severity
The new --command read stall in hold_pipeline() parks the connection whenever the next arbitrary command is a read and no replica is live, without checking for pooled or staged work. m_executed_command_index is shared across shards, so a mixed write-then-read --command list can queue a SET on another shard and then immediately hold every connection, leaving that write unsent.
Reviewed by Cursor Bugbot for commit f46698d. Configure here.


Fixes #888.
In cluster mode with strict
--read-preference=secondary, if CLUSTER SLOTS lists no replicas, no read can be routed. For--commandreads (keyless, or keyed likeGET __key__), the run ended at once with 0 ops and only the generic "client(s) stopped before reaching their stop condition". The built-in GET-only workload (--ratio=0:1) already went through a stall branch incluster_client::hold_pipeline()that warns "all replicas unreachable". Arbitrary-command reads never reached it.Fix (
cluster_client::hold_pipeline()):--commandreads now take that same branch.error: --read-preference=secondary: CLUSTER SLOTS lists no replicas, so no read can be routed; use --read-preference=secondaryPreferred or --read-preference-fallback=primary.Test:
test_strict_secondary_without_replicas_names_the_causeintests/test_cluster_slots_bad_reply.py. It covers--command=PING --command-is-read,--command="GET __key__"and--ratio=0:1, each with the default fallback and with--read-preference-fallback=queue, against a scripted one-node cluster with no replicas. Each case must exit 1, print the new message, and send no data. With the fix reverted, all 6 cases fail: the PING and GET runs print no reason, and the built-in run only shows the old warning.Not covered: a mixed built-in workload (
--ratio=1:1) with strict secondary and no replicas also ends at once with only the generic message, before and after this change.Results (ASan + UBSan, Ubuntu 24.04 container):
make checkpasses.🤖 Generated with Claude Code
Note
Low Risk
Targeted diagnostics and stall-path widening in cluster read routing; no new flags or topology refresh behavior.
Overview
Fixes #888: cluster runs with
--read-preference=secondaryand a topology that lists no replicas (typical right afterredis-cli --cluster create) could finish with 0 ops and only a generic stop message for--commandreads; built-in GET-only workloads already hit a stall path inhold_pipeline().cluster_client::hold_pipeline()now treats arbitrary-command reads like pure read workloads when there is no routable target, so they enter the same stall/warning path. When strict secondary applies and no shard has any replica, it logs a once-per-processerror:explaining that reads cannot be routed and suggestingsecondaryPreferredor--read-preference-fallback=primary; if replicas exist but are unreachable, the existing rate-limited warning remains (text slightly clarified).Test:
test_strict_secondary_without_replicas_names_the_causecoversPING --command-is-read, keyedGET, and--ratio=0:1, with default andqueuefallback, expecting exit 1, the new message, and no data commands sent.Reviewed by Cursor Bugbot for commit f46698d. Bugbot is set up for automated code reviews on this repo. Configure here.