Repository navigation
Do not fuzz the stateful fixture load in the flaky check - #117997
alexey-milovidov merged 3 commits into
Conversation
The `Stateless tests (amd_tsan, flaky check)` job livelocks while loading the stateful fixture. The statement that never returns is INSERT INTO test.hits_s3 SELECT * FROM test.hits The server logs normally for about 35 seconds, then emits nothing for about an hour; `--max_execution_time 1800` never fires, `SYSTEM FLUSH LOGS` returns SOCKET_TIMEOUT after its full 300 s, and `clickhouse stop` fails, so the process has to be killed for a core. The statement is terminated at its bound and the job fails without uploading a report, which discards the entire 50x re-run signal that check exists to produce. The flaky check is the only lane that arms ThreadFuzzer, and it arms it for the whole server lifetime: `functional_tests.py` appends the fuzzer config during INSTALL, so `THREAD_FUZZER_CPU_TIME_PERIOD_US=1000` is already in the server's environment when it starts. The `ThreadFuzzer` constructor then self-arms a process-wide `setitimer(ITIMER_PROF)` plus a SIGPROF handler, and nothing in this lane ever stops it. `ITIMER_PROF` bills process CPU, so with hundreds of threads the signal rate is roughly one per millisecond of aggregate CPU. Under ThreadSanitizer every signal delivery enters `CallUserSignalHandler`, which takes a per-thread sanitizer slot before dispatching, and the deliveries that reach the fuzzer's handler sleep inside it and then re-attach a slot. TSan has 255 usable slots against the 684 live threads seen in the thread dump from a wedged job, so threads block in `FindSlotAndLock` waiting for a slot held by a thread that is itself blocked in a signal handler. 576 of those 684 threads are stopped on exactly that, and no thread in the dump is running ClickHouse code, which is why nothing logs, no timeout fires and no query is answered. `ThreadFuzzer.cpp` already compiles its `pthread_mutex_*` injection out under `THREAD_SANITIZER`, and the dump confirms that half is inert. The SIGPROF path sits outside every sanitizer guard and is the only live mechanism there. Nothing asserts anything about the fixture load, so fuzzing it buys no race-detection signal while being able to discard the whole job's signal. This stops the fuzzer for the duration of `prepare_stateful_data` and starts it again immediately afterwards, in the flaky check only. It is the same scoping the stress runner already applies to this very statement: `stress_runner.sh` exports the same fuzzer environment, starts the server, runs `SYSTEM STOP THREAD FUZZER`, and only then creates and loads `test.hits_s3`. Both new statements sit inside the prep script, so they inherit its `set -e`, its ERR trap and its per-statement `timeout` bound; no new error handling is added. Re-arming restores the previous state exactly rather than approximately, because the constructor's arming condition and `start()`'s are the same predicate. For every other lane the flag is 0 and both guards are inert: rendering the prep script with the flag off and executing it against a stub client produces an argv log byte-identical to the one master's rendering produces. Two things this deliberately does not change. `SYSTEM STOP THREAD FUZZER` clears a flag but leaves the SIGPROF timer armed, so the cost of delivering the signal is not removed, only the sleeping inside the handler. And the underlying interaction between a signal-driven fault injector and the sanitizer's slot table stays latent for any future phase that runs more threads than there are slots.
The comment added beside `stop_thread_fuzzer=is_flaky_check` justified the fix rather than the code: its second and third lines described the slot exhaustion that motivated the change, so a reader had to go to `git blame` to make sense of them. It also named the sanitizer, while the flag is not sanitizer-conditional - it is set for all five flaky lanes, including the debug and binary ones, where the fuzzer costs the same fixture load 33x and 23x with no sanitizer involved. The replacement states two standing properties of the code instead: that this lane is the only one that arms the fuzzer, and that the fixture load is setup rather than a test, which is why stopping the fuzzer across it loses no signal.
The comment I added in 0d48000, and that commit's own message, claimed the flaky check is the only lane that arms `ThreadFuzzer`. That is wrong repo-wide, and 0d48000 refutes itself further down by describing the stress runner doing the same thing: `tests/docker_scripts/stress_runner.sh` arms the fuzzer unconditionally at :21-23 and stops it at :96, and `tests/integration/helpers/cluster.py` arms it per instance on request (`DEFAULT_THREAD_FUZZER_SETTINGS` at :113, applied at :640 under `enable_thread_fuzzer`). The narrower claim is true, and it is the one that justifies the gate: of the lanes this job runs, only the flaky check arms the fuzzer, because `enable_thread_fuzzer_config` is appended only under `if is_flaky_check:` (`ci/jobs/functional_tests.py:985-986`) and that is its sole caller. The comment now states that. I also reformatted the `prepare_stateful_data` signature to `black` output, so the parameter added by 0d48000 does not leave a formatting deviation inside this change. Report for the failure this addresses: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110321&sha=2def28ac1fbdc8166d4e6c37c00ab830b4248148&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 ClickHouse#110321
|
Reviewed before publication: my own cold pass plus an independent model pass over the diff. This reverses something I said. On 2026-08-31, on #110321, I reported that I had tried
Two limitations worth stating rather than leaving to be found. The wedge itself did not reproduce The last commit is comment text and a signature reformat only. I checked it is inert ( |
|
Workflow [PR], commit [5ac8517] Summary: ✅ AI ReviewSummaryThis PR brackets Missing context / blind spots
Final Verdict✅ No review findings at the current head. LLVM Coverage Report |
|
cc @maxknv, could you review this? Of the lanes that run |
336d7d2
Related: #110321 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The stateful fixture preparation in the flaky check no longer runs with
ThreadFuzzerarmed.Description
@ alexey-milovidov asked me to investigate a
Stateless tests (amd_tsan, flaky check)setup failure on #110321 and fix it separately (report):prepare_stateful_datawas terminated at its bound onINSERT INTO test.hits_s3 SELECT * FROM test.hits, so the job produced no signal. It recurred on #117831 (report); 8 in 90 days, all in that lane.Of the lanes that run
functional_tests.py, only the flaky check armsThreadFuzzer, and for the server's whole lifetime: the config is appended during INSTALL, soTHREAD_FUZZER_CPU_TIME_PERIOD_US=1000is set before the server starts, the constructor self-arms a process-widesetitimer(ITIMER_PROF), and nothing in this lane stops it. So the fixture load is fuzzed although nothing asserts on its interleaving, and pays 7.8x to 33x where it finishes (below). Under TSan there is no ceiling: each delivery takes one of 255 thread slots before dispatch, and one sleeping in the handler re-attaches one. In a wedged job's dump 576 of 684 threads sit inSlotLock, none in ClickHouse code; unfuzzed, the same TSan build runs it in 217 s.This stops the fuzzer across
prepare_stateful_dataand starts it after, in the flaky check only, astests/docker_scripts/stress_runner.shalready does before loading that table.Validation: with the flag off the rendered script's argv log is byte-identical to master's; a mutant arm proves that check is not blind; the re-arm measures 3.00x, control 1.05x.
Not shown: the wedge did not reproduce locally (3 arms, 732-878 threads, fuzzer active, all completed), so the lane comparison is the attribution evidence; I do not claim the wedge fixed. This PR touches no test file, so the flaky lanes skip and its own CI never runs the new statements.
SYSTEM STOP THREAD FUZZERleaves the SIGPROF timer armed; the stress lane runs that state and loads the same table in 91-155 s, so I left it.Measurements
Cost of
INSERT INTO test.hits_s3 SELECT * FROM test.hits, from the job logs of one commit (PR 117831,24803f871cdf465dac768070f6e1326256647773):amd_debug, parallel)amd_binary_excluded_from_llvm)amd_asan_ubsan, distributed plan, parallel, selected tests)amd_tsan, parallel, selected tests), 291 s (sequential, selected tests)The controlled pair is the 217 s lane against the flaky check: both are
m7i.8xlarge, both reporttest.hits= 8,873,898 rows, and the statement andmax_insert_threads=4are identical. The 291 s lane ran on anm7i.2xlarge, and the debug and binary rows compare different instance types, so read those as the size of the tax rather than as controls.Occurrences: CIDB, 90 days, job-level rows of the flaky-check lanes (
test_name = ''). 6 runs where the last recorded output is the preparation's owntpcdstable listing, at 9013-9055 s (the whole job budget), plus the 2 bounded ones after #115585 at 4365 s and 4513 s. All 8 areStateless tests (amd_tsan, flaky check), and the same two predicates over every otherStateless tests (%lane return nothing.Workflow [PR]
Sync PR [sync-upstream/pr/117997]
Version info
26.9.1.1367(included in26.9and later)