Repository navigation
Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging - #667
Conversation
|
🤖 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
I think the core fix is solid. I'd mainly like an answer on the (would file this as a comment, not a formal block) |
af78107 to
6befb49
Compare
6befb49 to
3f71179
Compare
3f71179 to
57662b9
Compare
|
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:
If cluster-routing owners would rather retry by default mid-run as well, the change is small: the (c) Can a connection whose CLUSTER SLOTS failed get stuck in the
(d) "Maximum reconnection attempts (0) exceeded ..." without 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. |
57662b9 to
6766df8
Compare
|
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) (3) Log wording. The PR description now has a "Release note" section for the reworded message without 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 Nit: tight time bounds. Widened to Also in this push, from a second review round:
The full file passed 33 of 33 locally (3 runs of the 11 tests). |
6766df8 to
1b2e0b5
Compare
|
Third review round. The branch is rebased onto 6eedafb, and the new head is 1b2e0b5.
Local results: 39 of 39 for the 13 tests, 20 of 20 runs of the two new tests, and the three |
1b2e0b5 to
1084b2c
Compare
|
Fourth review round. The branch is rebased onto 0062e56, and the new head is 1084b2c.
Local results: 45 of 45 for the 15 tests (3 runs), and 20 of 20 runs of the two new tests. |
|
Pushed a one-line follow-up, rebased on master: |
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]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a901388. Configure here.
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]>
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]>
…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]>
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]>
…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]>
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]>
…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]>
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]>
…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]>
…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]>
…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]>
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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
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]>

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.
--reconnect-on-error--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-timedeadline--test-timeor 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-timedeadline (then the thread ends as mid-run, also when the deadline passes while the retry is pending, e.g. a late--clients-startclient). Under--requeststhere is no deadline, so once another connection is running the first failure ends the thread (see #693)--connection-stage-timeoutis 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-timedeadline.With
--connection-stage-timeout=0, startup retries go on every second until the node answers. The run logs every attempt, and--helpnow 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:*0) or an error: memtier logscluster slot failed.(Cluster: an empty or -ERR CLUSTER SLOTS reply leaves the connection stuck; mid-run the process hangs, ignoring --test-time #648).every shard in the reply was malformed(Cluster: a CLUSTER SLOTS reply whose shard entries are all malformed leaves the connection stuck; mid-run the process hangs, ignoring --test-time #670).If this happens on a mid-run refresh (after a
-MOVED), the run hangs past--test-timeand--requests, even with--reconnect-on-error. At startup, memtier asks only once.Root cause
Both branches of the
rt_cluster_slotscase inshard_connection::process_response()leftm_cluster_slotsatsetup_sent:As a result:
is_conn_setup_done()stayed false, sofill_pipeline()sent nothing more.set_cluster_slots()refused to queue another refresh.disconnect().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 clearskeep_valuefirst.--reconnect-on-error, it callsreconnect_after_setup_error().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 oncerun_is_over()(the run's deadline passed after another connection reached steady state, newconnection_stage_steady_state_reached()), or, under--requests, as soon as another connection reached steady state.m_cluster_slots_retry_timerfor 1 s, andm_cluster_slotsstayssetup_sentwhile it waits, so nothing resends the request early. When the timer fires:setup_none;set_start_time(), asprocess_first_request()does on connect);fill_pipeline().disconnect()cancels the timer, and the destructor frees it. Ifevent_newfails, it logs and breaks the event loop, asattempt_reconnect()does.handle_reconnect_timer_event()stops retrying a rejected setup oncerun_is_over(): the client's own--test-timeonce it has started, or, for a client that never started while others did, the run's--test-timedeadline (frombenchmark_start_time). While no connection has reached steady state,--connection-stage-timeoutstill decides (exit 2), not the deadline.Commits
tests/test_cluster_slots_bad_reply.py.test_426_2_cluster_mode_against_standalonefailure in the sanitizer TLS cells.--requestsand the exit 0 past the deadline.m_deferred_fill_timer.--helptext for--connection-stage-timeout=0is updated.--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-erroris unchanged, and no existing test matches the old wording without the flag.--read-preference != primarybranch ofattempt_reconnect()(a peer still in setup), so a connection whose CLUSTER SLOTS failed is shown not to stall the run.test_cluster_slots_empty_reply_at_startup_still_aborts, and documented why the empty/error branch clearskeep_value.--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_newfailure in the retry path is logged and breaks the loop.<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).*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*0for a second client completes with rc 0, and a rejected AUTH at startup with--reconnect-on-error --test-time=1 --connection-stage-timeout=5still exits 2 at the stage timeout (it kills the mutant that drops the steady-state check fromrun_is_over()).--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 (viaattempt_reconnect()) when it fires after the run is over for a client that never had a reply. New tests: that staircase case, and--requestswith a second client that never gets a map (ends the thread at once; kills the mutant that drops the--requestsclause, which hangs).run_is_over()compares full timevals (whole seconds ended a waiting client up to 1 s early).--clients-start,client::finished()still compares whole seconds, so it can be true up to 1 s beforerun_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 whenfinished()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).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.pyhas 16 tests. It uses a scripted RESP peer (one node, plus a replica node for one test), in the same style astest_cluster_slots_refresh_overlap.py.--reconnect-on-error --requests)--test-time=3*0forever mid-run,--reconnect-on-error --test-time=2ends-ERR×2 at startup, then the full--test-time=2run (elapsed ≥ 3.5 s, ≥ 1000 requests)--reconnect-on-error --test-time=2ends*0forever at startup,--test-time=1 --connection-stage-timeout=5exits 2*0forever mid-run,--read-preference=secondary, replica READONLY delayed 1 s: fails (rc != 0) in < 10 s with--test-time=5*0forever,-c2 -t1 --test-time=2, no reconnect: fails (rc != 0) in < 10 s-c1 -t2 --reconnect-on-error --test-time=2: stops reconnecting at the deadline, rc != 0 in < 10 s*0after 0.5 s, then good;-c2 -t1 --test-time=3, no reconnect: rc 0, 3 CLUSTER SLOTS-a wrongpw),--reconnect-on-error --test-time=1 --connection-stage-timeout=5: exit 2 after ≥ 4 srun_is_over(): rc 1 at 2.0-2.5 s)*0forever,-c2 -t1 --requests=200, no reconnect: fails (rc != 0) in < 10 s--requestsclause: killed at 20 s)--clients=3 --clients-start=1 --clients-step=1 --step-duration=1 --test-time=4, no reconnect: fails (rc != 0) in < 12 sfinished()is true butrun_is_over()is not): fails (rc != 0)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 changedrun_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 threetest_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, andmake check7 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):--test-time=3--requests=20000Mid-run
*0forever 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:
test_cli_fuzz_phase1.py(7),test_resp_response_fuzzer.py(12),test_cluster_slots_refresh_overlap.py,test_cluster_readonly_drop.pyandtest_cluster_failed_keys.py.test_reconnections.pyandtest_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 needshandle_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:
--requestswith unlimited reconnectsA 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-preferenceother thanprimary, 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-erroris 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-timedeadline, 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--requestswith 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.
--requests).#670: 2.5.0 through 2.5.2 (latest) and master. Introduced by ee757e7 (#456), which made the malformed-reply branch leave
m_cluster_slotsatsetup_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