Repository navigation
Back off CLUSTERDOWN topology refreshes per client - #877
Conversation
Since #799, a -CLUSTERDOWN reply refreshes the topology with CLUSTER SLOTS at most once per second per client. Each client keeps its own map and there was no backoff, so -t 8 -c 50 sent up to 400 refreshes per second for the whole outage, adding control-plane load to the failure being measured. While a client sees only CLUSTERDOWN replies, the gap between its refreshes now doubles: 1 s, 2 s, 4 s, then 8 s. At the 8 s cap the same run sends at most 50 refreshes per second, and a new map is still seen sooner than the cluster's own failure detection (cluster-node-timeout, 15 s by default) completes. Any other workload reply means the cluster serves requests again and resets the gap to 1 s; the 1 s floor stays, so a flapping or partially covered cluster is never polled faster than before. The refresh's own CLUSTER SLOTS reply is a setup reply that never reaches handle_response, so it cannot reset the backoff while the cluster is still down. The decision lives in clusterdown_refresh_backoff in retry_backoff.h, next to the --retry-on-error backoff, and retry_backoff_test checks the sequence, the cap, saturation and the reset. A scripted-peer test counts CLUSTER SLOTS during a sustained CLUSTERDOWN with two clients: 8 with the backoff, 14 with the old fixed interval. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review. A human maintainer's review is still required before merge. Thanks for this. I went through it and it looks solid to me. The One question about the Nitpicking: the long comment block above Neither of these blocks the change. |
…est's timevals portably TRYAGAIN, LOADING or MASTERDOWN during a failover do not show the cluster serves requests again, but any non-CLUSTERDOWN reply reset the backoff, so a mix of them put each client back on the 1 s cadence. Reset only on a successful reply. The unit test built timevals with braces and a suseconds_t cast, which MSYS2 does not declare (tv_usec is long there): set the members instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks. Agreed on the reset. Fixed in e04a7af: the backoff now resets only on a successful (non-error) workload reply. The same commit fixes the MSYS2 failure on 40ac69f ( On the boolean checks: I've left Sanitized |
During CLUSTERDOWN Redis still answers keyless commands: PING, MULTI and WAIT succeed (checked on Redis 7.0.15), while a keyed command, also inside MULTI at queue time, gets -CLUSTERDOWN and EXEC gets EXECABORT. With --transaction, or a --command mix that includes a keyless command, every such reply reset the backoff, so those workloads went back to one refresh per second per client for the whole outage. Reset only on a successful reply to a request that carries a key: rt_set, rt_get, or rt_arbitrary whose command metadata lists key positions or __key__ placeholders. request::m_keys cannot tell, since arbitrary_request sets it to 1 for keyless commands. --transaction sends MULTI and EXEC as keyless rt_arbitrary requests, so their replies no longer reset it. The scripted-peer test now also runs a --transaction workload and a SET+PING --command mix: both sent 14 CLUSTER SLOTS before this change, against bounds of 10 and 8. 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.
❌ 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 dc4945c. Configure here.
…ckoff Random --monitor-input replay sends each line with the stats-only slot of its command type as metadata. That slot has no argv, so it has no key positions or __key__ placeholders, and request_carries_key() treated every such reply as keyless. A successful keyed monitor line never reset the backoff, so after a CLUSTERDOWN episode the workload stayed at the 8 s gap. Specific-line __monitor_lineN__ replay was not affected. The stats-only slot does carry the command spec looked up for its type, so also count it as keyed when that spec has key specs or movable keys. arbitrary_command::has_keys() now holds the key-position or placeholder test that the arbitrary_request constructor and request_carries_key() both used, so the two cannot drift. The backoff comments in retry_backoff.h now name a keyed request's success as the reset. The scripted peer replays a CLUSTERDOWN SET mixed with SET foo, and with PING as a control. With the keyed mix the client must stay near one refresh per second: 8 CLUSTER SLOTS before this change against a lower bound of 10. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
On the duplicated key check: done in eb42f5e. |

Fixes #834.
Since #799, a
-CLUSTERDOWNreply makes eachcluster_clientrefresh its topology withCLUSTER SLOTS, at most once per second. Each client keeps its own map, so-t 8 -c 50sent up to 400 refreshes per second for the whole outage.This takes option 1 from the issue, per-client exponential backoff:
CLUSTERDOWNreplies, the gap between its refreshes doubles from 1 s to 8 s (refreshes at 0, 1, 3 and 7 s, then every 8 s). A sustained outage at-t 8 -c 50drops from 400 refreshes per second to 50.TRYAGAIN,LOADING,MASTERDOWN) or redirects. Without this,--transactionruns and keyless--commandmixes would still poll once a second.cluster-node-timeout, 15 s by default).The decision lives in a small
clusterdown_refresh_backoffstruct inretry_backoff.h, next to the existing retry backoff. The README paragraph that stated the 400/s figure now states the schedule.Tests
tests/unit/retry_backoff_test.cppgets a case for the schedule, the cap, the reset and the 1 s floor. Against master's fixed 1 s logic it fails 13 checks: a 60 s outage gives 61 refreshes instead of 10.CLUSTERDOWNtest intests/test_cluster_unowned_slots.pygets a case that countsCLUSTER SLOTSduring a sustainedCLUSTERDOWN, for a plain workload,--transaction, and a SET+PING--commandmix. Master's logic sends 14 against a bound of 8 to 10, and so does a reset on any successful reply for the two keyless-reply workloads. With the fix it passed 4/4 runs.Results (Ubuntu 24.04 container, libevent 2.1.12):
make checkpasses, plain and ASan+UBSan.test_cluster_unowned_slots.pypasses 24/24, plain and sanitized.OSS_CLUSTER=1, 7 cluster test files pass 70/72. The 2 failures (test_transaction_connection_kills_do_not_hang,test_transaction_lost_multi_is_not_continued) fail the same way on unmodified master in this container.Limitation (same as master): if only some slots are down and the workload mixes keys, successful replies keep resetting the gap, so each client still refreshes about once a second. Removing that needs option 2 from the issue: one shared refresh per thread.
🤖 Generated with Claude Code
Note
Medium Risk
Changes cluster-mode error handling and topology refresh timing during outages; behavior is well-tested but affects all CLUSTERDOWN paths in production benchmarks.
Overview
Replaces fixed 1 s
CLUSTER SLOTSpolling on-CLUSTERDOWNwith per-client exponential backoff (1 → 8 s) so large-t/-cruns no longer hammer the cluster during sustained outages (#834).Each
cluster_clientnow uses aclusterdown_refresh_backoffhelper inretry_backoff.h: refresh gaps double after eachCLUSTERDOWN-triggered topology poll until they cap at 8 s, while a 1 s floor remains. A successful reply to a keyed workload resets the streak; keyless successes (PING,MULTI, monitor lines without keys, etc.) do not, via newrequest_carries_key()andarbitrary_command::has_keys(). README documents the revised refresh schedule.Tests add unit coverage for the backoff schedule and integration cases that bound
CLUSTER SLOTScalls under sustainedCLUSTERDOWN, transactions, and monitor replay.Reviewed by Cursor Bugbot for commit eb42f5e. Bugbot is set up for automated code reviews on this repo. Configure here.