Skip to content

End every --test-time path at the deadline or last reply, and send nothing past it - #892

Merged
fcostaoliveira merged 12 commits into
masterfrom
claude/end-time-paths-879
Oct 26, 2026
Merged

fcostaoliveira merged 12 commits into
masterfrom
claude/end-time-paths-879

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #879. Fixes #880.

Follow-up to #876, which ends a --test-time client at max(deadline, last reply), bounded by now. This PR fixes the paths #876 left out.

Problem

Change

Other behaviour changes

  • A client whose first connection completes only after the run is over sends no workload request (setup still goes out) and then ends. Having sent no workload, it is now a setup-only client (Setup-only cluster reconnects shorten partial-run duration and inflate rates #819/Exclude setup-only clients from final workload duration #821): it drops out of the duration average and Count. Before, it sent a request past the deadline and counted from the run's start to that reply. With one such client next to a normal one in a 3 s run, Total duration goes from about 3500 ms to 3000 ms and Ops/sec from 86 to 100.
  • A retried error reply no longer extends a client's end.
  • Setup and slot-map refreshes past the deadline are unchanged from master: a reconnect's AUTH, and a CLUSTER SLOTS retry that comes due at the deadline, still go out. Only new workload requests stop. A client past its deadline ends once its other connections are done (none with a reply pending, a reconnect due, a connect still in progress, or a setup step such as a slot map refresh that it can still send: not one held for an open MULTI, and none once the run is 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-timeout still bounds it sooner.
  • Why the end check lists sibling states (may_send_again()) instead of ending through finished(): once finished() 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 the finished() end only checks pending replies, so it would end a client while a sibling's reconnect or connect is still due.
  • A --test-time deadline that lands inside a --transaction MULTI, 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.

Scenario master this PR
Setup stall (#879) 4001, 4001; first SET after the reconnect at ~5.0 s 3000 ×3; no SET after the reconnect
Same, --max-reconnect-attempts=5 4020, 4000 3000 ×3
SIGINT during the idle after a late reply 3030, 3021 3542, 3540, 3540; Interrupted true on both
Late reply, then the reconnect is refused 3020, 3021 3540, 3522, 3540
Late reply, then the drain grace abandons 3030, 3030 3521, 3540, 3521; Unanswered 1 on both

Tests

  • New RLTest cases: 4 new cases in tests/test_answered_end_time.py fail 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_run covers 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.
  • Related suites: 309 cases at 281499f, 0 failed; the transaction, bad-reply and end-time suites were rerun at the head. That covers every 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 check passes 18/18.
  • Mutants: 12 of 13 are caught. Restoring the setup-done wait is caught by the held-refresh test. siblings_done() replaced by all_connections_idle() is caught by a unit case in reconnect_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 fresh now, which lands within the test's tolerance.
  • Perf: lab A/B on an idle Intel host against master: Ops/sec +0.02% at pipeline 1 and +0.06% at pipeline 16, within noise; instructions/op +0.42% and +0.14%. Measured at 359d882; later heads change only a bool in the per-request break and the done end, which is off the hot path.

Affected versions

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-time run 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-time behavior 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-error no 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.

…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]>
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

🤖 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 only_waiting classification in handle_end_stalled_clients() runs before abandon_unanswered_requests(), which can change that state. That's fine as written, but a short comment saying the order matters would help.

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 may_send_again() question answered before this merges.

(would file this as a comment, not a formal block)

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread shard_connection.cpp Resolved
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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread shard_connection.cpp Resolved
fcostaoliveira and others added 2 commits October 25, 2026 20:48
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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks, all four are addressed in 94e32f1.

  • siblings_done() vs all_connections_idle(): added test_deadline_end_waits_for_busy_sibling in tests/unit/reconnect_siblings_test.cpp (:182). It uses two_connection_client: one connection idle past the client's deadline, with finished() still false, and the other with a reconnect due. fill_pipeline() must not end the client while that reconnect is pending, and must end it at its deadline once the sibling is done. With siblings_done() replaced by all_connections_idle() at shard_connection.cpp:1999, the case fails, so that mutant is now killed.
  • Exclude setup-only clients from final workload duration #821: yes. process_first_request() only runs for a client with no reply and no submitted workload (shard_connection.cpp:2084). Before, past the deadline, it sent a request, which marked it as having submitted workload, so it counted in the duration average from the run's start to that reply. Now it sends nothing and stays setup-only, so it drops out of the average and Count. In a 3 s run where a second client's first AUTH is answered 1 s after the deadline, Total duration goes from 3501/3520 ms to 3000 ms and Ops/sec from 86 to 100; the exit code is unchanged. I added it to the release-note line.
  • m_claimed_by_retry ordering: there is now a comment at the call site (shard_connection.cpp:1752): it must follow handle_response(), which is where a retryable error claims the request.
  • Docstring: it now cites Cluster --transaction: CLUSTER SLOTS sent inside an open MULTI wedges the main connection #569 and --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 only.

🤖 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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Good catch, it was real, fixed in 114e79c. connect() clears m_reconnecting, and until BEV_EVENT_CONNECTED the sibling has no reply pending and nothing to replay, so siblings_done() returned true. I reproduced it with a scripted 2-node cluster: node B drops its connection at 1 s of a 3 s --rate-limiting run, and its accept queue is kept full until 3.5 s, so the redial is still connecting at the deadline. The idle connection ended the client at 3.0 s with rc 0, and the redial's rejected AUTH never went out. Master waits (no reply after the deadline means finished() stays false), connects at ~4.2 s and fails the run (#630).

siblings_done() now treats a sibling in conn_in_progress as busy (shard_connection.cpp:2471). If the connect never completes, the client ends exactly as on master: at --connection-timeout if set (~5 s with 2), or when the kernel gives up the SYN (~135 s on both). Total duration is 3000 ms either way, so there is no new hang. Covered by a new step in reconnect_siblings_test.cpp::test_deadline_end_waits_for_busy_sibling and by test_connection_setup_rejected.py::test_rejected_setup_after_slow_redial_past_deadline_fails_run. Both fail on 94e32f1 and pass now.

🤖 Generated with Claude Code

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread shard_connection.cpp Resolved
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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks, addressed in b5026bb.

  • README: the --test-time paragraph now says that a client whose first connection completes only after the deadline, and that never sent a request, doesn't count toward Total duration or Count at all, like a client that only ran its setup.
  • Slow-redial test timing: it's now peer-driven. Node B drops once it has answered a request and the first node has had 10 SETs. It is released only after the redial's slot map refresh has come and the deadline (first SET + --test-time) has passed with no SET for 0.3 s. release() closes only the fillers, by port, so memtier's own retried SYN is served, not reset. The test asserts that the drop, refresh and release happened as planned, so a missed window fails instead of passing vacuously. --test-time is 4 s, so the drop comes at least 1 s before the deadline. The SYN retransmit after the release is covered by a 35 s bound. Starved (nice 19 against 14 busy loops), it passes 10/10, in 6-14 s under RLTest and up to 23 s with a direct driver.
  • abandon_unanswered_requests(): confirmed, the fallback can't run. It returns early unless the duration is at least --test-time + the grace (client.cpp:447-449). For a client without an end time, that duration is now - start, or 0 if it has not started (run_stats.cpp:455-459). So at :473 it has started and now - start > --test-time, and test_time_end() (client.cpp:380, :384) returns true. The now fallback only guards a wall clock stepping back.

🤖 Generated with Claude Code

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread shard_connection.cpp Resolved
fcostaoliveira and others added 3 commits October 26, 2026 00:54
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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks, addressed in 7382810.

  • One predicate: done. shard_connection::may_send_again() (shard_connection.cpp:2469) is "this connection will still send something on its own", and siblings_done() is now "no other connection may send again"; end_client_after_run() uses the same check. Each clause names the path that sends: a pending reply (its handling runs fill_pipeline()), a due reconnect or a connect in progress (the setup ladder), a setup step fill_pipeline() will still send (not once finished(), not a refresh held for an open MULTI), and requests to replay on a live connection. It is deliberately not "can never send again": the --retry-on-error retry queue is left to the client's own holds_retries() check before the deadline end. The conditions are exactly those of the previous head, so there is no behaviour change and the unit tests are unchanged.
  • No-rate-limit path: added test_rejected_setup_after_slow_redial_without_rate_limit_fails_run and test_slow_redial_without_rate_limit_ends_once_set_up (peer-driven, as the rate-limited one). Without a rate, the idle connection is paused past its deadline while the redial connects. The redial then ends the client itself: its rejected AUTH fails the run, or once its accepted setup is done its own done check finds the paused connection idle and ends the client. It can't hang there because every state that keeps a sibling busy ends in a callback that runs that sibling's own done check or end_client_after_run(): a reply, the connect and setup reply, a failed connect, the deferred fill or the retry timer. The paused connection is never what ends it. Both pass here and on master, and 5/5 starved (nice 19 against 14 busy loops).
  • Release note: it's in the PR body ("…and that a client whose first connection completes only after a --test-time run is over no longer counts in Total duration or Count").
  • holds_retries(): now on connections_manager, so the cast is gone.

🤖 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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks, addressed in ff07182.

  • Blackholed redial: you were right, the tail was real.
    • Defaults: --connection-timeout defaults to 0 (off). --connection-stage-timeout (30 s) only polices startup and is disarmed once a thread reaches steady state. The drain grace skipped a client with nothing pending (the End a --test-time run whose server stops replying (10 s drain grace) #669 guard). So nothing bounded the wait.
    • Repro: a scripted two-node cluster, 3 s run. B's redial SYN is dropped (a full backlog-0 queue) and never let in. A goes away 1 s after the deadline, so the main connection's redial is refused and end_client_after_run() runs. Master ended at 4.0 s; d00f99a waited for the kernel's connect timeout and ended at 136 s. Both exit 0 with Total duration 3000 ms.
    • Fix: when end_client_after_run() defers to a busy sibling, it now marks the client (wait_for_siblings()), and the drain grace ends a marked client like one with replies pending. The run then ends at 14.4 s, still 3000 ms, with warning: 1 client(s) were still waiting for a connection to connect or set up 10 seconds after the test time ended.
    • Reconnect when AUTH/SELECT/HELLO fails on a reconnect instead of hanging #630: a redial that connects within the grace still sends its AUTH, so a rejection still fails the run, and the three slow-redial tests still pass.
    • Single endpoint: it has no siblings and is unchanged; End a --test-time run whose server stops replying (10 s drain grace) #669's guard test and test_test_time_stalled_server.py pass.
    • Test: test_blackholed_redial_is_ended_at_drain_grace fails on d00f99a (subprocess timeout at 50 s).
    • Unchanged: the case where A stays up and idle while B's redial is blackholed. It waits for the connect timeout on master too (135 s vs 137 s measured), since master's done end needs finished(); --connection-timeout bounds it on both.
  • Second look on cluster routing: agreed, that's worth having before merge. The new grace bound also caps any may_send_again() condition that stays true once a connection has tried to end the client.
  • Staircase finished(): no side effects. It reads m_reqs_processed, the config and gettimeofday() against benchmark_start_time (otherwise m_stats.get_duration()). The only override, verify_client::finished(), reads two members.
  • Count: excluding it is the consistent option. Since Setup-only cluster reconnects shorten partial-run duration and inflate rates #819/Exclude setup-only clients from final workload duration #821, a client counts once it has submitted workload. Setup-only cluster reconnects shorten partial-run duration and inflate rates #819's "kept at its deadline" covers a client that submitted workload and got no reply; one that sent nothing has no workload window to report.
  • Nit: widened to test_time + 6. That's the 8 s the other scripted tests use, and still under the drain grace, so a run that waits for the grace still fails. CI doesn't log this test's elapsed time on a pass: RLTest prints the name and [PASS] together after the test.

🤖 Generated with Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread shard_connection.cpp Resolved
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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks.

🤖 Generated with Claude Code

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks for the re-review.

🤖 Generated with Claude Code

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Owner review summary for 2d91921: ready to merge.

  • Review: 7 lenses (SEM, OUT, TEST, BUILD, LIFE, INTER, MAINT) all APPROVE at 2d91921 after 13 rounds. Every new head got a 6-lens delta recheck, and BUILD ran on the final CI.
  • CI: 145 passed, 6 skipped (label- or release-gated), 0 failed. Sanitizers are clean. No job is more than +1.6 min slower than on master.
  • Tests: the new end-time, blackholed-redial and slow-redial RLTests pass in all 14 inspected cells (plain, ASAN, TSAN, UBSan, coverage), and reconnect_siblings_test passes in the coverage jobs. The blackholed cases take about 15 s against a 50 s timeout.
  • Bugbot: success on 2d91921. All 5 threads are answered and resolved.
  • Auto-review: answered in my last reply (split, may_send_again() versus finished(), has_submitted_workload()); the PR body has the design note.
  • Follow-ups (not blocking):
    • unit-table coverage for idle_connection_waits_for_connect();
    • a comment on the only_waiting ordering;
    • the case where every connection is still connecting with none up keeps the kernel connect timeout, as on master.
  • Release notes: a client whose first connection completes after the --test-time deadline no longer counts toward Total duration/Count.

Fixes #879, fixes #880.

🤖 Generated with Claude Code

@fcostaoliveira
fcostaoliveira merged commit 381e995 into master Oct 26, 2026
151 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant