Repository navigation
Count retried requests as processed once, and uncount dropped replays - #559
Conversation
With --retry-on-error, a request answered with a retryable error was counted as processed when the error arrived, and again when its replay completed. A --requests run therefore stopped early, with exit 0, after sending only part of the requested commands. Under --reconnect-interval the extra count could also move processed past a reconnect point while the replay was still in flight. Requests dropped from the replay queue after a reconnect (at --max-retries, or with no captured bytes) were never uncounted from the generated total, so they held the pipeline for good: with --reconnect-interval the client stopped sending and the run failed with "client(s) stopped before reaching their stop condition", and a --requests run never finished. Count a request as processed only at its final outcome: a response that the retry path claims leaves processed unchanged, so a retried request stays in flight until its last attempt completes. Every replay-path drop is then an uncounted request, so drain_replay_queue_after_reconnect() and disconnect() uncount them with dec_reqs_generated(). Only counted responses can reach a --reconnect-interval boundary. Fixes #557 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review. A human maintainer still needs to review this before merge. Thanks for this. Splitting "answered" from "processed" looks like the right model. I checked the
The core fix looks solid to me. I'd mainly like the drop-path semantics settled, either in the code or in the help text, before this merges. Since this changes counters used for stop conditions, it may be worth a second look from whoever owns the retry/reconnect path. |
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 086426e. Configure here.
handle_event() treated "no request processed yet" as "the run has not started" and reset the start time on reconnect. Retried responses no longer count as processed, so a run whose first responses were all retryable errors restarted its --test-time clock when a connection dropped. Track responses received separately (m_reqs_answered, which includes responses that are retried) and use that instead. Also note that the retry-queue drop in disconnect() is not expected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once every request was sent, fill_pipeline paused the idle connection, and a retry replayed afterwards was written to it but never sent: the run failed with "client(s) stopped before reaching their stop condition". Resume the connection when replaying. Also restore maxmemory reliably in the tests (CONFIG GET returns bytes keys) and note in --help how retries count toward --requests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request answered with a retryable error leaves the pipeline and waits in its connection's retry queue for the backoff. If the run is past --test-time and that was the last pending reply, fill_pipeline() finds every connection idle (all_connections_idle() only checks pending replies) and calls disconnect_all(). disconnect() moves the retry queue into the replay queue, nothing reconnects, and the destructor frees the requests: they are never resent, never counted as errors, never logged to --failed-keys-file, and missing from Count. The run reports "errors 0" and exits 0. Both standalone (e.g. -BUSY) and cluster mode (-MOVED) are affected. Waiting for the retries instead is not bounded: --max-retries defaults to unlimited, and in cluster mode no CLUSTER SLOTS refresh is sent after the deadline (#590), so a MOVED retry would loop on the same node. So account for them the way other drops are since #559/#575: when the run ends, log every request still held for resend to --failed-keys-file as REPLAY "run-ended-before-retry", count it as an error like a refused retry, uncount it with dec_reqs_generated(), and print one warning. A --requests run is unaffected: a retried request is not processed until its final attempt, so it never ends with retries queued. Fixes #619 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request answered with a retryable error leaves the pipeline and waits in its connection's retry queue for the backoff. If the run is past --test-time and that was the last pending reply, fill_pipeline() finds every connection idle (all_connections_idle() only checks pending replies) and calls disconnect_all(). disconnect() moves the retry queue into the replay queue, nothing reconnects, and the destructor frees the requests: they are never resent, never counted as errors, never logged to --failed-keys-file, and missing from Count. The run reports "errors 0" and exits 0. Both standalone (e.g. -BUSY) and cluster mode (-MOVED) are affected. Waiting for the retries instead is not bounded: --max-retries defaults to unlimited, and in cluster mode no CLUSTER SLOTS refresh is sent after the deadline (#590), so a MOVED retry would loop on the same node. So account for them the way other drops are since #559/#575: when the run ends, log every request still held for resend to --failed-keys-file as REPLAY "run-ended-before-resend", count it as an error like a refused retry, uncount it with dec_reqs_generated(), and print one warning. A --requests run is unaffected: a retried request is not processed until its final attempt, so it never ends with retries queued. Fixes #619 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request answered with a retryable error leaves the pipeline and waits in its connection's retry queue for the backoff. If the run is past --test-time and that was the last pending reply, fill_pipeline() finds every connection idle (all_connections_idle() only checks pending replies) and calls disconnect_all(). disconnect() moves the retry queue into the replay queue, nothing reconnects, and the destructor frees the requests: they are never resent, never counted as errors, never logged to --failed-keys-file, and missing from Count. The run reports "errors 0" and exits 0. Both standalone (e.g. -BUSY) and cluster mode (-MOVED) are affected. Waiting for the retries instead is not bounded: --max-retries defaults to unlimited, and in cluster mode no CLUSTER SLOTS refresh is sent after the deadline (#590), so a MOVED retry would loop on the same node. So account for them the way other drops are since #559/#575: when the run ends, log every request still held for resend to --failed-keys-file as REPLAY "run-ended-before-resend", count it as an error (not as an op: it never got a final reply), uncount it with dec_reqs_generated(), and print one warning per client. A --requests run is unaffected: a retried request is not processed until its final attempt, so it never ends with retries queued. Fixes #619 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request answered with a retryable error leaves the pipeline and waits in its connection's retry queue for the backoff. If the run is past --test-time and that was the last pending reply, fill_pipeline() finds every connection idle (all_connections_idle() only checks pending replies) and calls disconnect_all(). disconnect() moves the retry queue into the replay queue, nothing reconnects, and the destructor frees the requests: they are never resent, never counted as errors, never logged to --failed-keys-file, and missing from Count. The run reports "errors 0" and exits 0. Both standalone (e.g. -BUSY) and cluster mode (-MOVED) are affected. Waiting for the retries instead is not bounded: --max-retries defaults to unlimited, and in cluster mode no CLUSTER SLOTS refresh is sent after the deadline (#590), so a MOVED retry would loop on the same node. So account for them the way other drops are since #559/#575: when the run ends, log every request still held for resend to --failed-keys-file as REPLAY "run-ended-before-resend", count it as an error (not as an op: it never got a final reply), uncount it with dec_reqs_generated(), and print one warning per client. A --requests run is unaffected: a retried request is not processed until its final attempt, so it never ends with retries queued. Fixes #619 Co-Authored-By: Claude Opus 5.5 <[email protected]>

Fixes #557. Follow-up to #556, which fixed the same leak for plain disconnects.
Problem
With
--retry-on-error:--requestsrun therefore stopped early, with exit 0, after sending only part of the requested commands.drain_replay_queue_after_reconnect()drops after a reconnect (at--max-retries, or with no captured bytes) stayed counted as generated. They held the pipeline for good:--reconnect-interval, the client stopped sending and the run failed withclient(s) stopped before reaching their stop condition;--requestsrun never finished.Fix
m_claimed_by_retry) leaves processed unchanged, so a retried request stays in flight until its last attempt completes.drain_replay_queue_after_reconnect()anddisconnect()uncount them withdec_reqs_generated()(from Uncount dropped in-flight requests so clients don't stall after a reconnect #556).--reconnect-intervalboundary. Otherwise a batch of only claimed responses would trigger the voluntary reconnect again at the same count (including 0).Testing
Two new tests in
tests/test_retry_on_error.py, both standalone only:test_retried_requests_are_counted_once: about 1 s of retryable-OOM(CONFIG SET maxmemory 1) inside a rate-limited--requests 3000run. ChecksDBSIZEand JSONSets/Countequal 3000.test_dropped_replays_do_not_stall_client:--retry-on-error --max-retries=0 --reconnect-interval=10withCLIENT KILLwaves.Local results, master vs this branch:
-OOM,--requests 3000--max-retries=0,--reconnect-interval=10, kills--requests 20000, kills,--max-retries=0test_retry_on_error.py7/7 (×3 plain, ×1 TLS). The full standalone suite passes; 4 throughput tests failed only when the host was overloaded and pass when rerun alone, on both master and this branch.🤖 Generated with Claude Code
Note
Medium Risk
Touches core stop conditions (
--requests, pipeline, reconnect) in the hot response/replay path; behavior change is intentional but could affect edge cases around retry and reconnect.Overview
Fixes
--retry-on-errorrequest accounting so--requestsruns and pipeline limits match real workload completion.Processed vs answered: Adds
m_reqs_answered(every response, including retryable errors) whilem_reqs_processedonly advances on a final outcome—responses where the retry path setsm_claimed_by_retryno longer double-count toward--requestsor--reconnect-interval.Dropped / replay path: Reconnect replay drains call
dec_reqs_generated()for requests dropped at max retries or without captured bytes (including stray retry-queue entries on disconnect), so abandoned work no longer blocks the pipeline.replay_request()resumes a paused connection when the last outstanding item is a retry.Docs & tests: CLI help clarifies that retried work counts once toward
--requests. New standalone tests cover OOM retries, retry-after-last-send, and--max-retries=0+ reconnect stalls.Reviewed by Cursor Bugbot for commit eabdcb3. Bugbot is set up for automated code reviews on this repo. Configure here.