Repository navigation
End a --test-time client at its last reply when the server stalls after the deadline - #876
Merged
Merged
Conversation
…er the deadline With --reconnect-on-error, a --test-time client that got replies, all before its deadline, and then stalled had its end time stamped at "now" by client::set_end_time() when its reconnect after the deadline completed. #867 capped this only for a client that never had a reply, since the time past the deadline can cover replies drained after it. So Total duration came out above --test-time and Ops/sec was deflated. With one client served normally and one answered 20 times and then held past a 4 s deadline, the run reported about 5100 ms and 82 ops/sec (5600 ms and 75 with --max-reconnect-attempts=5) instead of 4000 ms and 105. Record when each client's last reply was read, from the timestamp process_response() already takes for handle_response(), so a reply costs no extra clock read. Once a client's own start plus --test-time is past, end it at that deadline or at its last reply, whichever is later, and no later than now. Replies drained after the deadline still count, but the idle time after them does not. The deadline stays the client's own start, as in #867: for a client with replies run_deadline() is the same time, and for one without it would inflate Ops/sec for a late start. In cluster mode the last reply is per client, whichever shard it came on. A client that never submitted stays out of the average, and --requests runs have no deadline. end_client_after_run() is unchanged, so a run whose server is gone after the deadline still fails (#666). test_answered_end_time.py runs the stalled client against a scripted peer, standalone and with two cluster shards (answered on one, held on the other), with unlimited and finite reconnect attempts. A third case answers the held request past the deadline and then idles the client behind a second one, so it ends at that reply, not at the deadline or at the reconnect. Fixes #870 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The fix is small, it reuses the
The core change looks solid to me. I'd mainly want the scope of the duration change spelled out before this merges. (would file this as a comment, not a formal block) |
This was referenced Oct 25, 2026
…t a setup reply No case pinned two rules of the previous commit: the last reply is the client's, whichever shard it came on, and a setup reply (AUTH, SELECT, CLUSTER SLOTS, HELLO, READONLY) is not one. A last reply kept per shard connection, or one that setup replies also move, passed every case. The new "split" case gives B two shards, with --key-pattern=S:S over memtier-1 and memtier-2 so its SETs alternate between them. After B's 20th reply the first shard's connection is closed, and its reconnect's AUTH is held until A has closed plus 2 s. B's next SET on the second shard is answered at A's close plus 1 s. B ends from the first shard once its setup completes, at the late reply on the second: about 3500 ms. A per-connection last reply gives about 3000 ms, and counting the AUTH reply about 4000. Reword the README and the set_end_time() comment: replies drained after the deadline count and the idle time after the last one does not; with --retry-on-error a resent request answered after the reconnect moves the end to its reply; and a client whose reconnect setup stalls past its deadline can still send new requests once it completes, whose replies extend its end (#879). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…line test_worker_failure_after_timed_deadline_is_partial checked that the failed run's Total duration was above 1000 ms. Its peer answers three requests and drops the fourth 1.3 s in, so the duration used to be the drop time. The client's last reply came before its 1 s deadline, so it now ends at the deadline: exactly 1000 ms, and Coverage shard 4/8 failed on 1000 > 1000. Check that it ends at the deadline, not at the drop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The split case failed when B's first SET after its 20th reply went to the second shard, which held it. A key generated for the second shard then queued behind the held SET, and the two filled B's in-flight budget (--pipeline times its 2 connections). B sent nothing more on the first shard, so that connection was never closed and its reconnect's AUTH never held (b_held 0, no "connection dropped"). B still ended at the late reply, at 3500 ms, but from the second shard, so neither a per-connection last reply nor a counted setup reply could change the result. This showed in the UBSan OSS-CLUSTER cell, and in 3 of 10 local runs with memtier at nice 19 on one CPU with 2 busy loops. B reached its 20 replies about 2.6 s before its deadline, so this was not about slow start-up. Hold nothing on the second shard until the first is closed: B's SETs there are answered normally until then, and the next one after it is held and answered late. The peer now sets the order in both cases. The per-connection mutant still gives 3000 ms, and the one that counts setup replies 4000. The README bullet that states the drain rule now notes that a failed reconnect, Ctrl+C and the drain grace still end the client at its deadline (#880). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
Review summary for a2374bd. All 7 lenses approve (semantics, output, tests, lifecycle, interactions, maintainability, build).
Answering the review:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #870.
Problem
With
--reconnect-on-error, a--test-timeclient that got replies, all before its deadline, and then stalled had its end time stamped at "now" byclient::set_end_time()when its reconnect after the deadline completed. #869 capped this only for a client that never had a reply, soTotal durationstill came out above--test-timeandOps/secwas deflated.Change
Last reply time: each client records when its last reply was read. It reuses the timestamp
process_response()already takes, so a reply costs no extra clock read.End time: once the client's own start plus
--test-timeis past, the client ends at that deadline or at its last reply, whichever is later, and never later than now. Replies drained after the deadline still count; the idle time after them doesn't.Deadline: the client's own start, as in End a --test-time client that never had a reply at its deadline #869. For a client with replies,
run_deadline()gives the same time.Unchanged:
--requestsruns have no deadline.end_client_after_run()doesn't change, so a run whose server is gone after the deadline still fails (End a --test-time run at its deadline while reconnecting to a dead server #666).Scope: this applies to every answered
--test-timeclient past its deadline, not only one stalled on a reconnect. A healthy client ends in the same callback as its last reply, so it barely changes. A rate-limited client that ends on a timer tick after its deadline no longer counts the gap after its last reply, soTotal durationandOps/secfor ordinary rate-limited timed runs can move by up to one rate tick compared with 2.5.x.Results
Total duration in ms; every run exits 0. The standalone rows use
--test-time=4, the others--test-time=3.--max-reconnect-attempts=5Tests
tests/test_answered_end_time.py: 6 cases, all failing on master:run_deadline()one only intest_unanswered_end_time.py): always capping at the deadline,run_deadline()instead of the client's own start, no cap,minformax, a per-connection last reply, and setup replies moving the last reply.tests/test_run_count_partial_ranking.py: a run whose worker drops a held request after its deadline now ends at the deadline, not at the drop, so its duration bound is now 1000 to 1200 ms instead of above 1000.test_unanswered_end_time.pyis unchanged and its drain case still passes. The related tests pass 64/64, including End a --test-time run at its deadline while reconnecting to a dead server #666's server-gone run, which still exits 1.make checkpasses 18/18.Performance
Measured on a quiet Xeon 6972P host (gnr1): local Redis 8.2.2, plain TCP loopback, 8 threads × 25 clients, ratio 1:10, arms interleaved, 8 runs per arm.
GET p50 and p99 move by at most one 8 µs histogram bucket, and instructions per op rise by 0.03%. Both are within run-to-run noise.
Not covered here
finished()reads a stats clock that only replies move). This affects every release with--reconnect-on-error.Affected versions
Every release: up to 2.5.2,
set_end_time()always stamps "now". On master, 0bb7fc5 (#666) caps answered clients only inend_client_after_run(), which this path doesn't reach.🤖 Generated with Claude Code
Note
Medium Risk
Changes core
--test-timeduration and Ops/sec accounting for clients with replies under reconnect/stall scenarios; behavior is well-tested but affects reported benchmark metrics.Overview
Fixes #870:
--test-timeclients that already received replies no longer stretch Total duration to a post-deadline reconnect completion when the server stalls after--reconnect-on-error.Each client now tracks
m_last_reply_timewhen replies are read (inc_reqs_answeredtakes the existinghandle_responsetimestamp).client::set_end_time()sets the interval to max(client start +--test-time, last reply), capped at now—so late drained replies count, but idle wait after the last reply does not. Clients with no replies still end at their deadline (#867 behavior).README documents the updated duration rules (including
--retry-on-errorand #879/#880 caveats). Tests: newtests/test_answered_end_time.py(stalled, cluster, late reply, split-shard scenarios) and tighter bounds intest_run_count_partial_ranking.py.Reviewed by Cursor Bugbot for commit a2374bd. Bugbot is set up for automated code reviews on this repo. Configure here.