Repository navigation
End a --test-time run whose server stops replying (10 s drain grace) - #669
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this, and for the detailed write-up. I went through the diff and the tests. The approach looks sound to me: the main thread only decides when to start asking, and the actual teardown runs on the worker's own loop via On the decision you asked about, a few thoughts:
Nitpicking: after the grace period the main thread queues one The core fix looks solid to me. I'd mainly want someone who uses blocking (would file this as a comment, not a formal block) |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ 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 c763c83. Configure here.
c763c83 to
b1e6307
Compare
|
Thanks for the review. I rebased onto 66b58e7 and pushed b1e6307. Point by point:
Also changed:
Local results: both tests PASS 3/3 on oss and 3/3 on oss-cluster (3 shards). On origin/master 66b58e7 both FAIL (hang, killed). On c763c83 the retry case FAILS and the base case passes. CI on c763c83: the three failures ("Test OSS TCP TLS v1.2", "Test OSS TCP TLS v1.3", "Test Single Endpoint: TCP TLS") were all the 25-minute "Run tests" limit from #679. In each log, |
b1e6307 to
9cbcba4
Compare
|
Replying to the automated review, point by point. I rebased onto 6eedafb and pushed 9cbcba4.
Also from review:
|
9cbcba4 to
3de0677
Compare
|
On the open review question (can a thread finish and have its base freed while an Also in this push (3de0677, rebased on master 0062e56): the "End of a |
After the --test-time deadline a connection stops sending and the run ends only once every in-flight reply has arrived. Nothing bounded that wait, so a server that accepts but never answers (CLIENT PAUSE, a hung or partitioned node) kept memtier running forever and no report was printed, losing the results of the part of the run that did work. Give in-flight replies a 10 s grace period past the deadline. The main thread, which already ticks once a second, asks each still-running worker (via event_base_once, so the work runs on the worker's own loop) to end any client that is that far past its deadline and still has replies pending. Such a client counts its unanswered requests as errors, stamps its end time at start + --test-time so the rates cover the requested window and not the grace period, and disconnects; the run then ends and reports as usual, with a warning. Clients with nothing in flight are left alone: a client waiting for a reconnect is #656 and is handled separately. --requests runs keep waiting, as there is no deadline to measure a grace period from. Fixes #657 Co-Authored-By: Claude Opus 5.5 <[email protected]>
abandon_unanswered_requests() counted every pending reply as an error and then called disconnect_all(). With --retry-on-error, disconnect() moved those requests into the replay queue, and disconnect_all() counted them again and printed its "held for retry" warning. Drop the pending requests first (shard_connection::drop_pending_requests()), counting only workload requests, so setup commands in flight are not counted as errors either. Also remove the staircase step timer when a stalled client is ended, so it does not keep the loop alive until the next step, and test the --retry-on-error case. The test now pauses only writes (CLIENT PAUSE WRITE with an all-SET workload), so CLIENT UNPAUSE works and each case takes ~14 s instead of waiting for a bounded PAUSE ALL to expire. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requests dropped because no reply came within 10 s after --test-time were counted as errors, but that count shows up in no final output, and unlike the run-ended-before-resend path they never reached --failed-keys-file. - Log each abandoned workload request to --failed-keys-file with status "no-reply-after-test-time". - Report the count as "Unanswered requests" in the JSON Runtime section, next to "Interrupted". The exit code stays 0: the --test-time window was measured and reported. - Document the fixed 10 s grace in README, --help and the man page. - Use all_connections_idle() instead of an open-coded loop. Tests: assert the JSON count, the failed-keys rows and (with --retry-on-error) the final error count; add a staircase case whose next step is due long after the deadline, and a case where a client waiting for a reconnect with nothing in flight must be left alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mark" It sat between the cluster read-preference section and its "Testing limitations" note. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts() #661 added connections_manager::abandon_requests() as the single path for "uncount and count as an error". Use it in drop_pending_requests() instead of dec_reqs_generated() plus a separate inc_error() loop, so every give-up site counts the same way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3de0677 to
7518ce9
Compare
- test_live_server_drop_after_deadline_resends_held_requests: a proxy holds the replies from just before the deadline and drops the connections just after it; with --retry-on-error the drop is reconnected and the held requests are answered, none abandoned. It fails if a drop after the deadline is treated like a failed connect. - The dead-from-the-start test asserts that --test-time did not end the run (no connection reached steady state), and honor_test_time makes more than 10 attempts (--reconnect-backoff-factor=0.7), so the --requests-only warning check can fail. - Wall-clock bounds in the new tests are widened under sanitizers. - count_connection_error() keeps "every failed connect counts" in one place; comments on the rejected-setup pre-set and the reconnect() < 0 stop say why they are still needed. - test_test_time_reconnecting_client_left_alone (#669): the reconnect is now due at the deadline, so the run ends well before the grace period. - README: a peer that closes connections after a delay can extend the run by up to about twice that delay. Refs #656 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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…ter the drain grace With --retry-on-error, unlimited --max-retries and a server that rejects every request (e.g. -OOM), a --test-time run never ended. client::finished() measures the run with the per-second stats clock, which only moves on a completed op, and a reply handed to enqueue_retry() completes none. #669's drain grace is meant to bound exactly this kind of run, which keeps going after the deadline, but abandon_unanswered_requests() returned early for a client with no reply pending, and a request held in the retry queue for its backoff is not pending. With --pipeline 1 that is almost always the case. Since 50cfd7f resumes a paused connection to send a retry, such a run resends its retries forever on master. Count a client that still holds retries as unanswered too. TEST_TIME_ DRAIN_GRACE_SECS after the deadline it is ended like a stalled one: disconnect_all() counts the held requests as errors ("held for retry when the run ended were not resent", failed-keys reason run-ended-before-resend) and the reported end time is start + --test-time, so Runtime and the rates cover --test-time. When only retries were left, say so instead of "got no reply to 0 request(s)". Retries still go on after --test-time, as before, so a MOVED that arrives then still refreshes the slot map (test_moved_after_test_time_refreshes_ slots). The grace check runs from the main thread's 1 s tick, so a long retry backoff cannot hold the run past it. Fixes #715 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ter the drain grace With --retry-on-error, unlimited --max-retries and a server that rejects every request (e.g. -OOM), a --test-time run never ended. client::finished() measures the run with the per-second stats clock, which only moves on a completed op, and a reply handed to enqueue_retry() completes none. #669's drain grace is meant to bound exactly this kind of run, which keeps going after the deadline, but abandon_unanswered_requests() returned early for a client with no reply pending, and a request held in the retry queue for its backoff is not pending. With --pipeline 1 that is almost always the case. Since 50cfd7f resumes a paused connection to send a retry, such a run resends its retries forever on master. Count a client that still holds retries as unanswered too. TEST_TIME_DRAIN_GRACE_SECS after the deadline it is ended like a stalled one: the held requests are counted as errors (failed-keys status run-ended-before-resend), and the reported end time is start + --test-time, so Runtime and the rates cover --test-time. handle_end_stalled_clients() now reports the two kinds of client separately, by what each one had: "N client(s) got no reply to M request(s)" for clients waiting for replies, and "N client(s) were still retrying M request(s)" for clients holding retries, once per thread rather than one "held for retry" line per client. A client with both (the tick found a resend on the wire) is in both lines. Retries still go on after --test-time, as before, so a MOVED that arrives then still refreshes the slot map (test_moved_after_test_time_refreshes_slots). The grace check runs from the main thread's 1 s tick, so a long retry backoff cannot hold the run past it. A client waiting for a reconnect is still left alone, with or without --retry-on-error: its requests wait in the replay queue. README, man page and --help describe the new end of such runs. Fixes #715 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ter the drain grace (#724) With --retry-on-error, a --test-time run whose requests kept failing (e.g. an always-OOM server) never ended: the client always held requests for retry, so it never looked idle, and the #669 drain grace skipped clients with nothing pending. The run only stopped when killed, or at --connection-stage-timeout with exit 2. Retries still continue after --test-time (the contract pinned by test_moved_after_test_time_refreshes_slots). The #669 drain grace now also covers clients that hold retries: 10 s after the deadline such a client is ended, its held requests are counted as errors and written to --failed-keys-file with status run-ended-before-resend, and the reported end time is clamped to start + test_time, so Runtime and the rates cover --test-time. Each client is classified by what it actually had, and the warning prints at most two lines per thread per tick: N client(s) got no reply to M request(s) ... abandoned them N client(s) were still retrying M request(s) 10 seconds after the test time ended; ended them (counted as errors, not resent) JSON "Unanswered requests" does not include held retries. Docs (README, man page, --help) describe the new end-of-run case. An always-failing run now exits 0 at test_time + 10 s, where master exited 2 at --connection-stage-timeout when that was shorter. Tests: the #715 repro across backoff factors and a 20 s backoff, with a control without --retry-on-error, cross-checking the warning counts against failed-keys rows, JSON and the error total; and reconnect left-alone cases (with and without --retry-on-error) asserting neither warning appears. Fixes #715 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once the run is over, end_client_after_run() leaves the client to a busy sibling (siblings_done()), which since this PR includes a connect in progress, so a redial's rejected AUTH still fails the run (#630). Without --connection-timeout, a redial whose SYN is dropped (a firewalled or dead node) then kept the run open for the kernel's connect timeout: with the main connection's redial refused after the deadline, a 3 s run ended at 136 s, where master ended at 4 s. end_client_after_run() now marks the client as waiting for its siblings, and the drain grace ends such a client like one with replies pending, at the deadline plus 10 s, with a "still waiting for a connection" warning. A redial that connects within the grace keeps the #630 guarantee. Single-endpoint clients have no siblings and are unchanged (#669's idle-client guard). Also widen the held-refresh transaction test's bound to test_time + 6. Fixes #879 Fixes #880 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ff07182 bounded the wait on a blackholed redial only when a connection had tried to end the client after the run (end_client_after_run()). A connection that stays up and idle past the deadline defers its end on !siblings_done() in fill_pipeline() without marking the client, so the drain grace still skipped it and the run waited for the kernel's connect timeout (137 s for a 3 s run; 135 s on master). Without --rate-limiting that connection is paused before the deadline and fill_pipeline() never runs again, so marking the client from there cannot cover it. The drain grace now also ends a client with a connection up and idle (nothing it may send again) while another connection's connect is in progress (client::idle_connection_waits_for_connect()). A sibling waiting for its reconnect timer, or a client whose connections are all down, is still left to the reconnect logic (#669). A redial that connects within the grace still sends its AUTH (#630), and --connection-timeout, when set, still ends the run sooner (5.0 s with 2). Reported by Cursor Bugbot. Fixes #879 Fixes #880 Co-Authored-By: Claude Opus 5.5 <[email protected]>

Decision for maintainers: once
--test-timehas expired, memtier now waits at most 10 s (TEST_TIME_DRAIN_GRACE_SECS, a constant, no new flag) for replies to requests already sent. After that, the unanswered requests are abandoned: they are counted as errors, logged to--failed-keys-file(statusno-reply-after-test-time), and reported as"Unanswered requests"in the JSONRuntimesection next to"Interrupted". A warning is printed and the run ends and reports normally with exit code 0. The reported window is--test-time, not the grace period. The behavior is documented in the README,--helpand the man page. If you'd prefer it configurable (e.g.--drain-timeout), or prefer a non-zero exit for this case, either is a small follow-up.Problem
If the server stops answering while requests are in flight, a
--test-timerun never finishes. After the deadline it stops sending, then waits for the outstanding replies with no timeout. The process has to be killed, so no final report is printed and the results from the part of the run that worked are lost (#657).Root cause
fill_pipeline()stops sending oncefinished()is true. The run ends only from the "done" check, which needsm_pending_resp == 0. Nothing bounds that wait, and--connection-timeoutonly covers the connect.finished()isn't even re-evaluated, becauseget_duration()advances only when stats are updated.run_benchmark()waits for the threads with no deadline.Fix
In
run_benchmark(), the main thread already ticks once a second. Once--test-time + 10 shas passed since launch, each tick it callsclient_group::end_stalled_clients()on every worker that is still running. That call does anevent_base_onceon the worker's base (safe across threads withevthread_use_pthreads()), so the work runs on the worker's own loop and also wakes it from an idle poll.On the worker,
client::abandon_unanswered_requests()ends any client whose own duration is pasttest_time + graceand that still has replies pending (!all_connections_idle()). It:shard_connection::drop_pending_requests()). Each workload request is logged to--failed-keys-fileasno-reply-after-test-timeand counted as an error and in the newUnanswered requestscounter. This follows the existingrun-ended-before-resendpath inclient::disconnect_all(). Setup commands are dropped but not counted. With--retry-on-error, the requests are not also held for a resend and counted again;start + test_time, so ops/sec covers the requested window and is not diluted by the grace period;The loop then runs out of events and the run reports as usual.
In staircase mode the step timer is freed once stalled clients are ended, so it cannot keep the loop alive until the next step.
run_statsgetsm_unanswered_requests(summed when client, thread and run stats are merged) and aget_start_time()accessor.request_type_to_name()in client.cpp is no longerstatic, so shard_connection can name the command in the failed-keys row.Scope and relation to #656: clients with nothing in flight are not touched. A client stuck reconnecting to a dead server (
--reconnect-on-errorwith unlimited attempts, #656) is owned by a separate fix in the reconnect timer code (#666). This PR does not touch the reconnect scheduling, so the two changes are independent. A test now checks that a reconnecting client is left alone.--requestsruns are unchanged: they have no deadline to measure a grace period from, so a general per-request timeout would be a separate feature.Interaction with #661: #661 (open) adds
connections_manager::abandon_requests()andshard_connection::abandon_replay_requests(). This PR does not depend on it. Whichever of the two lands second should switchdrop_pending_requests()and its accounting to the shared helper.Normal runs are unaffected. The check only fires 10 s after the deadline, on threads that have not ended (a plain
--test-time 3run still takes ~4 s wall time, as before). The JSONRuntimesection gains one field,"Unanswered requests", which is 0 in a normal run.Test evidence
tests/test_test_time_stalled_server.pyhas four cases. The stalled cases are 3 s all-SET runs with 2 threads.CLIENT PAUSE 600000 WRITEis sent on every master at 1.5 s, so the connections stay open but no SET is answered, and the test lifts it withCLIENT UNPAUSEat the end.test_test_time_ends_when_server_stops_replying(2×2 clients): memtier exits 0 within test_time + 10 + 10 s. The warnings cover all 4 clients. The number ofno-reply-after-test-timerows in--failed-keys-fileand the JSONUnanswered requestsboth equal the abandoned count from the warnings, and nothing else is in the file. JSONTotal duration< test_time + 2 s.test_test_time_stalled_server_retry_on_error: the same checks. In addition, the final progress-lineerrors Nequals the abandoned count (each request is counted exactly once), and the "held for retry" warning is absent.test_test_time_stalled_server_staircase:--clients-start=1 --clients-step=1 --step-duration=60, so the next step is due long after the deadline. The 2 active clients are ended, and the run ends in time.test_test_time_reconnecting_client_left_alone:CLIENT KILL TYPE normalat 1.5 s with--reconnect-on-error --reconnect-backoff-factor=15, so the reconnect is due after the grace period. No stall warning may be printed, and the run must last past test_time + 10 s (it ends through the reconnect).Mutation check (each mutant built and run against the full file, oss):
Unanswered requests)m_stats.inc_error()inabandon_unanswered_requests()errors0 ≠ abandoned)event_free(m_staircase_timer)inhandle_end_stalled_clients()-9)all_connections_idle()early return1 client(s) got no reply to 0 request(s)on both threads)On the first push, origin/master (0298524 / 66b58e7) failed the stalled cases on oss and oss-cluster (hung, killed). In cluster mode, the reconnect case sometimes needs a second 15 s backoff round (about 32 s instead of 17 s). origin/master shows the same timing, so that case waits up to 60 s.
Not killed by a test: removing
dec_reqs_generated()indrop_pending_requests(). That counter matters only for--requestsruns, which this path never ends.Affected versions
1.0.0 through 2.5.2 (latest) and master.
client::fill_pipeline()/finished()). The current "no pending responses" end check came in 1c6735f "Enable arbitrary commands to be run on cluster mode" (Enable arbitrary commands to be run on cluster mode #117), with the same semantics.Fixes #657
🤖 Generated with Claude Code
Note
Medium Risk
Changes benchmark shutdown and error accounting for time-limited runs when servers stall; normal completions are unaffected until after the grace window, but slow legitimate replies past 10s are abandoned like missing replies.
Overview
Fixes hung
--test-timeruns when the server stops answering in-flight requests by capping the post-deadline drain at 10 seconds (TEST_TIME_DRAIN_GRACE_SECS).After
test_time + 10sfrom benchmark launch, the main thread asks each still-running worker to callend_stalled_clients(), which ends clients that still have pending replies: pending workload requests are dropped viashard_connection::drop_pending_requests(), logged to--failed-keys-fileasno-reply-after-test-time, counted as errors (without double-counting under--retry-on-error), and summed in a new JSONRuntimefield Unanswered requests. The client’s reported end time is clamped tostart + test_timeso throughput metrics exclude the grace wait; stderr warns and the process still exits 0. Staircase ramp timers are torn down so they cannot keep the event loop alive. Clients with nothing in flight (e.g. waiting on reconnect) are left alone.README,
--help, and the man page document the behavior;tests/test_test_time_stalled_server.pycovers pause, retry-on-error, staircase, and reconnect cases.Reviewed by Cursor Bugbot for commit 7518ce9. Bugbot is set up for automated code reviews on this repo. Configure here.