Repository navigation
End every --test-time path at the deadline or last reply, and send nothing past it - #892
Conversation
…thing past it client::finished() compares the run's stats clock with --test-time, and that clock only moves on replies and connection errors. A client whose connection dropped before its deadline with nothing in flight, and whose reconnect AUTH the server held past it, sent a new SET once the setup completed: with one client served normally and the other's AUTH answered 2 s past a 3 s deadline, the run reported 4001 ms and 80.2 ops/sec instead of 3000 ms (#879). fill_pipeline() now also stops issuing workload, and ends an idle client in its "done" check, once connections_manager::deadline_passed_by() says a started client's own start plus --test-time is past by the time fill_pipeline() already reads at its top. It is checked once per call and adds no clock read. Staircase mode already compares the wall clock. The "done" check still leaves a client that holds --retry-on-error retries to the drain grace (#715). A client whose first connection only completes after the run is over now ends at once instead of sending a request. #876 ended a client in set_end_time() at min(now, max(deadline, last reply)), but the Ctrl+C (#747), failed-connect (#666) and drain-grace (#669) ends still capped an answered client at its deadline, dropping the replies it drained past it from the interval: 3021 ms against 3542 ms for the same workload (#880). client::test_time_end() now computes the rule for all four; the interrupt is bounded by the interrupt time. The Interrupted flag, exit codes, unanswered counts and #666's failing run are unchanged. A reply whose request is claimed for retry is not a final reply and no longer moves the last reply time, so a run whose retries never succeed still reports --test-time. test_answered_end_time.py adds the stalled-setup case (3000 ms, no SET after the setup) and the late reply ended by SIGINT, by a refused reconnect and by the drain grace (about 3500 ms each). reconnect_siblings_test.cpp checks the interrupt, failed-connect and drain-grace ends with a reply past the deadline, and mark_started() now records its reply time. cluster_slots_retention_test.cpp started its client at t=1000 s, long past its deadline, so the slot map retry it checks would no longer go out: it now starts the client 1 s ago. Fixes #879 Fixes #880 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 the diff and the commit history, and I have a few comments.
Nitpicking: the The regression coverage looks solid: the four RLTest cases fail on master, the scripted held-refresh case is good, and so is the mutant pass. The diff is large and touches cluster reconnect logic, so it may be worth a second look from whoever owns cluster/reconnect handling. I'd mainly like the split question and the (would file this as a comment, not a formal block) |
359d882 also stopped fill_pipeline()'s loop on the wall-clock deadline, so a connection whose reconnect or slot map refresh came due at the deadline, with nothing pending, sent no setup and ended its client normally. Four tests in test_cluster_slots_bad_reply.py caught it: - test_rejected_auth_once_at_deadline_fails_the_run (#666): the AUTH of the reconnect due at the deadline was never sent, so the rejected setup did not fail the run (#630) and it exited 0. - test_cluster_slots_one_empty_reply_at_deadline_is_retried (#666): the slot map refresh due at the deadline was not sent (2 CLUSTER SLOTS requests instead of 3), so a one-off slot error was not retried. - test_cluster_slots_{empty,malformed}_reply_mid_run_honours_test_time (#667): the refresh stopped at the deadline and the run ended normally, instead of failing as incomplete. These are guarantees, not the old overcounting, and the tests are unchanged. The loop condition is back to finished(), so setup still goes out past the deadline; only the per-request break checks the deadline, so no new workload does. The "done" check ends a client past its deadline only once this connection's setup is done and its other connections are done too (siblings_done(), not just no reply pending), so a sibling's reconnect or refresh due at the deadline still runs. This also restores cluster_slots_retention_test.cpp as it was: its slot map retry past the deadline is a setup command and goes out again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
bugbot run |
281499f's "done" check ended a client past its deadline only once this connection's setup was done. The only setup still pending there is a CLUSTER SLOTS refresh held for an open --transaction MULTI (#569): it waits for the rotation's EXEC, and past the deadline no new workload, EXEC included, goes out (#879). With --rate-limiting the refill timer kept calling fill_pipeline(), so the run never ended. A scripted one-node cluster whose first SET inside the MULTI gets -MOVED, with a rotation (MULTI, 10 SETs, EXEC at 5/s) longer than --test-time=2, hung until killed; master ends it at the deadline with the MULTI left open, as it does here now. Drop the setup check: the client ends, and disconnecting closes the MULTI. A reconnect or refresh due on another connection still keeps it going (siblings_done()), and so do held retries (#715). test_cluster_transaction.py adds the scripted case, which runs in every environment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
reconnect_siblings_test.cpp now runs fill_pipeline() on an idle connection whose client is past its --test-time deadline, while the client's other connection has a reconnect due. The client must not end until that sibling is done, then ends at its deadline. With siblings_done() replaced by all_connections_idle(), which counts pending replies only, the case fails: no other test told them apart. Comment why inc_reqs_answered() must follow handle_response(): that is where a retryable error claims the request for retry. The held-refresh transaction test's docstring cites #569 and #879 instead of the review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, all four are addressed in 94e32f1.
🤖 Generated with Claude Code |
siblings_done() did not count a connection whose connect is in progress: connect() clears the pending reconnect, and until the connect completes the connection has no reply pending and nothing to replay. A connection idle past its --test-time deadline, called again by the --rate-limiting timer, then ended the client and closed the sibling before it sent its setup, so a rejected AUTH on that redial no longer failed the run (#630). Master waits for that connect, as the idle connection had no reply to make finished() true. Count a connection in progress as busy. Its connect completes or fails (or hits --connection-timeout), and then the client ends as on master. Add a unit case for a sibling still connecting, and an RLTest case where a cluster node's full accept queue holds the redial in progress across the deadline. Both fail on the previous head. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Good catch, it was real, fixed in 114e79c.
🤖 Generated with Claude Code |
test_rejected_setup_after_slow_redial_past_deadline_fails_run started wall-clock timers before memtier, so a slow or starved start could miss the window. It failed 2 of 10 runs at nice 19 against 14 busy loops: the drop sometimes ran before node B had accepted memtier's connection, and release() closed memtier's own retried SYN along with the fillers. The first node's commands now drive the script. Node B drops once it has answered a request and the first node has had 10 SETs. It is released only once the redial's slot map refresh has come and no SET has come for 0.3 s since the deadline. release() closes only the fillers, identified by their ports. The test also asserts that the drop, the refresh and the release happened as planned, and that the drop came at least 1 s before the deadline. --test-time is 4 s, which leaves room for a starved peer. README: a client whose first connection completes only after the deadline, and that never sent a request, does not count toward Total duration or Count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, addressed in b5026bb.
🤖 Generated with Claude Code |
siblings_done() did not count a connected sibling whose setup still had to go out with no reply pending. One case is the main connection once a shard's reconnect timer has asked it for a CLUSTER SLOTS refresh, before its deferred fill sends it. The reconnecting shard no longer counts as pending by then. Another is a connection waiting for its CLUSTER SLOTS retry timer. A connection idle past its --test-time deadline could end the client in between, dropping the refresh and the redial it leads to. A rejected setup on that redial then no longer failed the run (#630). Count such a sibling as busy, unless its refresh is held for an open --transaction MULTI, which is not sent past the deadline (#569). The refresh then goes out, and its reply, retry or error ends the client as before. Add a unit case for a connected sibling with a refresh still to send; it fails on the previous head. Align the deadline test's comment with what siblings_done() checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once finished(), fill_pipeline() sends no setup step with nothing pending, as on master. A sibling left with a setup step due then, a slot map refresh after a late MOVED for example, never sends it. Since the previous commit siblings_done() counted it as busy, so a failed post-run redial on another connection (end_client_after_run()) left the client unended for good. Count a connected sibling's pending setup as busy only while the run is not finished(). Past the deadline with finished() still false, the case the previous commit fixed, it still keeps the client going. Split the comment above siblings_done(), and add a unit step for a finished() run, which fails on the previous head. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move siblings_done()'s per-connection checks into one predicate, shard_connection::may_send_again(). Each check names the path that sends again on its own: a pending reply, a due reconnect or a connect in progress, a setup step fill_pipeline() will still send, or requests to replay on a live connection. Behaviour is unchanged. holds_retries() is now on connections_manager, as deadline_passed_by() is, so fill_pipeline() no longer casts to client. The slow-redial tests all used --rate-limiting, whose refill timer keeps calling fill_pipeline() past the deadline. Add two runs without it. There, the first connection is paused, and the redial ends the client: its rejected AUTH fails the run, or once its accepted setup is done it finds the first connection idle and ends it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, addressed in 7382810.
🤖 Generated with Claude Code |
may_send_again() repeated by hand when fill_pipeline() sends a setup step: not when the step is held for an open MULTI, and not once the run is finished() with nothing pending. Move that into one helper, setup_step_sendable(), which the replay branch, the fill loop and may_send_again() all use. Behaviour is unchanged: in each place the helper reduces to the condition it replaces. Drop an extra blank line in test_connection_setup_rejected.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, addressed in d00f99a.
🤖 Generated with Claude Code |
Once the run is over, end_client_after_run() leaves the client to a busy sibling (siblings_done()), which since this PR includes a connect in progress, so a redial's rejected AUTH still fails the run (#630). Without --connection-timeout, a redial whose SYN is dropped (a firewalled or dead node) then kept the run open for the kernel's connect timeout: with the main connection's redial refused after the deadline, a 3 s run ended at 136 s, where master ended at 4 s. end_client_after_run() now marks the client as waiting for its siblings, and the drain grace ends such a client like one with replies pending, at the deadline plus 10 s, with a "still waiting for a connection" warning. A redial that connects within the grace keeps the #630 guarantee. Single-endpoint clients have no siblings and are unchanged (#669's idle-client guard). Also widen the held-refresh transaction test's bound to test_time + 6. Fixes #879 Fixes #880 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, addressed in ff07182.
🤖 Generated with Claude Code |
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 ff07182. Configure here.
ff07182 bounded the wait on a blackholed redial only when a connection had tried to end the client after the run (end_client_after_run()). A connection that stays up and idle past the deadline defers its end on !siblings_done() in fill_pipeline() without marking the client, so the drain grace still skipped it and the run waited for the kernel's connect timeout (137 s for a 3 s run; 135 s on master). Without --rate-limiting that connection is paused before the deadline and fill_pipeline() never runs again, so marking the client from there cannot cover it. The drain grace now also ends a client with a connection up and idle (nothing it may send again) while another connection's connect is in progress (client::idle_connection_waits_for_connect()). A sibling waiting for its reconnect timer, or a client whose connections are all down, is still left to the reconnect logic (#669). A redial that connects within the grace still sends its AUTH (#630), and --connection-timeout, when set, still ends the run sooner (5.0 s with 2). Reported by Cursor Bugbot. Fixes #879 Fixes #880 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks.
🤖 Generated with Claude Code |
|
Thanks for the re-review.
🤖 Generated with Claude Code |
|
Owner review summary for 2d91921: ready to merge.
🤖 Generated with Claude Code |

Fixes #879. Fixes #880.
Follow-up to #876, which ends a
--test-timeclient at max(deadline, last reply), bounded by now. This PR fixes the paths #876 left out.Problem
fill_pipeline()checked whether the run was over using a stale clock. A client whose connection stalled during setup could still send requests well after its deadline. In one run the first SET went out at about 5.0 s of a 3 s run, and the run reported 4001 ms.Change
Stop sending past the deadline (--test-time: a client whose reconnect setup stalls past its deadline sends new requests once it completes (finished() reads a stats clock that only replies move) #879):
fill_pipeline()checks once per call whether the client's own deadline has passed, using thenowit already reads. That check drives:--retry-on-errorretries keeps the drain grace from --retry-on-error: a --test-time run where every request keeps failing never ends (finished() only advances on completed ops; #669's drain grace misses requests held in the retry queue) #715.There is no new clock read. A check inside the per-request loop cost +118 instructions/op at pipeline 16, while the once-per-call check costs +13.
One end-time helper (--test-time: the interrupt (#747), dead-server (#666) and drain-grace end paths cap an answered client at its deadline, dropping replies it drained past it from the interval #880):
client::test_time_end(now, &end)returns min(now, max(deadline, last reply)). These paths all use it:set_end_time();end_client_after_run(true);The Interrupted flag, exit codes and unanswered counts don't change.
Retried replies: a reply whose request is claimed for retry no longer moves the last-reply time. Without this, every
-OOMretry reply pushed the end out, and the --retry-on-error: a --test-time run where every request keeps failing never ends (finished() only advances on completed ops; #669's drain grace misses requests held in the retry queue) #715 drain-grace test reported 12919 ms.m_reqs_answeredstill counts every reply.From End a --test-time client at its last reply when the server stalls after the deadline #876's review:
mark_started()now sets the reply time. There are exact-timestamp unit cases for the three end paths. Theset_end_time()comment is down to 3 lines, and the README--test-timetext no longer needs the --test-time: a client whose reconnect setup stalls past its deadline sends new requests once it completes (finished() reads a stats clock that only replies move) #879/--test-time: the interrupt (#747), dead-server (#666) and drain-grace end paths cap an answered client at its deadline, dropping replies it drained past it from the interval #880 caveats.Other behaviour changes
finished(), since no setup step is sent then with nothing pending, as on master) and it holds no retries. If a sibling's connect never completes (a redial whose SYN is dropped, without--connection-timeout) while another connection is idle or has given up, the drain grace ends it 10 s after the deadline with a "still waiting for a connection" warning. Before, the run waited for the kernel's connect timeout (about 2 min; master did too when the other connection stayed up, and ended at once, skipping the redial's AUTH (Reconnect when AUTH/SELECT/HELLO fails on a reconnect instead of hanging #630), when its redial was refused).--connection-timeoutstill bounds it sooner.may_send_again()) instead of ending throughfinished(): oncefinished()is true,fill_pipeline()sends no setup step (as on master), so a redial's AUTH would not go out (Reconnect when AUTH/SELECT/HELLO fails on a reconnect instead of hanging #630); and thefinished()end only checks pending replies, so it would end a client while a sibling's reconnect or connect is still due.--test-timedeadline that lands inside a--transactionMULTI, while a CLUSTER SLOTS refresh is held for it, ends the client instead of hanging and drops the MULTI with the connection, as on master.Results
Total duration in ms, measured at 359d882. Every run exits 0. Master was run twice and this PR three times.
--max-reconnect-attempts=5Tests
tests/test_answered_end_time.pyfail on master and pass with this PR, over 3 runs each.test_cluster_transaction.py::test_transaction_deadline_mid_multi_with_held_refresh_ends(scripted peer) covers the held-refresh case; it hung on an earlier head of this PR.test_connection_setup_rejected.py::test_rejected_setup_after_slow_redial_past_deadline_fails_runcovers a cluster redial still connecting at the deadline whose AUTH is then rejected: an earlier head ended the client and passed the run.test_connection_setup_rejected.py::test_blackholed_redial_*_is_ended_at_drain_grace(3 cases) cover a redial that never connects, with the main connection's redial refused, or with it idle with and without--rate-limiting: the run waited for the kernel's connect timeout (136-137 s for a 3 s run) and now ends at the drain grace. Two more cases run it without--rate-limiting, where the idle connection is paused and the redial ends the client: its rejected AUTH fails the run, or once its accepted setup is done it ends the run normally.test_cluster_slots*.py,test_answered_end_time.py,test_retry_on_error.py,test_reconnect*.py,test_connection_setup_rejected.py,test_run_count*.py,test_late_interrupt_duration.py, and every file that checks Total duration or Interrupted.make checkpasses 18/18.siblings_done()replaced byall_connections_idle()is caught by a unit case inreconnect_siblings_test.cpp: an idle connection past the deadline while a sibling has a reconnect due, then a connect in progress. Another unit case pins a connected sibling with a slot map refresh still to send as busy. The one that survives finalizes the interrupt with a freshnow, which lands within the test's tolerance.Affected versions
--reconnect-on-error, which came in 7ae9f65 (Connection Error Tracking & Auto-Reconnect #320). So it affects 2.3.0 through 2.5.2, and master.As with #876, the release notes will say that rate-limited timed runs can move by up to one rate tick compared with 2.5.x, and that a client whose first connection completes only after a
--test-timerun is over no longer counts in Total duration or Count.🤖 Generated with Claude Code
Note
Medium Risk
Changes core timed-run termination, pipeline sending, and duration/ops accounting across reconnect, cluster, transaction, and interrupt paths; behavior is well-tested but affects benchmark metrics users rely on.
Overview
Tightens
--test-timebehavior so timed runs stop issuing new workload once a client’s own deadline has passed (even when replies haven’t advanced the run clock), while connection setup (AUTH, CLUSTER SLOTS refresh, etc.) can still complete so rejected setup still fails the run.End-time reporting is unified through
client::test_time_end(): a client that sent workload ends at max(deadline, last final reply), capped at now. That logic now drives normal finish, SIGINT, drain-grace abandon, and failed-reconnect shutdown paths (#880). Replies claimed for--retry-on-errorno longer move the “last reply” timestamp.Shutdown coordination expands beyond pending replies: siblings with reconnects in progress, due setup steps, or replay queues keep the client alive until
may_send_again()/holds_retries()say otherwise. A client whose first connection completes only after the run is over ends immediately with no post-deadline SETs and may drop out of Total duration / Count if it never sent workload.README documents the updated rules; RLTest and unit tests cover setup stalls, late replies, interrupts, held CLUSTER SLOTS during MULTI, and slow cluster redials.
Reviewed by Cursor Bugbot for commit d00f99a. Bugbot is set up for automated code reviews on this repo. Configure here.