Repository navigation
Count retries still queued when a --test-time run ends (#619) - #620
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this, and for the detailed write-up. The root cause matches what I see in the code:
The core fix looks solid to me. I'd mainly like an answer on the error-accounting asymmetry in point 1 before this merges. (would file this as a comment, not a formal block) |
9e7967c to
c3e94cd
Compare
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]>
c3e94cd to
9184208
Compare
|
Thanks for the review. Answers point by point (head 9184208, rebased on f1cb946):
After the rebase the new test passes 5/5, and the whole 🤖 Generated with Claude Code |
With --retry-on-error, a request memtier gives up on after its connection drops is logged to --failed-keys-file but was never counted as an error, so the run reported "errors 0". Since #620 a request abandoned when the run ends is counted, so whether a lost request reached the error total depended only on where it was dropped. Add connections_manager::abandon_requests(), which uncounts the requests from the generated total (as the drop sites already did) and counts each one as an error, and use it at every place a request held for resend is dropped for good: - drain_replay_queue_after_reconnect(): "connection-dropped" (max retries reached) and "no-captured-bytes-for-replay" - cluster_client::hand_off_replay_requests(): "transaction-not-replayed", "no-slot-owner-for-replay", "slot-owner-down-for-replay" - shard_connection::disconnect() under --retry-on-error: "transaction-not-replayed" and requests with no captured bytes - client::disconnect_all(): "run-ended-before-resend" (unchanged count) A request moved to the replay queue and later resent is not counted; it is counted only where it is finally dropped. Requests dropped on a disconnect without --retry-on-error are still only uncounted, as before. The failed-keys rows are unchanged. Fixes #652 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request memtier gives up on after its connection drops is logged to --failed-keys-file but was never counted as an error, so the run reported "errors 0". Since #620 a request abandoned when the run ends is counted, so whether a lost request reached the error total depended only on where it was dropped. Add connections_manager::abandon_requests(), which uncounts the requests from the generated total (as the drop sites already did) and counts each one as an error, and use it at every place a request held for resend is dropped for good: - drain_replay_queue_after_reconnect(): "connection-dropped" (max retries reached) and "no-captured-bytes-for-replay" - cluster_client::hand_off_replay_requests(): "transaction-not-replayed", "no-slot-owner-for-replay", "slot-owner-down-for-replay" - shard_connection::disconnect() under --retry-on-error: "transaction-not-replayed" and requests with no captured bytes - client::disconnect_all(): "run-ended-before-resend" (unchanged count) A request moved to the replay queue and later resent is not counted; it is counted only where it is finally dropped. Requests dropped on a disconnect without --retry-on-error are still only uncounted, as before. The failed-keys rows are unchanged. Fixes #652 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request memtier gives up on after its connection drops is logged to --failed-keys-file but was never counted as an error, so the run reported "errors 0". Since #620 a request abandoned when the run ends is counted, so whether a lost request reached the error total depended only on where it was dropped. Add connections_manager::abandon_requests(), which uncounts the requests from the generated total (as the drop sites already did) and counts each one as an error, and use it at every place a request held for resend is dropped for good: - drain_replay_queue_after_reconnect(): "connection-dropped" (max retries reached) and "no-captured-bytes-for-replay" - cluster_client::hand_off_replay_requests(): "transaction-not-replayed", "no-slot-owner-for-replay", "slot-owner-down-for-replay" - shard_connection::disconnect() under --retry-on-error: "transaction-not-replayed" and requests with no captured bytes - client::disconnect_all(): "run-ended-before-resend" (unchanged count) A request moved to the replay queue and later resent is not counted; it is counted only where it is finally dropped. Requests dropped on a disconnect without --retry-on-error are still only uncounted, as before. The failed-keys rows are unchanged. Fixes #652 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --retry-on-error, a request memtier sent and then gave up on (never resent, never answered) was logged to --failed-keys-file but not counted in the error total, so runs reported "errors 0" next to hundreds of dropped rows. Since #620 the run-end drop was counted; every other drop site only uncounted the request. Add connections_manager::abandon_requests(), which uncounts the requests and counts each one as an error, and shard_connection::abandon_replay_requests(), which logs and abandons everything held for resend on a connection. Use them wherever a request is dropped for good: - drain_replay_queue_after_reconnect(): connection-dropped, no-captured-bytes-for-replay - cluster_client::hand_off_replay_requests(): transaction-not-replayed, no-slot-owner-for-replay, slot-owner-down-for-replay - shard_connection::disconnect(): transaction-not-replayed, and the new not-replayable for requests without captured bytes - client::disconnect_all(): run-ended-before-resend (count unchanged) - client_group::run(), once the thread's event loop returns: everything still held, or still in flight under --retry-on-error, on every connection of the thread. The connection that ended the thread logs with max-reconnect-attempts-exceeded, or connection-lost-no-reconnect without --reconnect-on-error; the others with thread-ended-before-resend. One stderr warning per thread. On Ctrl+C only the queued requests are logged and counted; requests in flight are dropped as before. A request moved to the replay queue and later resent is not counted. Without --retry-on-error, requests dropped on a disconnect are still only uncounted. The memtier_errors_total HELP text and docs now include requests given up on without a reply. Fixes #652 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
With
--retry-on-errorand--test-time, a request that is waiting in a retry queue when the run ends is dropped silently:--failed-keys-file;The run still prints
errors 0and exits 0. This happens in standalone mode (for example-BUSY) and in cluster mode (-MOVED). Details and the cluster repro are in #619.Root cause
enqueue_retry(). The request leaves the pipeline, som_pending_respdrops, and it waits inm_retry_queuefor the backoff timer.fill_pipeline()seesfinished()andall_connections_idle(), and callsdisconnect_all().all_connections_idle()only checks pending replies.disconnect()moves the retry queue into the replay queue. Nothing reconnects, so the destructor frees those requests without recording them anywhere.A
--requestsrun can't end with retries still queued. Since #559 a retried request is counted as processed only at its final attempt, sofinished()stays false until the retry completes.Fix
At the end of the run,
client::disconnect_all()takes every request still held for resend, from the retry queue and the replay queue, usingpop_replay_request(). Each one is handled like the drops in #559/#575, plus an error count:--failed-keys-fileasREPLAYwith statusrun-ended-before-resend. The status says "resend" because the replay-queue case is a reconnect resend, not a retry.inc_error()), so it shows in theerrors Nprogress tail and in Prometheus. Unlike a refused retry, it is not counted as an op: it never got a final reply, so there is no latency to record.dec_reqs_generated(). Nothing reads that count afterdisconnect_all(), so this call can't be observed, and a mutant that removes it survives the tests. It stays for consistency with the other drop paths (Count retried requests as processed once, and uncount dropped replays #559/Resend held retries when a slot map refresh retires a connection #575), so the generated and processed counts agree whatever reads them later.A warning line reports how many requests were dropped. It's printed once per client that dropped any, not once per run, so
-c 2or-t Ncan print several lines.Why not drain instead? Waiting for the retries is not bounded.
--max-retriesdefaults to unlimited. In cluster mode, CLUSTER SLOTS isn't sent after the deadline, so a MOVED retry would go back to the same node: that is #590, which #591 fixes only while replies are still pending. Draining would turn this silent drop into a hang. Accounting keeps--test-timemeaning "stop at the deadline" and makes the loss visible.disconnect_all()is only called from the twofinished() && all_connections_idle()end-of-run checks inshard_connection.cpp, so nothing changes mid-run.Interactions with other PRs. This PR is rebased on master f1cb946, where #591, #600 and #613 have merged. None of them touch
client::disconnect_all().fill_pipelinesends setup commands afterfinished()while replies are pending): with it, some of these retries reroute instead of being dropped. The case where all replies arrive in one burst still ends here, and is now accounted.run-ended-before-resenderrors. That's intended, since they were never resent, but it's a visible change for ASK-heavy runs that end during a reconnect.all_connections_idle()doesn't treat a reconnecting connection as busy, so another connection's teardown can still calldisconnect_all(), and this PR will count those replays as errors rather than wait for the reconnect. The accounting is correct, but the replays end early. Making the idle check wait for reconnecting connections is a separate change and out of scope here.Tests
New test
test_retries_left_at_end_of_test_time_are_countedintests/test_retry_on_error.py. It uses a scripted standalone peer, with no Redis needed:+OK, then holds every reply from 0.3 s.--test-time=1, it writes all 8 held replies at once:+OKand 7 ×-BUSY.--retry-backoff-ms=200keeps the retries in the queue.abandoned(failed replies minus the retries the peer received) is greater than 0. Thatabandonedcount must equal both therun-ended-before-resendlines in--failed-keys-fileand the finalerrors N.Local results (RLTest):
0 == 7(no failed-keys lines,errors 0)test_retry_on_error.py16/16 (standalone, RLTest--env oss)The master failure wasn't rerun after the rebase. The test still checks for the
run-ended-before-resendlines and theerrors Ncount, which master doesn't produce.Scripted cluster peer from the #591 review (MOVED burst after the deadline):
errors/ failed-keys lines--pipeline=1--pipeline=4--pipeline=16-c 2 --pipeline=4Related suites with this PR:
test_retry_on_error.py9/9,test_reconnections.py7 pass / 3 skip;test_retry_on_error.py4 pass / 5 skip,test_cluster_redirect_stats.py5/5,test_cluster_transaction.py15 pass / 2 skip,test_reconnections.py7 pass / 3 skip.CI runs the full matrix.
Fixes #619
Affected versions
2.4.0 through 2.5.2 (latest) and master.
--retry-on-error), which added the retry queue. The end-of-run idle check from Fix rate-limit induced hanging at test completion #340 never took that queue into account.🤖 Generated with Claude Code
Note
Medium Risk
Changes end-of-run teardown and error accounting for --retry-on-error + --test-time; behavior is bounded to disconnect_all() but affects reported errors and failed-keys output.
Overview
Fixes a silent loss of work when
--test-timeends while--retry-on-errorstill has requests waiting in retry/replay queues (not counted as pending replies).client::disconnect_all()now drains each connection’s replay queue afterdisconnect(), treating every stranded retry like a refused replay: log to--failed-keys-fileasREPLAY/run-ended-before-resend,inc_error(),dec_reqs_generated(), plus a one-line warning with the count.Adds
test_retries_left_at_end_of_test_time_are_countedusing a scripted TCP peer that bursts retryable-BUSYreplies after the deadline, asserting failed-keys lines match the finalerrors Ntail.Reviewed by Cursor Bugbot for commit 23f1db7. Bugbot is set up for automated code reviews on this repo. Configure here.