Repository navigation
End a --retry-on-error --test-time run whose retries never succeed after the drain grace - #724
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The root-cause write-up makes the change easy to follow. Extending #669's abandon path, instead of touching A couple of questions, neither blocking:
The core fix looks solid to me. I'd just like the cluster mixed-state question answered before this merges. (would file this as a comment, not a formal block) |
02c43b6 to
9b89460
Compare
|
Thanks for the review. Replies point by point. The branch is now at 9b89460, rebased on ec4e6fa, and the design changed.
On #666: this PR no longer touches |
…ter the drain grace With --retry-on-error, unlimited --max-retries and a server that rejects every request (e.g. -OOM), a --test-time run never ended. client::finished() measures the run with the per-second stats clock, which only moves on a completed op, and a reply handed to enqueue_retry() completes none. #669's drain grace is meant to bound exactly this kind of run, which keeps going after the deadline, but abandon_unanswered_requests() returned early for a client with no reply pending, and a request held in the retry queue for its backoff is not pending. With --pipeline 1 that is almost always the case. Since 50cfd7f resumes a paused connection to send a retry, such a run resends its retries forever on master. Count a client that still holds retries as unanswered too. TEST_TIME_DRAIN_GRACE_SECS after the deadline it is ended like a stalled one: the held requests are counted as errors (failed-keys status run-ended-before-resend), and the reported end time is start + --test-time, so Runtime and the rates cover --test-time. handle_end_stalled_clients() now reports the two kinds of client separately, by what each one had: "N client(s) got no reply to M request(s)" for clients waiting for replies, and "N client(s) were still retrying M request(s)" for clients holding retries, once per thread rather than one "held for retry" line per client. A client with both (the tick found a resend on the wire) is in both lines. Retries still go on after --test-time, as before, so a MOVED that arrives then still refreshes the slot map (test_moved_after_test_time_refreshes_slots). The grace check runs from the main thread's 1 s tick, so a long retry backoff cannot hold the run past it. A client waiting for a reconnect is still left alone, with or without --retry-on-error: its requests wait in the replay queue. README, man page and --help describe the new end of such runs. Fixes #715 Co-Authored-By: Claude Opus 5.5 <[email protected]>
9b89460 to
602a6af
Compare
|
Thanks. Replies to the second review, point by point. The branch is now at 602a6af, rebased on e09ee54. (a) Description vs code. The PR body is rewritten for the grace-based design. That includes the decision, the before/after table, the #666 overlap, a one-line dependency note for the server-dies-under- (b) Clock moved by another connection. Yes, (c) Mixed clients in one warning. Fixed.
A client with both is counted in both. The per-client "held for retry" lines are folded into the second line, so (d) Test length and bounds. Trimmed to factor 0, factor 2, the 20 s backoff and the control, about 45 s in total. The upper bound is now test_time + grace + 3 s, which leaves room under sanitizers: cluster ASan measured 15.02 s on the old 15.5 s bound. The test also accepts the case where the 1 s tick finds a resend on the wire. That client then appears in the "no reply" line, and the test checks that the two counts add up against the failed-keys rows, JSON (e) Hard-coded grace. The grace is now read back from the warning text, as |
|
Answering the two questions in the 18:59 version of the review:
|
Decision: a
--test-timerun whose--retry-on-errorretries never succeed is now ended by #669's drain grace (TEST_TIME_DRAIN_GRACE_SECS, 10 s after the deadline), the same way as a run waiting for replies that never come. Until then, retries go on after--test-timeas before. That is the existing contract pinned bytest_moved_after_test_time_refreshes_slots: a MOVED that arrives after the deadline still refreshes the slot map. The report covers--test-timeand not the grace.Behaviour change to note: a run where every request always fails now exits 0 at test_time + 10 s, with the requests counted as errors. On master it ran forever, or, with the default
--connection-stage-timeout(30 s), exited 2 at that timeout. The second case only applies when test_time + 10 <--connection-stage-timeout.(The first version of this PR ended the run on wall time at the deadline. That broke
test_moved_after_test_time_refreshes_slotsand could still overshoot by one retry backoff. It has been replaced.)Problem
With
--retry-on-errorand the default unlimited--max-retries, a--test-timerun against a server that rejects every request (e.g.maxmemory 1+noeviction, so every SET gets-OOM) never ends. It resends its retries until killed, or until--connection-stage-timeoutaborts it with rc=2. See #715.Root cause
client::finished()comparesm_stats.get_duration()with--test-time. That ism_cur_stats.m_second, which only moves inroll_cur_stats()from theupdate_*_op()calls, i.e. when an op completes. A reply handed toenqueue_retry()records nothing, so the clock stays at 0.client::abandon_unanswered_requests()returned early whenall_connections_idle(), i.e.get_pending_resp() == 0. A request held in the retry queue for its backoff is not pending, and with--pipeline 1that is almost always what the tick sees.Fix
abandon_unanswered_requests()also ends a client that still holds retries (shard_connection::holds_retries()) once the grace is over:run-ended-before-resend;--test-time, so Runtime and the rates cover--test-time.handle_end_stalled_clients()reports the two kinds of client separately, based on what each client actually had, once per thread:N client(s) got no reply to M request(s) 10 seconds after the test time ended; abandoned them (...)for clients waiting for replies. This includes clients waiting only for setup replies, as before.N client(s) were still retrying M request(s) 10 seconds after the test time ended; ended them (counted as errors, not resent).for clients holding retries. This line replaces one "held for retry" line per client:-t 2 -c 8now prints 2 lines instead of 16 when all clients cross the grace on the same 1 s tick. Clients that cross it on different ticks print one pair of lines per tick (at most two lines per thread per tick). The counts still add up exactly.-t 2 -c 8run, 1 of 16 clients was.--retry-on-error: its in-flight requests wait in the replay queue, not the retry queue.finished()and the retry drain timer are unchanged:end_stalled_clients()→event_base_once), so a long backoff cannot hold the run past test_time + grace + about 1 s;--test-timerun"), the man page and--helpdescribe this. JSON"Unanswered requests"does not include held retries.Overlap with #666: this PR touches neither
run_is_over()norrun_deadline(); it only extends the #669 abandon path. Dependency: when the server dies after the deadline under--reconnect-on-error, the run still hangs with this PR alone (that is #656, fixed by #666). With #666 merged too, it ends at 7.0 s with duration 3000 and 64run-ended-before-resendrows.Test evidence
test_retry_on_error.py::test_test_time_ends_when_every_request_is_retried(new):Setup: every SET gets
-OOM,--test-time 3,--pipeline 1,--failed-keys-file. Cases: backoff 100 ms with factor 0, backoff 100 ms with factor 2, a 20000 ms backoff, and a control without--retry-on-error. Times are measured withtime.monotonic(), and the grace is read from the warning text.Retry cases assert:
test_time + grace <= elapsed < test_time + grace + 3;run-ended-before-resendrows, and the "no reply" count equals theno-reply-after-test-timerows, which equals JSONUnanswered requests;errorstotal equals the sum.Accepting both categories makes the test robust when the tick finds a resend on the wire.
The control asserts the run ends in [test_time, test_time + 3) with neither warning.
test_test_time_stalled_server.py:test_test_time_reconnecting_client_left_alonenow asserts that neither warning appears. A mutant that removes the idle gate (M1) fails it...._left_alone_retry_on_error: the same test with--retry-on-error. A mutant whereholds_retries()lacks the emptiness check (M4) fails it.Results:
--retry-on-errorreconnect test fails.test_retry_on_error.py: 28/28;test_test_time_stalled_server.py: 5/5 standalone and 5/5oss-cluster;test_cluster_redirect_stats.pyonoss-cluster: 9/9;make check: 10/10.Manual repro (
-t 1 --ratio 1:0 --retry-on-error --connection-stage-timeout 0, maxmemory 1 + noeviction):-c 1 --pipeline 1 --retry-backoff-ms 100 --retry-backoff-factor 0 --test-time 3-c 1 --pipeline 1 --retry-backoff-ms 20000 --test-time 3-c 1 --retry-backoff-ms 1000 --retry-backoff-factor 2 --test-time 3-t 2 -c 8 --retry-backoff-ms 100 --test-time 3-c 1 --pipeline 1 --test-time 3(no retry)Whole-second wall times come from the main thread's
sleep(1)poll for thread completion, not from a delay in the run. The JSON duration of the same runs is test_time. In the first version of this PR, a factor-0 run had a JSON duration of 3036 ms and showed 4.0 s wall, and a 0 ms backoff showed 3.0 s wall.Fixes #715
Affected versions
master only (not in a release). The underlying condition goes back to 2.4.0.
git tag --contains 50cfd7fgives no tag.finished()has usedm_cur_stats.m_secondsince the first version (833a8df).🤖 Generated with Claude Code