Repository navigation
Time --connection-stage-timeout in microseconds, not whole seconds - #860
Merged
Merged
Conversation
The connection-stage supervisor stamped the run start and the first failure with tv_sec only and compared whole seconds. A run that started late in a second could abort after just over N - 1 seconds of a --connection-stage-timeout of N: the main loop polls once per second, and a poll a few milliseconds past a second boundary saw two elapsed seconds where barely one had passed. test_unowned_keys_survive_repeated_ redial (2 s budget, about 1.1 s of injected delays) fails this way about once in 40 runs, aborting after 1.01 s. Stamp both in microseconds and compare against the timeout in microseconds. The comparison moves to connection_stage_clock.h, and a unit test checks the boundary (1.02 s is not 2 s; exactly 2 s is). The "aborting after N seconds" message still reports whole seconds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- .gitignore: /connection_stage_clock_test, like the other unit tests. - The unit test checks a 5000 s timeout, so converting it to microseconds in 32 bits fails it. - Fix the run-start variable name in the supervisor comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 25, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Problem
--connection-stage-timeout=Ncan abort after just over N − 1 seconds.The supervisor stamps the run start and the first setup failure with
tv_seconly, and compares whole seconds. The main loop polls it once per second (sleep(1)). Suppose the run starts at 10.99 s and a poll lands at 12.01 s: the supervisor sees 12 − 10 = 2 seconds after 1.02 s, so a 2 s timeout trips.This makes
test_cluster_unowned_slots:test_unowned_keys_survive_repeated_redial(from #799) flaky. It has a 2 s budget against about 1.1 s of injected server delays and backoffs. It failed in #545'slibevent-compat (legacy, plaintext, standalone)cell:Locally it failed 3 times in 180 runs: 2 of 70 on #545, 1 of 40 on #832, and 0 of 70 on master. Every failure was this abort after about one second. Neither #545 nor #832 touches this code; the failure depends on where in the second the run starts.
Deterministic reproduction (from review): start memtier at set points late in a wall-clock second, against a server that accepts and never replies, with
--connection-stage-timeout=2. Master aborted early in 4 of 25 runs, after 1.016 s, still saying "2 seconds". With this PR none did; the fastest abort was 2.008 s.Fix
connection_stage_clock.h(connection_stage_timed_out()), so it can be unit-tested.Tests
tests/unit/connection_stage_clock_test(make check): a phase that started late in a second has not timed out 1.02 s later. It times out at exactly 2 s and reports whole elapsed seconds, has no start time before the first failure, and uses timestamps far from the epoch. A mutant that compares whole seconds fails it, and so does one that converts the timeout to microseconds in 32 bits (a 5000 s case).--connection-stage-timeout(connection setup rejection, cluster slots, unowned slots, reconnects, retries, CLI validation and others). Results are the same with and without the fix: 236 pass, and the one failure is the same pre-existingtest_memcache_meta_protocol:test_meta_unsupported_options_fail_before_connectionon both.🤖 Generated with Claude Code
Note
Low Risk
Localized change to connection-setup abort timing with dedicated unit tests; no auth or protocol behavior changes beyond more accurate timeout enforcement.
Overview
Fixes
--connection-stage-timeoutso it measures elapsed setup time in wall-clock microseconds instead of comparing wholetv_secvalues, which could abort after ~N−1 seconds when a phase started late in a second (flaky cluster setup tests).Adds
connection_stage_timed_out()inconnection_stage_clock.hand switches the connection-stage supervisor inmemtier_benchmark.cppto microsecond stamps (g_conn_stage_*_usec,conn_stage_now_usec()); user-facing abort text still reports whole elapsed seconds.connection_stage_clock_testis wired intomake checkto lock in boundary behavior (including large timeouts and year-2100 timestamps).Reviewed by Cursor Bugbot for commit e1a6c84. Bugbot is set up for automated code reviews on this repo. Configure here.