Repository navigation
Don't report a worker that already ended as a --connection-stage-timeout abort - #891
Merged
Merged
Conversation
…out abort run_benchmark() sleeps one second, asks the connection-stage supervisor whether to abort, and only then counts the workers still running. A worker that failed on its own during that sleep, before any connection reached steady state, was therefore also reported as an abort when the timeout had expired by that poll. memtier printed both the worker failure and "aborting after N seconds of connection-stage failures" and exited 2 instead of 1. This made test_cli_fuzz_phase1.py's #8 case (--data-size-range 1-9999999999) flaky on TSAN: Redis rejects the oversized SET with -ERR Protocol error and resets the connection about 4 s later, and the supervisor's 6 s budget, measured in whole seconds from the run start, expired at the next poll. Locally 3 of 8 TSAN runs exited 2, and 10 of 10 plain runs did when memtier shared one CPU with two busy loops. Skip the supervisor when no worker is running. The loop then sees no active thread and the run reports how its workers ended. test_connection_stage_worker_ended.py runs memtier with --connection-stage-timeout=1 against a scripted peer that closes the connection without replying 0.2 s after the first command, so the worker fails before the first poll, which is the one where the timeout has expired. It exits 2 without this fix and 1 with it. Fixes #890 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The supervisor is skipped only when no worker is running. Nothing checked the "no" part: test_connection_stage_worker_ended.py ran one thread, where "any worker running" and "every worker running" are the same condition. With the latter, a run with one failed worker never polls the supervisor again, and a worker stuck in setup keeps it waiting forever, which is the hang that --connection-stage-timeout exists to bound. Add a case with four threads: the scripted peer closes three connections 0.2 s after their first command and never answers the fourth. With --connection-stage-timeout=1 memtier must exit 2 with the abort hint, in well under 15 s. The subprocess timeout is 30 s, so a hang fails the test instead of stalling the suite. The case takes about 1.5 s; with "every worker running" memtier is still running at 30 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
Owner summary at 3e81db5: all 7 lenses approve (SEM, OUT, TEST, BUILD, LIFE, INTER, MAINT).
🤖 Generated with Claude Code |
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 #890.
Problem
run_benchmark()sleeps one second, asks the connection-stage supervisor whether to abort, and only then counts the workers still running. Suppose a worker fails on its own during that sleep, before any connection reaches steady state, and the timeout has expired by the next poll. The run is then also reported as an abort: memtier prints both the worker failure andaborting after N seconds of connection-stage failures, and exits 2 instead of 1.That made case #8 of
test_cli_fuzz_phase1.py(--data-size-range 1-9999999999) flaky on TSan. It failed this way in #886's CI:-ERR Protocol error, which counts as a connection rejection.Change
The supervisor is checked only while at least one worker is still running. When none is, the loop sees no active thread and the run reports how its workers ended.
One more case changes: a worker that ends cleanly without ever reaching steady state, e.g. a
--requestsrun whose only replies were connection rejections, now exits 0 where it used to exit 2. That happens because rejection replies already count as processed requests, which is a separate, existing rule (#686/#788). Tracked in #894.Results
Case #8's own arguments, against a local redis-server 8.6.0. The counts are runs that exited 2:
* A correct abort, not this bug: no worker failure was printed. Redis reset the connection about 2.9 s in, right at the 3 s budget, so the worker was still in setup when the timeout fired.
Tests
tests/test_connection_stage_worker_ended.pyruns--connection-stage-timeout=1against a scripted peer that closes the connection without replying 0.2 s after the first command. This makes the race deterministic. The test fails 5/5 on master (plain and TSan), and passes 10/10 plain and 5/5 TSan with this PR.test_worker_still_in_setup_is_supervisor_abortuses 4 threads. The peer closes 3 connections and never answers the 4th, so the run must still abort with exit 2 at the timeout. A variant that skips the supervisor unless all workers are running hangs here, and passed every other test.test_cli_fuzz_phase1.pyfile plus the new test passed 8/8 in each of 3 runs at 587f123, before the second case was added, on a TSan build with the workflow's settings, with no TSan reports.make checkpasses 18/18.Affected versions
The check order dates from 2e8869e (#431), in 2.4.0 through 2.5.2. The exit-1 worker-failure path it collides with came in with 7a6394e (#546), which no release tag contains. So the visible bug is on master only.
🤖 Generated with Claude Code
Note
Medium Risk
Touches main benchmark loop exit semantics around connection-stage supervision; behavior change is narrow but affects process exit codes and when runs are aborted vs. reported as worker failures.
Overview
Fixes a race where
--connection-stage-timeoutcould label a run as a supervisor abort (exit 2) even when every worker had already failed on its own (exit 1).After the main loop’s one-second sleep,
run_benchmark()now checks whether any worker thread is still running before callingconnection_stage_should_abort(). If all workers have finished, the supervisor is skipped so the process reports the workers’ natural outcome instead of printing aborting after N seconds of connection-stage failures. When at least one worker is still stuck in connection setup, the timeout path is unchanged.Adds
tests/test_connection_stage_worker_ended.py: a scripted TCP peer that closes early vs. leaves a worker hanging, asserting exit 1 without the timeout message in the first case and exit 2 with the message when one worker remains in setup.Reviewed by Cursor Bugbot for commit 3e81db5. Bugbot is set up for automated code reviews on this repo. Configure here.