Skip to content

Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging - #667

Merged
fcostaoliveira merged 11 commits into
masterfrom
fix/cluster-slots-empty-reply
Oct 16, 2026
Merged

fcostaoliveira merged 11 commits into
masterfrom
fix/cluster-slots-empty-reply

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Decision for review: what happens after a CLUSTER SLOTS reply that is empty, an error, or has only malformed shards. Before this PR, the connection that got it went silent and the run hung.

when --reconnect-on-error behaviour
any time yes reconnect, as for a rejected AUTH/SELECT/HELLO since #630. Bounded by --max-reconnect-attempts; stops once the run is over. For a client that never got a reply while others did, "over" means the run's --test-time deadline
mid-run (this client had a reply) no handled like a dropped connection: the thread ends and the run fails (exit 1), logging "CLUSTER SLOTS error and --reconnect-on-error is not set, ending this thread."
startup (this client has had no reply yet) no resend CLUSTER SLOTS every second. The waiting time is not charged to --test-time or to ops/sec. Bounded by --connection-stage-timeout (default 30 s, exit 2) while no connection of the run has reached steady state; after that, by the run's --test-time deadline (then the thread ends as mid-run, also when the deadline passes while the retry is pending, e.g. a late --clients-start client). Under --requests there is no deadline, so once another connection is running the first failure ends the thread (see #693)

--connection-stage-timeout is disarmed for the whole run as soon as any connection reaches steady state, so a client still retrying after that needs another bound: the run's --test-time deadline.

With --connection-stage-timeout=0, startup retries go on every second until the node answers. The run logs every attempt, and --help now says so. Before this PR, the same setup hung silently after the first attempt.

Problem

In --cluster-mode, the connection that gets one of these CLUSTER SLOTS replies stops sending anything:

If this happens on a mid-run refresh (after a -MOVED), the run hangs past --test-time and --requests, even with --reconnect-on-error. At startup, memtier asks only once.

Root cause

Both branches of the rt_cluster_slots case in shard_connection::process_response() left m_cluster_slots at setup_sent:

As a result:

  • is_conn_setup_done() stayed false, so fill_pipeline() sent nothing more.
  • set_cluster_slots() refused to queue another refresh.
  • Nothing called disconnect().
  • Mid-run, report_connection_stage_failure() is a no-op, so nothing bounded the stall.

Fix

