Repository navigation
End a --test-time run at its deadline while reconnecting to a dead server - #666
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The core fix for #656 is real: a
Nitpicking: the test helpers set I think the core fix is solid. I'd mainly like answers on the exit-code compatibility (1) and the coupling between the two flags (2) before this merges. Since this touches cluster reconnects, it may be worth a second look from whoever owns cluster routing. |
93c051e to
5f95ad7
Compare
|
Thanks for the first-pass review. Point by point:
Also in 5f95ad7: Bugbot's stale-duration finding (inline reply). The synchronous |
5f95ad7 to
f189250
Compare
|
Rebased onto master cf5753f (f189250). The A correction to point 1 of my earlier reply: a server that is gone before the first reply is not retried indefinitely. The |
f189250 to
1d0b93c
Compare
|
Replying to the current version of the first-pass review. I pushed c6e43b0, rebased onto master 0062e56.
Nit: done. The comment on Other changes in this push, from review:
|
5bad025 to
13b0995
Compare
|
Pushed 13b0995, rebased onto master 1d13ff5 (#661, #694). I resolved the
Local checks: all of |
13b0995 to
c2c86b5
Compare
|
Replying to the review as edited at 10:43. I pushed c2c86b5, rebased onto master 8f5fa34 (#669).
Also in this push:
Local checks:
|
c2c86b5 to
b28ac5a
Compare
|
Pushed b28ac5a, on master 971776c (#667). I squashed the branch into one commit because rebasing the old series onto #667 conflicted at every step.
Local checks: |
b28ac5a to
692186c
Compare
Over TLS a refused connect logs "TLS connection error: (null)" rather than "Connection error: ", so the mixed test counted 0 logged errors and failed in the TLS CI cells. Count the "attempting reconnection" and "Maximum reconnection attempts" lines instead: attempt_reconnect() logs exactly one of them for each error it counts, on every transport. Run the dead-server tests with the TLS args too. Bound the count from above (clients x (1 + attempts), or the logged count plus one per client for the Ctrl+C run) and check that every Time-Serie second is within the run, so merging the epoch-keyed buckets of a never-started client again is caught. Give the mixed run an 8 s --test-time, so client 0's last dial at 6 s happens before the deadline also when reconnects stop at the deadline (#666), and expect the run to last at least 5 s: it ends when that dial fails, and averaging in client 0's zero timestamps halves it to 3 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
692186c to
f496ced
Compare
|
Replying to the first-pass review as rewritten at 12:10. The new head is f496ced. It also fixes both Bugbot findings; I replied to those inline.
|
Over TLS a refused connect logs "TLS connection error: (null)" rather than "Connection error: ", so the mixed test counted 0 logged errors and failed in the TLS CI cells. Count the "attempting reconnection" and "Maximum reconnection attempts" lines instead: attempt_reconnect() logs exactly one of them for each error it counts, on every transport. Run the dead-server tests with the TLS args too. Bound the count from above (clients x (1 + attempts), or the logged count plus one per client for the Ctrl+C run) and check that every Time-Serie second is within the run, so merging the epoch-keyed buckets of a never-started client again is caught. Give the mixed run an 8 s --test-time, so client 0's last dial at 6 s happens before the deadline also when reconnects stop at the deadline (#666), and expect the run to last at least 5 s: it ends when that dial fails, and averaging in client 0's zero timestamps halves it to 3 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
6831520 to
9718017
Compare
…rver With --reconnect-on-error and unlimited --max-reconnect-attempts (the default), a server that goes away for good kept a --test-time run reconnecting forever, with no report: the reconnect path never checked whether the run was over, and finished() is otherwise only checked when requests are sent or answered. A reconnect armed before the deadline also waited out its full backoff (up to 60 s) and the report counted that dead time. With unlimited attempts: - run_deadline() / run_is_over(): the stop condition in one place. A started client is timed from its own start, also on the wall clock (within 1 ms counts as passed); a client that never started, once any connection reached steady state, from the benchmark's start (#667's contract, which this extends). - next_reconnect_delay() caps the armed delay at the time left, on a local copy, so the backoff schedule is unchanged. - stop_reconnecting_if_run_over(): when a connect fails and the run is over, stop reconnecting; a started client's stats end at the deadline, so the duration and throughput reflect --test-time (exit 0). - A setup rejected since the connection's last workload reply (any reply, errors included) still fails the run (#630), also when the server then goes away. - A client whose first connection completes only after the run is over is timed from the benchmark's start, so it ends at its first reply. - A drop of an established connection after the run is over gets one reconnect, so held replays are resent; a second drop counts as a failed connect (a peer that accepts and closes would otherwise loop at 0 s). - The client is ended only once its other connections are done too (siblings_done()), e.g. another cluster shard with a reconnect pending; a failed run is recorded on the client (fail_run()) so a sibling's later normal end still fails it. With a finite --max-reconnect-attempts nothing changes: the attempts bound the run at their usual backoff, and running out of them fails it (exit 1), as before. Also: failed reconnects that never reach the event loop (unix socket), and failed cluster dials after the run is over, are counted as connection errors (count_connection_error()); with --requests and unlimited attempts, memtier warns once per process, after 10 failed attempts, that the server is still unreachable; a cluster dial that fails after the run is over leaves the connection dead instead of ending the client inside the CLUSTER SLOTS handler. README, --help and the man page document the behaviour; tests in test_reconnections.py and tests/unit/reconnect_siblings_test.cpp cover it. Fixes #656 Co-Authored-By: Claude Opus 5.5 <[email protected]>
8b58d15 to
9d78591
Compare
|
Replying to the review as edited at 02:49. I pushed 9d78591, on master 3fcbfbc (#757, #761).
Also in this push:
Local checks:
|
|
Replying to the review as edited at 2026-10-17 03:44:00Z. Pushed 705b429 as a normal fast-forward on 9d78591. (2) Bounded runs: done. For a started client, (3) TLS kills and the narrowed accounting test: yes, this is a deliberate user-visible behavior change. A client that never completed a request makes that run invalid. It must not silently contribute no work while other clients determine the result. The previous owner's experiment with CLIENT KILL every 10 ms and The final replica compatibility pass is also included:
Validation on the final delta:
I also trimmed the obsolete rebase-by-rebase validation history in the PR description while keeping the before/after table and compatibility decisions. CI and an independent focused recheck of this delta are still required before merge. |
|
On the latest review:
An independent recheck now covers AUTH, SELECT and HELLO rejection for both modes: all 18 cases passed; preferred replicas stayed closed across 730–2194 topology refreshes with exit 0/no redials/zero Connection Errors; required replicas exited 1.
The squash message will describe final behavior rather than the intermediate owner-commit history. |
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 705b429. Configure here.
|
Replying to the review edited at 2026-10-17 05:16:21Z. Pushed d7f430f, a README-only clarification; the reviewed implementation remains ee56133. 1. Replica setup policy. I considered both alternatives. Applying the optional-replica rule without You are right that 2. Partial thread success was considered and ruled out. Counting an entirely never-started client as an error but returning success when any sibling did work would accept a different workload from the one requested. For example, The 4/9 TLS-chaos result is therefore not a promise of a constant exit code under scheduler-dependent CLIENT KILL timing. Different kills can prevent a client from ever receiving a reply, or allow all clients to start. The run fails in the former case; other successful clients do not override it. Master obtained success by allowing runs to continue well past their deadlines. The separate never-started-client tests pin the chosen failure rule; the narrowed Connection Errors/sec test measures accounting after clients have actually started. The README now explicitly includes repeated TLS-handshake failures and says that work by other clients on the thread does not turn that run into success. 4. Confirmed. The shared normal/deadline/drain completion scan can set For the nonblocking state-refactor suggestion, I am keeping the existing flags in this change: the recorded failed-connect/drop history, persistent setup failure since the last reply, and one-time slot-refresh retry have different lifetimes. No C++ or test code changed in this documentation pass. |
|
Thanks; I re-read the updated review. The compatibility alternatives were considered, not just documented:
The helper setter and commit-body suggestions are nonblocking. No runtime change was made in response to this latest comment; d7f430f only documents the selected policies. |
With --reconnect-on-error, a --test-time client that had sent workload but never got a reply had its end time stamped at "now" by client::set_end_time(): when its reconnect after the deadline completed, or when its thread ended. Such a client takes part in the run's duration average (#821), so Total duration came out above --test-time and Ops/sec was deflated. With one client served normally and one whose SET was held past a 4 s deadline, the run reported about 5000 ms and 80 ops/sec (5500 ms and 73 with --max-reconnect-attempts=5) instead of 4000 ms and 100. Cap such a client's end at its own start plus --test-time once that is past, as Ctrl+C after the deadline already does (#747). It uses the client's own start, not run_deadline(), which times an unanswered client from the benchmark's start and would inflate Ops/sec for a client that started late. A client with replies still ends at "now", since that time can cover replies it drained after the deadline (#870 tracks the gap for a client whose last reply came before the deadline). A client that never submitted stays out of the average, and --requests runs have no deadline. end_client_after_run() keeps leaving such a client unended when its server is gone after the deadline, so that run still fails (#666). test_unanswered_end_time.py runs the scenario against a scripted peer, standalone and in cluster mode, with unlimited and finite reconnect attempts. It adds a late-started client, a client whose drained reply is counted, and a client that gives up before the deadline. Fixes #867 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er the deadline (#876) With --reconnect-on-error, a --test-time client that got replies, all before its deadline, and then stalled had its end time stamped at "now" by client::set_end_time() when its reconnect after the deadline completed. #869 capped this only for a client that never had a reply. With one client served normally and one answered 20 times and then held past a 4 s deadline, the run reported about 5100 ms and 82 ops/sec (5600 ms and 75 with --max-reconnect-attempts=5) instead of 4000 ms. Record when each client's last reply was read, from the timestamp process_response() already takes, so a reply costs no extra clock read. Once a client's own start plus --test-time is past, end it at that deadline or at its last reply, whichever is later, and no later than now. Replies drained after the deadline still count, but the idle time after them does not. In cluster mode the last reply is per client, whichever shard it came on, and setup replies do not count. This applies to every answered client past its deadline, so a rate-limited client that ends on a timer tick after it no longer counts that gap. end_client_after_run() is unchanged, so a run whose server is gone after the deadline still fails (#666). test_answered_end_time.py runs the stalled client against a scripted peer, standalone and with two cluster shards, with unlimited and finite reconnect attempts; a client answered past the deadline that then idles; and a cluster client answered late on one shard while the other shard's reconnect setup is held. test_run_count_partial_ranking.py now expects a run whose worker drops after its deadline to end at the deadline. Not covered: a stalled reconnect setup can still let new requests go out past the deadline (#879), and the interrupt, dead-server and drain-grace end paths still cap at the deadline (#880). Fixes #870 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>

Decisions (issue #656 asked "is this intended?"): with
--reconnect-on-error:--test-time, unlimited attempts (the default): the deadline wins. Once the run has started and the deadline has passed, a failed connect is not retried. The client ends as it does when the deadline passes with all connections up: the report is printed, the exit code is 0, and the connection errors are in the report.--test-time, finite--max-reconnect-attempts: unchanged from master. The deadline logic in this PR (capped delays, stopping at the deadline) applies only with unlimited attempts. A bounded run keeps its backoff schedule; it fails (exit 1) when its attempts run out, and ends normally when the server comes back in time, around the deadline included. This is the compatible option asked for in review: an earlier round failed bounded runs at the deadline, which also failed runs that recover (a node failing over or restarting around the deadline). For a started client,run_is_over()adds its wall-clock check only whenstops_at_deadline()holds. Never-started clients retain master's benchmark-deadline rule (Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging #667).--requests, unlimited attempts: the run keeps waiting for the server, which is what "unlimited" means, and this is now documented. memtier warns once, after 10 failed attempts, that the server is still unreachable.reconnect()never reaches the event loop, so it was not counted. It is now counted (1 drop + N failed connects), the same as TCP. Tests pin it for both transports.Release notes
--reconnect-on-errorand unlimited--max-reconnect-attempts(the default), a--test-timerun that has started ends at its deadline (exit 0, with its report) while its server is down, instead of reconnecting forever.--max-reconnect-attemptsnothing changes: the attempts bound the run at their usual backoff, and running out of them fails it (exit 1).Problem
With
--reconnect-on-errorand the default--max-reconnect-attempts 0, a server that goes away for good kept a--test-time 5run reconnecting once a second, forever, with no report. On master 0298524 it was at 380% when I killed it after 19 s.A later review found a related overshoot. The deadline was only checked when a reconnect failed. A reconnect armed just before the deadline still waited out its full backoff delay (capped at
MEMTIER_BACKOFF_CAP_SEC, 60 s). The run ended at that failed attempt, and the report counted the dead time. For example,--test-time 4 --reconnect-backoff-factor 20with the server killed at 1.5 s exited after 22 s and reportedTotal duration21831 ms and 20 ops/sec instead of ~114.Root cause
attempt_reconnect()and the retry branch ofhandle_reconnect_timer_event()reschedule the reconnect whenever attempts are unlimited. They never check whether the run is over, and they arm the timer for the full backoff delay.finished()(--test-time,--requests) is otherwise checked only when requests are sent or answered. That never happens again on a connection that cannot connect.Fix (all in the reconnect path)
run_deadline()/run_is_over()compute the stop condition in one place.benchmark_start_time. This is a client whose connection was up but never answered while another client's was, so--connection-stage-timeoutis already disarmed. Deduped against Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging #667, now on master: this PR uses master'sconnection_stage_steady_state_reached()and unit-test stubs. It replaces Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging #667'srun_is_over()with a superset that keeps Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging #667's contract for its callers: a never-started client is timed frombenchmark_start_time(full timeval), and a started client is over onfinished()or, with unlimited reconnects only, once its own wall-clock deadline has passed (finished()only moves with stats updates).test_cluster_slots_bad_reply.pypasses 16/16.next_reconnect_delay()(unlimited attempts only) caps the delay the reconnect timer is armed with at the time left before the deadline (within 1 ms counts as passed, so a timer firing a hair early by the wall clock does not re-arm near-zero delays). The cap applies to a local copy, som_current_backoff_delayand the backoff schedule are unchanged.stop_reconnecting_if_run_over()runs when a connect fails: inattempt_reconnect(), in the synchronousreconnect() < 0branch, and before reconnecting in the timer. If the run is over, it disconnects the connection. If no replies are pending, it ends a started client's stats at the deadline, not at the failed attempt, soTotal durationand ops/sec reflect--test-time, and callsdisconnect_all(). That counts any requests held for replay as errors.m_connect_failedrecords whether the error arrived before the connection was established, orreconnect()failed. It is cleared when a connection is established.CLIENT KILLloop) still gets the held requests resent.m_dropped_after_run_over) counts as a failed connect and ends the run. Without it, a peer that accepts and then closes every connection (a proxy with a dead backend, a TLS terminator, maxclients) with--retry-on-errorwas reconnected with zero delay forever, at 100% CPU and with no report.--test-time(in the README).m_reconnect_attempts == 0"first reconnect" rule, which was unreliable because the counter is reset only on a reply.process_first_request()), so it ends at its first reply instead of running a whole--test-timeafter the deadline, and the run ends normally.end_client_after_run(), which ends the client only if no other connection (e.g. another cluster shard) has a reply pending, a reconnect pending, or requests held for replay on a live connection (siblings_done()). A failed run is recorded on the client (client::fail_run()), so a busy sibling's later normal end still fails it. Pinned bytests/unit/reconnect_siblings_test.cpp: a sibling with a reconnect pending, and a connecting sibling holding requests for replay, each keep the client going (fails if the guard is reverted toall_connections_idle()or dropped, or if the replay check is removed).count_connection_error(): every dropped connection and failed connect, including the synchronousreconnect() < 0one, counts as a connection error in one place.--read-preference primaryis closed and left closed with--reconnect-on-errortoo, as End a run whose connection setup is rejected instead of hanging (cluster replicas, failover, standalone) #750 does without it. With--reconnect-on-error,secondaryPreferrednow applies the same rule because its reads fall back to the primary. Without reconnect,secondaryPreferredretains End a run whose connection setup is rejected instead of hanging (cluster replicas, failover, standalone) #750's behavior. Asecondaryreplica remains required: an unrecovered setup rejection fails the run, even if a sibling ends the client first. Redialed instead, it was rejected about once a second, and its retry, due at the deadline, then failed a run the primaries served in full (rc 1 on a 3+3 cluster withrequirepassonly on the primaries; master rc 0).warn_reconnecting_indefinitely(): with unlimited attempts and--requests, memtier warns once per process (also across--run-countruns), after the first connection reaches 10 failed attempts:warning: server still unreachable after N reconnection attempts; ....A server that is dead from the start is not this PR's deadline case.
--test-timeis measured from the start of the run, which never starts. That startup phase is bounded by the--connection-stage-timeoutsupervisor (#426): exit 2 once it expires (30 s by default). This PR leaves that unchanged and adds a test that pins it.Interaction with #669 (10 s drain grace, now on master): the two compose. #669 ends a client that still has replies pending 10 s after the deadline; this PR ends a client whose connection is down, at the deadline.
test_test_time_reconnecting_client_left_aloneused to expect a 15 s backoff to run past the grace period; the reconnect is now due at the deadline, so it asserts the run ends before the grace period. That test no longer reaches the grace window, so #669's idle-client guard (if (all_connections_idle()) return 0;inabandon_unanswered_requests()) is now covered bytest_reconnect_hanging_past_drain_grace_is_left_to_connection_timeout. An accept-and-hold peer (accepts, never replies) with--retry-on-errorends through #669's grace: exit 0 at about--test-time+ 10 s.Relationship to #657 (a server that stops replying after the deadline, fixed separately in the drain code): both are runs that never end. In #657 the connection stays up with replies pending; here the connection cannot connect.
Test evidence
New tests in
tests/test_reconnections.py. They run memtier through an in-test proxy (TCP, or a unix socket under--unix) and stop it mid-run. The tests are skipped on cluster envs.test_server_gone_unlimited_reconnects_honor_test_time--test-time+ 5 s, the report, no--requestswarning after more than 10 attempts (fails if it warns without--requests, M11), Connection Errors ≥ 4 (failed connects counted)test_server_gone_long_backoff_ends_at_test_time--reconnect-backoff-factor=20: wall time <--test-time+ 3 s, JSONTotal durationwithin [−100, +500] ms of--test-timetest_server_gone_never_started_client_ends_at_test_time-t2 -c1and-t1 -c2, proxy forwards only the first connection: the never-started client stops too, exit 1test_accept_then_close_peer_with_retry_on_error_ends_at_test_time--retry-on-error: exit 0 within--test-time+ 4 s, with the reporttest_reconnect_hanging_past_drain_grace_is_left_to_connection_timeout--connection-timeout=12, past the 10 s grace: no "got no reply" stall, the timed-out connect ends the run with exit 0,Total duration≈--test-time. Fails with #669's idle-client guard removed (G1)test_live_server_drop_after_deadline_resends_held_requests--retry-on-error: reconnected, no "run is over", no abandoned replays, exit 0. Fails with the!m_connect_failedgate removed (M5) or the flag forced true (M5b)test_cluster_slots_bad_reply.py::test_cluster_slots_empty_reply_then_node_gone_ends_at_test_timetest_cluster_slots_bad_reply.py::test_cluster_slots_one_empty_reply_at_deadline_is_retriedmoved_after2300 and 2700,--test-time=3 --rate-limiting=1000): exit 0, no "Connection setup failed and the run is over"test_cluster_slots_bad_reply.py::test_cluster_slots_never_started_client_fails_at_deadline--test-time+ 2 stest_cluster_slots_bad_reply.py::test_rejected_auth_once_at_deadline_fails_the_runm_slots_rejected = true(exit 0)test_never_started_client_dropped_after_deadline_does_not_restartTotal duration≥--test-time− 100 ms (the late client is timed from the run's start). Under TLS the held connection never completes its handshake, so its drop is a failed connect and the run fails (exit 1, asserted)set_start_time_at()branch disabled (1501 ms)test_never_started_client_dropped_before_deadline_does_not_restart--test-time+ 2 s and the same duration check (TLS: exit 1, as above)test_connection_setup_rejected.py::test_replica_rejecting_auth_with_reconnect_is_closed_not_redialed--read-preference primary,--reconnect-on-errorunlimited and--max-reconnect-attempts=50,--test-time 2: exit 0, one "closing it" per connection, no redials, 2 AUTH attempts at the replica, 0 Connection Errorstest_server_gone_bounded_reconnects_fail_as_before--max-reconnect-attempts=6and=1, server gone for good: exit 1 with "Maximum reconnection attempts (N) exceeded", no "run is over", Connection Errors ≤ 2×(N+2)test_server_restarting_around_deadline_bounded_ends_normally--max-reconnect-attempts=10, server down at 5.3 s and back at 6.8 s,--test-time 6: exit 0test_setup_recovered_then_server_gone_ends_normallytest_setup_rejected_then_server_gone_fails_the_runtest_server_gone_unlimited_reconnects_warn_with_requests-n 1000000: still waiting, and the 10-attempt warning (backoff factor 0.7 with the 0.1 s floor: the 10 attempts take about 2.5 s, so the warning shows about 4.5 s in; the test waits 8 s, plus 5 s under sanitizers, instead of 18 s)test_server_gone_before_start_..._end_at_stage_timeout--connection-stage-timeout, and--test-timedid not end it (fails with the steady-state gate removed, M6b)9d78591:make check13/13, reconnections 31/31, setup rejection 12/12, cluster-slot errors 20/20, retry-on-error 28/28, run-count exit codes 9/9, JSON output integrity 25/25, and an oss-cluster subset 21/21. Earlier revisions also passed the reconnection suite under TLS; see the review comments for the full historical evidence.make check13/13; both new replica regressions 10/10; setup-rejection and cluster-slot suites 34/34, focused bounded/rejected/recovered/startup reconnect cases 5/5.--test-time 4 --reconnect-backoff-factor 20exited 0 after 5.0 s withTotal duration4000 ms (before: 22 s, 21558 ms). No CI cell runs--unixyet (follow-up CI: run the RLTest suites over a unix socket (--unix) #726).Fixes #656
Test hardened for this PR
test_json_output_integrity.py::test_json_aggregated_connection_errors_seckilled every normal client every 0.25 s. Under TLS its kills could land on all of a client's connections during their handshakes, so that client never got a reply. This PR (correctly) fails a run with a client that never ran, so that run exited 1. The test is about Connection Errors/sec, not that rule: its kill loop now only kills connections that have served a workload command (cmdget/set). Its assertions are unchanged. Measured: 12/12 under--tls, 10/10 under--tlswithtaskset -c 2, 5/5 plain.Merge-order notes
tests/unit/reconnect_siblings_test.cpphas theint failure_exit_code() { return 1; }stub.reconnect_after_setup_error(const char *, bool setup_step)keeps this PR's--reconnect-on-errorbranch, thenreturn, then End a run whose connection setup is rejected instead of hanging (cluster replicas, failover, standalone) #750's replica-close and steady-stateend_thread()branches; End a run whose connection setup is rejected instead of hanging (cluster replicas, failover, standalone) #750'scount_connection_error()/disconnect_after_error()/end_thread()helpers are used, with onecount_connection_error(); the_Nodeconstructor parameters are the union.Final owner pass
secondaryPreferred+ a rejecting replica +--reconnect-on-error: exit 0 in 10/10 runs, exactly one close per replica connection, no redials, and zero Connection Errors. The previous owner reproduction was nondeterministic (exit codes 1, 0, 1, 0, 1).secondary+ a rejecting replica: exit 1 in 10/10 runs. The client checks unrecovered setup rejections when a sibling ends it, so scheduling no longer decides the result for unlimited reconnects.--tls --run-count 3 --test-time 2returned exit 1 in 4/9 runs in 14–15 s on this PR; master returned exit 0 in 21–26 s, overshooting every deadline. The failure policy is intentional. The Connection Errors/sec test only kills connections that have served GET/SET so it measures that rate; the never-started-client tests independently pin the failure policy.Final deadline and drain correction
Required-replica setup failures now pass through one completion helper for normal, deadline and drain-grace endings. A deterministic fixture covers primary/secondaryPreferred/secondary across all three routes. Independent scripted-peer reproduction: an unrecovered required replica plus a stalled primary incorrectly returned 0 before the drain correction and returns 1 afterward (~13 seconds in both). Final validation: unit 13/13, setup/reconnect 16/16, drain 5/5. README-only d7f430f adds the explicit compatibility policies; runtime code remains ee56133.
Affected versions
2.3.0 through 2.5.2 (latest) and master.
--reconnect-on-errorwith unlimited attempts as the default. The first tag that contains it is 2.3.0.🤖 Generated with Claude Code
Note
High Risk
Touches core reconnect, deadline, cluster multi-shard teardown, and exit-code paths; mis-coordination could hang runs, end early, or mis-report failures.
Overview
With
--reconnect-on-errorand unlimited--max-reconnect-attempts, a--test-timerun that has started now stops reconnecting at the deadline, prints its report (exit 0), and caps stats duration at--test-timeinstead of retrying forever or waiting out full backoff past the deadline. Reconnect delays are capped to time left before the deadline; failed connects after the run ends are no longer retried, while one post-deadline reconnect remains for a dropped live connection so held requests can replay.shard_connectioncentralizes deadline/stop logic (run_deadline,run_is_over,stop_reconnecting_if_run_over,siblings_done/end_client_after_run) so multi-connection clients are not torn down while a sibling still has a pending reconnect or replay queue. Setup rejections (AUTH/SELECT/HELLO) since the last workload reply still fail the run (#630); optional replicas underprimaryorsecondaryPreferred+ reconnect are closed without endless redials. Unix-socket failed dials inreconnect()now count as connection errors like TCP. Finite--max-reconnect-attemptsbehavior is unchanged.Docs (README, man page) describe the policy;
memtier_benchmarkthreads reportcount_failed_clients(); cluster shard dials after the run leave the connection dead instead of ending the whole client mid–CLUSTER SLOTS. Addedreconnect_siblings_testand broad integration tests (proxy fixtures, cluster slots, setup rejection).Reviewed by Cursor Bugbot for commit d7f430f. Bugbot is set up for automated code reviews on this repo. Configure here.