Both branches call retry_cluster_slots_after_error(), which applies the table above. The empty/error branch also clears keep_value first.

  • With --reconnect-on-error, it calls reconnect_after_setup_error().
  • Mid-run without the flag, it calls attempt_reconnect(). Without the flag that function ends the thread, as it does for a dropped connection. It does the same for a client with no reply yet once run_is_over() (the run's deadline passed after another connection reached steady state, new connection_stage_steady_state_reached()), or, under --requests, as soon as another connection reached steady state.
  • At startup, it arms a dedicated m_cluster_slots_retry_timer for 1 s, and m_cluster_slots stays setup_sent while it waits, so nothing resends the request early. When the timer fires:
    • it sets setup_none;
    • if nothing has been answered yet, it resets the run's start time (set_start_time(), as process_first_request() does on connect);
    • it calls fill_pipeline().
  • disconnect() cancels the timer, and the destructor frees it. If event_new fails, it logs and breaks the event loop, as attempt_reconnect() does.
  • handle_reconnect_timer_event() stops retrying a rejected setup once run_is_over(): the client's own --test-time once it has started, or, for a client that never started while others did, the run's --test-time deadline (from benchmark_start_time). While no connection has reached steady state, --connection-stage-timeout still decides (exit 2), not the deadline.

Commits

  1. Retry after an empty or error reply (Cluster: an empty or -ERR CLUSTER SLOTS reply leaves the connection stuck; mid-run the process hangs, ignoring --test-time #648).
  2. Retry after an all-malformed reply (Cluster: a CLUSTER SLOTS reply whose shard entries are all malformed leaves the connection stuck; mid-run the process hangs, ignoring --test-time #670). Renames the test file to tests/test_cluster_slots_bad_reply.py.
  3. Don't advance the run's clock before the first reply. This fixed the test_426_2_cluster_mode_against_standalone failure in the sanitizer TLS cells.
  4. Review fixes:
    • Startup retry time is no longer charged to the run (it was a BLOCK).
    • A mid-run failure without reconnect now fails the run instead of retrying, which removes the endless retry with --requests and the exit 0 past the deadline.
    • The retry uses a dedicated timer instead of m_deferred_fill_timer.
    • The --help text for --connection-stage-timeout=0 is updated.
  5. Review follow-ups:
    • Without --reconnect-on-error, attempt_reconnect() no longer says "Maximum reconnection attempts (0) exceeded for ...", since no reconnection was enabled. It now says "<error> and --reconnect-on-error is not set, ending this thread." This applies to a dropped connection too. The message with --reconnect-on-error is unchanged, and no existing test matches the old wording without the flag.
    • New test for the --read-preference != primary branch of attempt_reconnect() (a peer still in setup), so a connection whose CLUSTER SLOTS failed is shown not to stall the run.
    • Corrected the comment of test_cluster_slots_empty_reply_at_startup_still_aborts, and documented why the empty/error branch clears keep_value.
  6. Second review round:
    • With more than one client, a client stuck on a bad CLUSTER SLOTS while another was running retried forever, and the run never ended (with or without --reconnect-on-error, even with --connection-stage-timeout=5). Startup retries now stop once any connection reached steady state, and a never-started client stops reconnecting at the run's deadline.
    • event_new failure in the retry path is logged and breaks the loop.
    • Stale comment in the malformed-reply branch updated; replica-branch message reworded to "<reason>; leaving conn N dead and continuing while peers are still mid-setup."; test time bounds widened to < 10 s (master hangs until the 20 s kill).
  7. Third review round: commit 6 ended a client's thread on one transient *0 (no --reconnect-on-error) once any other connection was running. A client with no reply yet now keeps the 1 s retry until the run's deadline. New tests: one transient *0 for a second client completes with rc 0, and a rejected AUTH at startup with --reconnect-on-error --test-time=1 --connection-stage-timeout=5 still exits 2 at the stage timeout (it kills the mutant that drops the steady-state check from run_is_over()).
  8. Fourth review round: under --clients-start, client::finished() uses the run's deadline, so a late client whose CLUSTER SLOTS kept failing had its retry fire after the deadline, sent nothing, and the run exited 0 with one client's throughput. The retry timer now ends the thread (via attempt_reconnect()) when it fires after the run is over for a client that never had a reply. New tests: that staircase case, and --requests with a second client that never gets a map (ends the thread at once; kills the mutant that drops the --requests clause, which hangs).
  9. Fifth review round:
    • run_is_over() compares full timevals (whole seconds ended a waiting client up to 1 s early).
    • Under --clients-start, client::finished() still compares whole seconds, so it can be true up to 1 s before run_is_over(); a retry firing in that window let a late client without a slot map count as done and the run exit 0. The retry now also fails such a client when finished() is already true (once another connection reached steady state). New test starts the run 0.9 s into a second so the retries land in that window (failed 8 of 8 runs at a901388).
    • Unit-test stub for connection_stage_steady_state_reached().
    • --help: "0 disables the supervisor (at startup, a failed CLUSTER SLOTS is then retried every second)."

Test evidence

tests/test_cluster_slots_bad_reply.py has 16 tests. It uses a scripted RESP peer (one node, plus a replica node for one test), in the same style as test_cluster_slots_refresh_overlap.py.

test origin/master previous head 6befb49 this PR
empty reply mid-run, recovers (--reconnect-on-error --requests) FAIL PASS PASS
empty reply mid-run forever, no reconnect: fails (rc != 0) in < 10 s with --test-time=3 FAIL (hang) FAIL (rc 0, ~4 s) PASS
*0 forever mid-run, --reconnect-on-error --test-time=2 ends FAIL PASS PASS
-ERR ×2 at startup, then the full --test-time=2 run (elapsed ≥ 3.5 s, ≥ 1000 requests) FAIL FAIL (retries eat the run) PASS
malformed (slot 16384) mid-run, recovers FAIL PASS PASS
malformed (node without port) ×2 at startup, then the full run FAIL FAIL PASS
malformed forever mid-run, --reconnect-on-error --test-time=2 ends FAIL PASS PASS
*0 forever at startup, --test-time=1 --connection-stage-timeout=5 exits 2 FAIL (only 1 CLUSTER SLOTS) PASS PASS
*0 forever mid-run, --read-preference=secondary, replica READONLY delayed 1 s: fails (rc != 0) in < 10 s with --test-time=5 FAIL (hang, killed at 20 s) n/a (asserts the new message) PASS
first CLUSTER SLOTS good, then *0 forever, -c2 -t1 --test-time=2, no reconnect: fails (rc != 0) in < 10 s FAIL (hang) FAIL (hang, killed at 20 s) PASS
same, -c1 -t2 --reconnect-on-error --test-time=2: stops reconnecting at the deadline, rc != 0 in < 10 s FAIL (hang) FAIL (reconnects forever, killed at 20 s) PASS
first CLUSTER SLOTS good, the second *0 after 0.5 s, then good; -c2 -t1 --test-time=3, no reconnect: rc 0, 3 CLUSTER SLOTS FAIL (stuck client) PASS at 57662b9; FAIL (rc 1, "ending this thread") at 6766df8 PASS
standalone, AUTH rejected (-a wrongpw), --reconnect-on-error --test-time=1 --connection-stage-timeout=5: exit 2 after ≥ 4 s n/a PASS PASS (mutant without the steady-state check in run_is_over(): rc 1 at 2.0-2.5 s)
first CLUSTER SLOTS good, then *0 forever, -c2 -t1 --requests=200, no reconnect: fails (rc != 0) in < 10 s FAIL (hang) PASS at 1b2e0b5 (mutant without the --requests clause: killed at 20 s) PASS
same, staircase --clients=3 --clients-start=1 --clients-step=1 --step-duration=1 --test-time=4, no reconnect: fails (rc != 0) in < 12 s FAIL (hang) FAIL at 1b2e0b5 (rc 0, one client's throughput) PASS
same staircase, run started 0.9 s into a second, bad replies delayed 0.3 s (retries land where whole-second finished() is true but run_is_over() is not): fails (rc != 0) FAIL (hang) FAIL at a901388 (rc 0, 8 of 8 runs) PASS (10 of 10)

Flakiness: 48 of 48 runs passed (6 runs of the 8 tests), and 8 of 8 after the rebase onto 66b58e7. At 57662b9, rebased onto 57ad921: 27 of 27 (3 runs of the 9 tests), plus 10 of 10 runs of the new replica test. All 9 fail on origin/master 57ad921. At 6766df8, rebased onto cf5753f: 33 of 33 (3 runs of the 11 tests), plus 20 of 20 runs of the two new multi-client tests (10 each); both new tests fail on the previous head 57662b9 (killed at 20 s). test_reconnections.py:test_auth_failure_on_reconnect_with_retry_on_error_honors_test_time, which goes through the changed run_is_over() check, still passes. At 1b2e0b5, rebased onto 6eedafb: 39 of 39 (3 runs of the 13 tests), plus 20 of 20 runs of the two new tests (10 each). The three test_reconnections.py:test_auth_failure_on_reconnect_* tests pass. At 1084b2c, rebased onto 0062e56: 45 of 45 (3 runs of the 15 tests), plus 20 of 20 runs of the two new tests (10 each). At 6554c59, rebased onto 8f5fa34 (#669): 48 of 48 (3 runs of the 16 tests), 10 of 10 runs of the new staircase test, and make check 7 of 7.

The file adds about 32 s to each full-suite CI cell. The only red check so far was the 25-minute "Run tests" step timeout (#679, addressed by #683), not a failing test.

Startup with 3 bad replies, then a good map, --pipeline=4 (from the reviewer's scenario):

run 6befb49 this PR
--test-time=3 Count 4, 1.3 ops/sec Count 260575, 85715 ops/sec, 3040 ms
--requests=20000 6074 ops/sec, 3293 ms 65718 ops/sec, 304 ms

Mid-run *0 forever after -MOVED, --test-time=3, no reconnect: 6befb49 exited 0 after 5.0 s (Count 50, 4 connection errors, duration 4005 ms). This PR exits 1 after 1.5 s with "CLUSTER SLOTS error and --reconnect-on-error is not set, ending this thread."

Existing suites pass on this PR:

  • existing-env: test_cli_fuzz_phase1.py (7), test_resp_response_fuzzer.py (12), test_cluster_slots_refresh_overlap.py, test_cluster_readonly_drop.py and test_cluster_failed_keys.py.
  • oss-cluster, 3 shards: test_reconnections.py and test_cluster_transaction.py.

Not in this PR: empty host in CLUSTER SLOTS

A real single-node cluster that has never been met, and has no cluster-announce-ip, returns an empty host string (redis 8.6.0: 0 / 16383 / "" / 12160). memtier has rejected an empty host since 2.4.0 (39fc971), logging "empty host/port; skipping". Before that, it copied the empty string and could not connect. The CLUSTER SLOTS docs say clients may treat "" like NULL, meaning "use the endpoint the command was sent to". That needs handle_cluster_slots() to know which connection sent the command, plus NULL-bulk handling, so it is left for a separate issue. On this target, master asks once and exits 2 at --connection-stage-timeout. This PR asks once per second and exits 2 at the same time.

Not in this PR: --requests with unlimited reconnects

A connection whose setup keeps being rejected, under --requests + --reconnect-on-error + the default unlimited --max-reconnect-attempts, reconnects forever, whether or not its client has started. That predates this PR (master since #630), and is filed as #693.

Release note

Without --reconnect-on-error, a connection that fails is now logged as "<error> and --reconnect-on-error is not set, ending this thread." instead of "Maximum reconnection attempts (0) exceeded for <error>, ending this thread.", and, with --read-preference other than primary, as "<reason>; leaving conn N dead and continuing while peers are still mid-setup." Log scrapers matching the old text need updating; the message with --reconnect-on-error is unchanged.

Behaviour change with --reconnect-on-error: a client whose AUTH/SELECT/HELLO (or CLUSTER SLOTS) setup keeps being rejected while other clients are running is now stopped at the run's --test-time deadline, and the run fails. Before, a client whose setup only recovered after the deadline started late and extended the run past --test-time; and a client whose setup never recovered, while the others ran, reconnected forever and the run never ended. That hang is fixed here too. Under --requests with unlimited --max-reconnect-attempts, such a client still reconnects forever: #693.

Fixes #648
Fixes #670

Affected versions

#648: 1.2.11 through 2.5.2 (latest) and master.

  • Introduced by fdd22d8, "add support for cluster mode (add support for cluster mode #42)". The first tag that contains it is 1.2.11.
  • Confirmed by running: master 3b3c2d7 and 0298524 (mid-run hang and single-shot startup), and 2.5.2 (mid-run hang with --requests).
  • Derived from history: 1.2.11 to 2.5.1. The branch has not changed since 1.2.11.

#670: 2.5.0 through 2.5.2 (latest) and master. Introduced by ee757e7 (#456), which made the malformed-reply branch leave m_cluster_slots at setup_sent. Confirmed by running on master 3b3c2d7 and 0298524.

Found during review of the cluster-mode PRs (see #648 and #670).

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks for this. The root cause is clear: both branches left m_cluster_slots at setup_sent and nothing re-armed it. The test file looks good too. Each scenario is checked against master and against the previous head, and there are mutant kills for the --requests and steady-state clauses. A few comments, mostly about how the logic has built up over the review rounds:

  • The last commit adds connection_stage_steady_state_reached() && m_conns_manager->finished() to the retry handler because client::finished() compares whole seconds against benchmark_start_time under --clients-start. Did you consider fixing finished() itself instead, with the same timersub you now use in run_is_over()? As it stands, two "is the run over" checks disagree by up to 1 s, and every new caller has to remember which one it's using. I may be missing a reason the staircase path has to stay coarse.

  • "Should this client stop retrying" is now decided in three places, each with a slightly different condition: retry_cluster_slots_after_error() (reqs_answered || run_is_over() || (test_time == 0 && steady)), handle_cluster_slots_retry_event() (!reqs_answered && (run_is_over() || (steady && finished()))), and handle_reconnect_timer_event() (setup_rejected && run_is_over()). If it's easy, it would be nice for these to go through one helper. Does that sound feasible? Eight rounds in, I think one predicate would also be easier to check against the table in the description.

  • Scope: two of these changes reach beyond CLUSTER SLOTS. The new attempt_reconnect() wording applies to every dropped or timed-out connection without --reconnect-on-error. The run_is_over() change in handle_reconnect_timer_event() alters how a rejected AUTH/SELECT/HELLO is bounded under --reconnect-on-error. Both are disclosed in the release note, and I think both are improvements. Still, I wonder if they'd be easier to review and revert as their own commits or PR, separate from the Cluster: an empty or -ERR CLUSTER SLOTS reply leaves the connection stuck; mid-run the process hangs, ignoring --test-time #648/Cluster: a CLUSTER SLOTS reply whose shard entries are all malformed leaves the connection stuck; mid-run the process hangs, ignoring --test-time #670 fix. It's the same reasoning as keeping unrelated changes out of a fix commit.

  • On the log wording: it's stderr, not a JSON or CSV field, so I don't think the compat bar from PR#60 strictly applies. But "Maximum reconnection attempts ... exceeded" has been the text for a long time, and only the "not set" case changes. Fine by me, but worth a second look from whoever handles release notes.

  • Nitpicking: char reason[256] with snprintf is safe as long as error_context stays one of the short literals it gets today. A short comment saying so would help, in case someone later passes a server error string through.

  • Nitpicking: the --connection-stage-timeout help text changed, but I couldn't find the option in memtier_benchmark.1. That's not caused by this PR, but you may want to check whether the man page should cover it.

I think the core fix is solid. I'd mainly like an answer on the finished() question before this merges, since that's where the last few rounds of edge cases have come from.

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

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. Replying point by point to the first-pass review. The branch is rebased onto 57ad921, and the new head is 57662b9.

(a) Description vs. final behaviour. The description already matched 3f71179 by the time of this reply. It now covers 57662b9 as well: there is a "Review follow-ups" item, and the test table and the logged message are updated.

(b) Is failing the run mid-run too harsh during a failover or resharding? This is intended, and it is the decision the PR asks maintainers to confirm. My reasons:

  • A mid-run CLUSTER SLOTS refresh only happens after -MOVED, -ASK, -READONLY or a dead target. That means the topology is already changing.
  • Without --reconnect-on-error, memtier already fails the run when a connection drops during that same failover. A node answering *0 or a partial map is the same kind of event, so it gets the same default.
  • Retrying silently by default would make a benchmark that stalled for part of a failover look like a clean run. The previous head did that: it exited 0 with a shortened run.
  • Users who want to ride through a failover already pass --reconnect-on-error for dropped connections. With it, a bad map reconnects, bounded by --max-reconnect-attempts, and the run recovers once a good map arrives. Two tests cover that: *_mid_run_is_retried for an empty reply and for a malformed one.
  • At startup, before anything was answered, memtier still retries every second until --connection-stage-timeout, so a node that is still converging is tolerated by default.

If cluster-routing owners would rather retry by default mid-run as well, the change is small: the get_reqs_answered() branch in retry_cluster_slots_after_error(). But that would make this case behave differently from a dropped connection.

(c) Can a connection whose CLUSTER SLOTS failed get stuck in the read_preference != rp_primary && peer_client_has_any_setup_in_progress() branch? It does not stall the run. I checked this with a test and with a trace:

  • In that branch, disconnect() sets the connection to conn_disconnected with m_reconnecting false, and the thread keeps going.
  • A peer of the same client then revives it or ends the run. Once the peer has finished setup, a write routed to the dead primary makes the producing connection call set_cluster_slots() (cluster_client.cpp, in the "target primary disconnected" path).
  • If that refresh succeeds, handle_cluster_slots() reconnects the dead primary (conn_disconnected && !is_reconnect_pending() → connect_shard_connection()).
  • If it fails, the peer has no peer still in setup, so it takes the terminal branch and ends the thread.
  • New test test_cluster_slots_empty_reply_mid_run_with_replica_in_setup: one primary and one replica, --read-preference=secondary --ratio=1:0, and the replica's READONLY is delayed by 1 s. The primary's refresh after -MOVED returns *0 while READONLY is pending, so it takes this branch ("peers still mid-setup, leaving connection dead and continuing"). The replica then refreshes, that refresh fails too, and the thread ends. Result: rc 1 in about 2 s with --test-time=5, and 10 of 10 runs passed. On origin/master the same test hangs until it is killed at 20 s.
  • One case does hang: a peer whose setup never completes (a replica that never answers READONLY). That hang is not specific to CLUSTER SLOTS. A plain dropped connection does the same thing on that path, as I checked with the same fake cluster and the primary closing its socket instead of answering -MOVED. So it is outside this PR.

(d) "Maximum reconnection attempts (0) exceeded ..." without --reconnect-on-error. Reworded in attempt_reconnect(). Without the flag, it now logs "<error> and --reconnect-on-error is not set, ending this thread." (or "..., leaving connection dead and continuing." in the replica-setup branch). This also covers dropped connections, which had the same odd wording. The message with --reconnect-on-error is unchanged, so the existing assertions in test_reconnections.py still hold. The test assertion in this PR is updated.

CI note: the only red check so far was the 25-minute "Run tests" step timeout (#679, being fixed by #683). The new test file adds about 32 s to each full-suite cell. This PR does not change any workflow files.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Follow-up to the first-pass review, on the points still open. The branch is rebased onto cf5753f, and the new head is 6766df8.

(2) event_new failure in retry_cluster_slots_after_error(). Fixed. It now logs error: event_new failed in retry_cluster_slots_after_error with benchmark_error_log() and calls event_base_loopbreak(), as attempt_reconnect() does, so the thread ends and the run fails instead of hanging silently.

(3) Log wording. The PR description now has a "Release note" section for the reworded message without --reconnect-on-error (any caller of attempt_reconnect(), including a plain dropped connection), and for the reworded replica-setup message below.

Nit: stale comment in the malformed branch. Updated. It no longer says the worker would stall or hang; it says the rejection is reported so --connection-stage-timeout bounds it at startup, and that the reply is then handled like an empty one.

Nit: tight time bounds. Widened to elapsed < 10 in both tests (--test-time=3 and --test-time=5). Without the fix the run hangs until the 20 s kill, so the bound still tells the two apart.

Also in this push, from a second review round:

  • Multi-client hang. "Startup" was decided per client (get_reqs_answered()), but --connection-stage-timeout is disarmed for the whole run as soon as any connection reaches steady state. With more than one client, a client stuck on *0 while another was running retried every second forever, and the run never ended. With --reconnect-on-error it reconnected forever, because the "run is over" check needed the client's own clock, which never started. A failed CLUSTER SLOTS is now treated as mid-run once any connection reached steady state, and a client that never started stops reconnecting at the run's --test-time deadline. There are two new tests for this (-c2 -t1 without reconnect, -c1 -t2 with it). Both are killed at 20 s on 57662b9 and pass on 6766df8 (20 of 20 runs).
  • The replica-branch message read as if --reconnect-on-error were set per connection. It now reads "<reason>; leaving conn N dead and continuing while peers are still mid-setup."

The full file passed 33 of 33 locally (3 runs of the 11 tests).

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

Copy link
Copy Markdown
Collaborator Author

Third review round. The branch is rebased onto 6eedafb, and the new head is 1b2e0b5.

  • One transient *0 no longer fails the run. In 6766df8, a client with no reply yet ended its thread on the first failed CLUSTER SLOTS once any other connection was running, so a single transient empty reply failed the run (exit 1). Such a client now keeps the 1 s retry, bounded by the run's --test-time deadline (run_is_over()), so the multi-client hang stays fixed. Under --requests there is no deadline, so it still ends the thread at once there. New test: the second CLUSTER SLOTS gets *0 after 0.5 s, -c2 -t1 --test-time=3, and the run exits 0 after 3 CLUSTER SLOTS requests. It fails on 6766df8 (rc 1, "ending this thread").
  • The steady-state check in run_is_over() is now tested. New test: AUTH is rejected at startup, with -a wrongpw --reconnect-on-error --test-time=1 --connection-stage-timeout=5. It must exit 2 at the stage timeout (at least 4 s). The mutant that drops !connection_stage_steady_state_reached() exits 1 after 2.0-2.5 s and fails the test.
  • Behaviour change in the release note. With --reconnect-on-error, a client whose setup only recovers after the deadline is now stopped, and the run fails, instead of running late. This also fixes the existing hang where one client's setup is rejected forever while the others run.
  • Follow-up --reconnect-on-error with --requests and unlimited --max-reconnect-attempts: a connection whose setup keeps being rejected reconnects forever #693. --requests with --reconnect-on-error and unlimited attempts reconnects forever after a rejected setup. This was reproduced on master 3b3c2d7 (AUTH) and on this branch (CLUSTER SLOTS). The PR body links it.

Local results: 39 of 39 for the 13 tests, 20 of 20 runs of the two new tests, and the three test_auth_failure_on_reconnect_* tests in test_reconnections.py pass.

@fcostaoliveira
fcostaoliveira force-pushed the fix/cluster-slots-empty-reply branch from 1b2e0b5 to 1084b2c Compare October 16, 2026 10:04
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Fourth review round. The branch is rebased onto 0062e56, and the new head is 1084b2c.

  • Late staircase clients without a slot map now fail the run. Under --clients-start, client::finished() uses the run's deadline. A late client whose CLUSTER SLOTS kept failing had its 1 s retry fire after the deadline. fill_pipeline() then treated it as finished and sent nothing, so the run exited 0 with only the first client's throughput. Now, when the retry timer fires after run_is_over() for a client that never had a reply, handle_cluster_slots_retry_event() ends the thread through attempt_reconnect(), the same way a failed reply after the deadline already does. New test: --clients=3 --clients-start=1 --clients-step=1 --step-duration=1 --test-time=4, where every CLUSTER SLOTS after the first is *0. It must exit non-zero in < 12 s. At 1b2e0b5 it exits 0.
  • The --requests clause is now tested. New test: _Node(bad_slots_replies=1000, first_good=True) with --requests=200 and -c2. It asserts a non-zero rc, no timeout, elapsed < 10 s, and "ending this thread". The mutant that drops m_config->test_time == 0 && connection_stage_steady_state_reached() hangs until the 20 s kill.

Local results: 45 of 45 for the 15 tests (3 runs), and 20 of 20 runs of the two new tests.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Pushed a one-line follow-up, rebased on master: run_is_over() now compares the full timeval difference instead of whole seconds. Before, a client still waiting for its slot map could be treated as past the deadline up to 1 s early when the run had started late in a second. A reviewer saw a --test-time=2 run with one transient *0 fail in 4 of 8 runs this way. tests/test_cluster_slots_bad_reply.py passes 15/15.

fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
The deadline was only checked when a reconnect attempt failed. A reconnect
armed before the deadline still waited its full backoff delay (up to
MEMTIER_BACKOFF_CAP_SEC, 60 s), and the client's stats ended at that later
failure, so --test-time 4 with --reconnect-backoff-factor 20 ran for 22 s
and reported a 21.8 s duration and a fraction of the real throughput.

- Arm every reconnect no later than the deadline: the delay is capped at
  the time left, on a local copy, so the backoff schedule is unchanged.
- When a connect fails and the run is over, end a started client's stats
  at the deadline, so the duration and ops/sec reflect --test-time.
- Stop only on a failed connect, not on a drop of an established
  connection: a live server that closes connections around the deadline
  (e.g. a CLIENT KILL loop) still gets the requests held for replay
  resent. This replaces the m_reconnect_attempts == 0 "first reconnect"
  rule, which broke because the counter is reset only on a reply.
- Cover a client that never started (its connection was up but never
  answered while another client's was): once any connection reached
  steady state the connection-stage supervisor is disarmed, so time it
  from the benchmark's start, as PR #667's run_is_over() does. The #630
  check for a rejected setup uses the same helper.
- Leave a cluster connection whose dial fails after the run is over dead,
  instead of ending the client from inside the CLUSTER SLOTS handler.

The deadline wins over a finite --max-reconnect-attempts: a run whose
attempts are not exhausted by the deadline ends normally (exit 0); one
whose attempts run out first still fails (exit 1). README, --help and the
man page say so.

Refs #656

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 a901388. Configure here.

Comment thread shard_connection.cpp Resolved
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
The deadline was only checked when a reconnect attempt failed. A reconnect
armed before the deadline still waited its full backoff delay (up to
MEMTIER_BACKOFF_CAP_SEC, 60 s), and the client's stats ended at that later
failure, so --test-time 4 with --reconnect-backoff-factor 20 ran for 22 s
and reported a 21.8 s duration and a fraction of the real throughput.

- Arm every reconnect no later than the deadline: the delay is capped at
  the time left, on a local copy, so the backoff schedule is unchanged.
- When a connect fails and the run is over, end a started client's stats
  at the deadline, so the duration and ops/sec reflect --test-time.
- Stop only on a failed connect, not on a drop of an established
  connection: a live server that closes connections around the deadline
  (e.g. a CLIENT KILL loop) still gets the requests held for replay
  resent. This replaces the m_reconnect_attempts == 0 "first reconnect"
  rule, which broke because the counter is reset only on a reply.
- Cover a client that never started (its connection was up but never
  answered while another client's was): once any connection reached
  steady state the connection-stage supervisor is disarmed, so time it
  from the benchmark's start, as PR #667's run_is_over() does. The #630
  check for a rejected setup uses the same helper.
- Leave a cluster connection whose dial fails after the run is over dead,
  instead of ending the client from inside the CLUSTER SLOTS handler.

The deadline wins over a finite --max-reconnect-attempts: a run whose
attempts are not exhausted by the deadline ends normally (exit 0); one
whose attempts run out first still fails (exit 1). README, --help and the
man page say so.

Refs #656

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira and others added 7 commits October 16, 2026 11:54
In --cluster-mode, a CLUSTER SLOTS reply that is empty (*0) or an error
only logged "cluster slot failed." and returned. m_cluster_slots stayed
setup_sent, so the connection never sent a workload request again and
set_cluster_slots() refused to queue another refresh; only a disconnect
would reset it, and nothing disconnected. On a mid-run refresh (after a
-MOVED) the run hung past --test-time and --requests, also with
--reconnect-on-error. At startup a node that briefly has no slots was
asked once, and the run ended at --connection-stage-timeout. The branch
also left set_keep_value(true) in place.

Treat the reply like a rejected setup step. Clear keep_value, then:
- with --reconnect-on-error, reconnect through
  reconnect_after_setup_error() as AUTH/SELECT/HELLO errors do (#630), so
  --max-reconnect-attempts bounds the retries and they stop once the run
  is over;
- otherwise resend CLUSTER SLOTS after one second. The failure is counted
  as a connection error, which also advances the run's clock (it only
  moves on replies otherwise), so the run still ends at --test-time. At
  startup --connection-stage-timeout still applies, with the same message.

Fixes #648

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A non-empty CLUSTER SLOTS reply in which every shard entry fails
validation (slot bound out of range, node without a port, ...) leaves
handle_cluster_slots() returning false. That branch deliberately kept
m_cluster_slots at setup_sent, so, as with an empty reply (#648), the
connection sent nothing more and set_cluster_slots() would not queue
another refresh. Unless the server closed the socket, a mid-run refresh
hung past --test-time, --requests and --reconnect-on-error, and at
startup the node was asked only once.

Handle it like an empty reply: call retry_cluster_slots_after_error(),
which reconnects with --reconnect-on-error and otherwise resends CLUSTER
SLOTS after a second. The prior topology is still left in place.

Rename the test file to test_cluster_slots_bad_reply.py and add the
malformed cases.

Fixes #670

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st reply

The previous fix counts each failed CLUSTER SLOTS as a connection error,
which advances the run's clock so --test-time is honoured mid-run. At
startup that clock is already running but no reply has arrived, so a
node that never answers (e.g. --cluster-mode against a standalone
server) made the run "finish" at --test-time with 0 ops and exit 0,
instead of failing at --connection-stage-timeout with exit 2.
test_426_2_cluster_mode_against_standalone caught this in the sanitizer
TLS cells.

Only count the error once a reply has been answered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…LUSTER SLOTS

Review of the CLUSTER SLOTS retry found three problems without
--reconnect-on-error:

- At startup, the time spent retrying was charged to the run. The start
  time was set when the connection opened, so with three bad replies a
  --test-time=3 run reached its deadline right after the first good
  reply (Count 4, 1.3 ops/sec) and a --requests run reported a third of
  its real throughput. Reset the start time when a retry is sent before
  the first reply, as process_first_request() does on connect.

- Mid-run, a node that never recovered was retried once per second and
  the run exited 0 about a second past --test-time, while the same
  failure with --reconnect-on-error, or a dropped connection, exits 1.
  Handle it like a dropped connection: attempt_reconnect() ends the
  thread and the run fails. This also removes the endless retry with
  --requests, and the connection-error count that moved the run's clock.

- The retry shared m_deferred_fill_timer, so arming it could push a
  pending zero-delay schedule_fill() wake out by a second. Use a
  dedicated timer, and keep m_cluster_slots at setup_sent until it
  fires so nothing else resends the request early.

Startup retries are bounded by --connection-stage-timeout; with 0 they
continue every second, which --help now says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e replica-setup branch

Without --reconnect-on-error, attempt_reconnect() reported "Maximum
reconnection attempts (0) exceeded for ...", although no reconnection was
ever enabled. It now says "<error> and --reconnect-on-error is not set,
ending this thread." The message with --reconnect-on-error is unchanged.

Add a test for a CLUSTER SLOTS refresh that fails mid-run while a
replica's READONLY is pending under --read-preference=secondary.
attempt_reconnect() then leaves the connection disconnected instead of
ending the thread. The test checks that this connection does not stall the
run: once the replica is ready, a write for the dead primary makes it
refresh the slot map, that refresh fails too and ends the thread, so the
run fails before --test-time. On origin/master the run hangs.

Correct the comment of test_cluster_slots_empty_reply_at_startup_still_aborts:
it checks that startup keeps asking and that --connection-stage-timeout
still ends the run, not that the retries leave the run's clock alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A client whose CLUSTER SLOTS keeps failing at startup was retried every
second, bounded only by --connection-stage-timeout. That supervisor is
disarmed globally as soon as any connection reaches steady state, so with
more than one client, one client running and another stuck on an empty
reply retried forever, and the run never ended. With --reconnect-on-error
the stuck client reconnected forever instead: the "run is over" check only
looked at the client's own --test-time, and its clock never started.

Treat a failed CLUSTER SLOTS as mid-run once any connection reached steady
state: without --reconnect-on-error end the thread, as for a dropped
connection. With it, a client that never started stops reconnecting at the
run's --test-time deadline.

Also log and break the loop if the retry timer cannot be created, update a
stale comment, reword the replica-setup message, and widen test bounds.

Refs #648, #670

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit ended the thread on the first failed CLUSTER SLOTS of
a client that had no reply yet, once any other connection reached steady
state. A single transient empty reply for a second client then failed a
run that would have recovered a second later.

Such a client now keeps asking once a second, and stops only at the run's
--test-time deadline (run_is_over()), so the multi-client hang stays fixed.
Under --requests there is no deadline, so it still fails at once there
(see #693).

Add tests for the transient case and for a rejected setup at startup
being ended by --connection-stage-timeout, not by the --test-time deadline.

Refs #648, #670

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…rver

With --reconnect-on-error and unlimited --max-reconnect-attempts, 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.

- 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; 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. The deadline wins over a
  finite --max-reconnect-attempts.
- 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).
- Failed reconnects that never reach the event loop (unix socket) are
  counted as connection errors (count_connection_error()).
- With --requests and unlimited attempts, warn every 10 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; new tests in
  test_reconnections.py cover it, including a reconnect still connecting
  when #669's drain grace expires (its idle-client guard).

Fixes #656

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
In staircase mode the run's deadline was checked as
now.tv_sec - benchmark_start_time.tv_sec >= test_time, which drops the
microseconds. A run that started at x.6 s therefore ended at x+test_time
whole seconds, about 0.4 s early: "Total duration" for --test-time 3 was
anywhere between 2.0 and 3.0 s, and the last staircase step got a shorter
window than the others.

Compare the full elapsed timeval in client::finished() and
client_group::handle_staircase_step(), as run_is_over() already does. The
staircase step needs the same change: its whole-second check overestimates
the elapsed time by up to 1 s, so a step that fires a few ms after a second
boundary could be taken as past the deadline, and the last step skipped,
now that the run itself no longer ends at that boundary. The live display's client count now also rounds down from the
microsecond difference.

The special case PR #667 added in handle_cluster_slots_retry_event() is
kept, only its comment about whole seconds is dropped.

Fixes #713

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…rver

With --reconnect-on-error and unlimited --max-reconnect-attempts, 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.

- 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; 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. The deadline wins over a
  finite --max-reconnect-attempts.
- 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).
- Failed reconnects that never reach the event loop (unix socket) are
  counted as connection errors (count_connection_error()).
- With --requests and unlimited attempts, warn every 10 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; new tests in
  test_reconnections.py cover it, including a reconnect still connecting
  when #669's drain grace expires (its idle-client guard).

Fixes #656

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
In staircase mode the run's deadline was checked as
now.tv_sec - benchmark_start_time.tv_sec >= test_time, which drops the
microseconds. A run that started at x.6 s therefore ended at x+test_time
whole seconds, about 0.4 s early: "Total duration" for --test-time 3 was
anywhere between 2.0 and 3.0 s, and the last staircase step got a
shorter window than the others.

client::finished() now compares the full elapsed timeval, as
run_is_over() already does.

client_group::handle_staircase_step() used the same whole-second check
to stop at the deadline. It now decides by the step count instead: step
k is due at k * step_duration and is taken only if that is before
test_time. A clock check does not work there either way: the timer runs
on libevent's monotonic clock and can fire a hair before the deadline by
gettimeofday(), so an exact check connected one more client per thread
at the deadline, which the run then stopped at once.

The live display's client count now rounds down from the microsecond
difference.

The special case PR #667 added in handle_cluster_slots_retry_event() is
kept, only its comment about whole seconds is dropped.

Fixes #713

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…rver

With --reconnect-on-error and unlimited --max-reconnect-attempts, 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.

- 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; 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. The deadline wins over a
  finite --max-reconnect-attempts.
- 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).
- Failed reconnects that never reach the event loop (unix socket) are
  counted as connection errors (count_connection_error()).
- With --requests and unlimited attempts, warn every 10 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; new tests in
  test_reconnections.py cover it, including a reconnect still connecting
  when #669's drain grace expires (its idle-client guard).

Fixes #656

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
In staircase mode the run's deadline was checked as
now.tv_sec - benchmark_start_time.tv_sec >= test_time, which drops the
microseconds. A run that started at x.6 s therefore ended at x+test_time
whole seconds, about 0.4 s early: "Total duration" for --test-time 3 was
anywhere between 2.0 and 3.0 s, and the last staircase step got a
shorter window than the others.

client::finished() now compares the full elapsed timeval, as
run_is_over() already does.

client_group::handle_staircase_step() used the same whole-second check
to stop at the deadline. It now decides by the step count instead: step
k is due at k * step_duration and is taken only if that is before
test_time. A clock check does not work there either way: the timer runs
on libevent's monotonic clock and can fire a hair before the deadline by
gettimeofday(), so an exact check connected one more client per thread
at the deadline, which the run then stopped at once. The clock is still
checked as well, with full timevals: after a stall of the event loop
(SIGSTOP, VM pause) libevent reschedules the timer from "now", so the
count lags behind and a step could otherwise fire after the deadline.

The live display's client count now rounds down from the microsecond
difference.

The special case PR #667 added in handle_cluster_slots_retry_event() is
kept, only its comment about whole seconds is dropped.

Fixes #713

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
In staircase mode the run's deadline was checked as
now.tv_sec - benchmark_start_time.tv_sec >= test_time, which drops the
microseconds. A run that started at x.6 s therefore ended at x+test_time
whole seconds, about 0.4 s early: "Total duration" for --test-time 3 was
anywhere between 2.0 and 3.0 s, and the last staircase step got a
shorter window than the others.

client::finished() now compares the full elapsed timeval, as
run_is_over() already does.

client_group::handle_staircase_step() used the same whole-second check
to stop at the deadline. It now decides by the step count instead: step
k is due at k * step_duration and is taken only if that is before
test_time. A clock check does not work there either way: the timer runs
on libevent's monotonic clock and can fire a hair before the deadline by
gettimeofday(), so an exact check connected one more client per thread
at the deadline, which the run then stopped at once. The clock is still
checked as well, with full timevals: after a stall of the event loop
(SIGSTOP, VM pause) libevent reschedules the timer from "now", so the
count lags behind and a step could otherwise fire after the deadline.

The JSON "Active Clients" entry is computed from the bucket's second.
Now that the last requests can complete just after the deadline, in a
bucket at t = test_time, cap it at the last step due before test_time,
so that bucket does not count a step that was never taken.

The live display's client count now rounds down from the microsecond
difference.

The special case PR #667 added in handle_cluster_slots_retry_event() is
kept, only its comment about whole seconds is dropped.

Fixes #713

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 16, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 17, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 17, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 17, 2026
…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 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 every 10 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]>
fcostaoliveira added a commit that referenced this pull request Oct 17, 2026
…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]>
fcostaoliveira added a commit that referenced this pull request Oct 17, 2026
…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]>
fcostaoliveira added a commit that referenced this pull request Oct 17, 2026
…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]>
fcostaoliveira added a commit that referenced this pull request Oct 25, 2026
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]>
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