Repository navigation
Disable the fail points a stateless test enables once it is over - #118863
alexey-milovidov wants to merge 5 commits into
Conversation
A fail point armed with `SYSTEM ENABLE FAILPOINT` is server-wide: it is scoped neither to the session nor to the database that armed it. A test that never reaches its own `SYSTEM DISABLE FAILPOINT` leaves it armed for every test that runs after it against the same server. A `.sql` test stops at its first unexpected error, so an unexpected error anywhere before the `DISABLE` is enough; a `.sh` test can exit early or be killed on timeout. The test that then fails is not the test that is broken, which makes this the hardest kind of CI failure to attribute. Seen on `master` between 2026-09-06 and 2026-09-08: `04648_distributed_plan_task_error_propagation` lost a race and aborted before its `SYSTEM DISABLE FAILPOINT distributed_plan_record_failure_while_starting_tasks`, so every distributed-plan query for the rest of the job failed at task start, and `04340_distributed_plan_status_reenqueue_fault` - eight minutes later in the same job - never reached a status re-enqueue and reported `reenqueue fault handled: 0`. The two failed together in every failing run of `Stateless tests (arm_asan_ubsan, azure, sequential)`, about 25 times a day each, and got separate "flaky test" issues. So `clickhouse-test` now disables the fail points named in a test file once that test is over, whatever its outcome. `SYSTEM DISABLE FAILPOINT` is idempotent and accepts a name that is not armed - or that no build knows at all - so a name picked up from a comment or from an `EXPLAIN` is harmless. Only literal names are matched; a test that builds the name at runtime still has to disable it itself. Example of the leak: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=1dd29f83596b117a895338eabb68bcec75042885&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20sequential%29 Related: #118831 Related: #118832 Related: #118417 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [cffdd1d] Summary: ✅ AI ReviewSummaryThis PR teaches Findings
Final VerdictLLVM Coverage ReportMeasured on commit cffdd1d.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +175 lines in 47 files (-102 lines lost coverage) · Details |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Can we do something like SYSTEM DISABLE ALL FAILPOINTS?
If this feature does not exist, send another PR with it.
`FailPointInjection::disableFailPoint` throws `BAD_ARGUMENTS` for a name it does not know, so the names scraped out of prose or out of an `EXPLAIN` - `fp`, `this_fail_point_does_not_exist`, and a handful of English words - each produced a warning. Those names never armed anything, so skip them silently and keep the warning for a server that actually stopped answering. This goes away entirely once `SYSTEM DISABLE ALL FAILPOINTS` (#118877) is in: the whole function becomes that one statement, with no names to scrape. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
It did not exist - added in #118877. Not switching this PR over yet only because CI does not run for a pull request based on another feature branch. Once #118877 is in,
One thing worth your call when I make that change: 22 of those 170 tests are not tagged |
…raw test text The review pointed out that scraping `SYSTEM ENABLE FAILPOINT <name>` out of the test source disables fail points on the wrong process: a name inside a `clickhouse-local` invocation (`04658_disable_unknown_fp_name.sh`, `04654_delta_lake_predicate_untranslatable_under_not.sh`) never touched the shared server, and a name in a comment (`is`, `toggles`, `fails`, `already`) is not a fail point at all. Now `system.fail_points` is the source of truth: only names the server reports armed are ever disabled. Which of them belong to the finished test depends on how it ran. A sequential test owns the server, so every armed fail point left behind is its own leftover; this also covers the 27 tests that build the name at runtime. A concurrent test shares the server, so only the names it arms with a literal statement are disabled, and only if armed. That scraping now skips comments and returns nothing for a shell test that runs `clickhouse-local` anywhere, since a query string spanning several lines or a shell wrapper defeats any line-by-line attribution. Because nothing is sent for a name the server does not report armed, the special cases for `Cannot find fail point` and for a build without FIU are gone. Verified against a local server: a `no-parallel` test that aborts after arming `dummy_failpoint` leaves nothing armed; a concurrent one disarms `dummy_failpoint` but leaves a fail point armed by someone else alone; a test that only mentions the name in prose disarms nothing. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
This does not sound like a good approach, because tests can run in parallel. What if, instead, we add SYSTEM DISABLE FAILPOINT explicitly in all tests that miss that? And also add a style check for that. Let's send another PR with these changes. |
|
Sent as #120809: the 15 stateless tests that enabled a fail point without disabling it now disable it explicitly (from a The check skips what cannot leak or is already correct: a test that arms fail points only inside Leaving this one open for you to decide - the teardown here is superseded by that approach, so it can be closed. |
`SYSTEM ENABLE FAILPOINT` arms a fail point for the whole server, and the only way to undo it is to name it again. Whoever needs a server that injects nothing has to know what somebody else armed, which a test harness cannot: a `.sql` test stops at its first unexpected error and a `.sh` test can be killed on timeout, so the name is exactly what is missing at that point. `SYSTEM DISABLE ALL FAILPOINTS` disables every registered fail point and resumes whoever is blocked on a pauseable one, the same way `SYSTEM DISABLE FAILPOINT` does for a single name. It takes no argument and, like the other `SYSTEM ... FAILPOINT` statements, no `ON CLUSTER` - fail points are node-local state. It requires the same `SYSTEM FAILPOINT` grant, and it is a no-op rather than an error in a build without libfiu, where nothing can be armed in the first place: failing it would only make every caller special-case a build flag to ask for a state that already holds. Suggested in the review of ClickHouse#118863, which is where the harness will use it. Related: ClickHouse#118831 Related: ClickHouse#118832 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A fail point lives in the server process, not in the connection or the session, so one that a test enables and never disables goes on firing in whatever runs next. The stateless suite runs tests in parallel, so that is another test's query: it fails, or hangs on a pauseable fail point, for a reason that is nowhere in its own source, and the report blames the wrong change. Add the missing `SYSTEM DISABLE FAILPOINT` to the 15 tests that had none, and a `failpoints_disabled_in_tests` style sub-check that requires every `SYSTEM ENABLE FAILPOINT <name>` under `tests/queries/0_stateless` to be matched by a `SYSTEM DISABLE FAILPOINT <name>` in the same test. A `ONCE` fail point disarms itself when it fires, but nothing guarantees the test reaches the code path that consumes it - on the version the test was written against it does not fire at all - so those are disabled explicitly too. In a `.sh` test the disable goes into a `trap ... EXIT`, since an early `exit` or a failing command under `set -e` skips the rest of the file. The check leaves alone what cannot leak or is already correct: a test that arms fail points only inside `clickhouse-local`, whose process-global state dies with the process; a disable whose name comes from a shell variable, which no text check can resolve; and `EXPLAIN SYSTEM ENABLE FAILPOINT`, which prints the parsed statement and arms nothing. Asked for in ClickHouse#118863 (comment) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Related: #118877
Related: #118831
Related: #118832
Related: #118417
Changelog category (leave one):
Description
A fail point armed with
SYSTEM ENABLE FAILPOINTis server-wide: it is scoped neither to the session nor to the database that armed it. A test that never reaches its ownSYSTEM DISABLE FAILPOINTleaves it armed for every test that runs after it against the same server. A.sqltest stops at its first unexpected error, so an unexpected error anywhere before theDISABLEis enough; a.shtest can exit early or be killed on timeout.The test that then fails is not the test that is broken, which makes this the hardest kind of CI failure to attribute.
masterspent 2026-09-06 to 2026-09-08 demonstrating it:04648_distributed_plan_task_error_propagationlost a race (fix: Report a distributed plan's root cause, not its exchange teardown error #118417) and gotPOCO_EXCEPTIONwhere it expectedCANNOT_SCHEDULE_TASK. Being a.sqltest, it aborted there - beforeSYSTEM DISABLE FAILPOINT distributed_plan_record_failure_while_starting_tasks.Injected task failure while starting tasks.04340_distributed_plan_status_reenqueue_fault, eight minutes later in the same job, therefore never started a task, never reached a status re-enqueue, and reportedreenqueue fault handled: 0.Both tests failed together in every failing run of
Stateless tests (arm_asan_ubsan, azure, sequential), about 25 times a day each, and each got its own "flaky test" issue. Only04340looked like a flake; nothing about it was.So
clickhouse-testnow disarms, once a test that mentions a fail point is over and whatever its outcome, the fail points it left armed, in thefinallythat already resets the per-test environment. The source of truth is the server:system.fail_pointsreports which fail points are armed right now, and only those are ever disabled. The test file is not trusted to say what the test armed - a name in prose, in anEXPLAIN, or in aclickhouse-localinvocation never touched the shared server, and a name built at runtime ($FP) is invisible to any scraping.Which of the armed fail points belong to the finished test depends on how it ran:
no-parallel, or the whole run with--jobs 1) owns the server for its duration, so every fail point still armed when it finishes is its own leftover. This covers both tests from Flaky test: 04648_distributed_plan_task_error_propagation #118831 / Flaky test: 04340_distributed_plan_status_reenqueue_fault #118832 and also the 27 of the 170 fail-point tests that build the name at runtime.SYSTEM ENABLE FAILPOINT <name>statement are disabled, and only if the server reports them armed. Comments are skipped, and a shell test that runsclickhouse-localanywhere contributes no names, since a query string spanning several lines or a shell wrapper around the invocation defeats any line-by-line attribution. A concurrent test that builds the name at runtime still has to disable it itself, for which atrapis the usual way.Nothing is sent for a name the server does not report armed, so a build without FIU (no registered fail points) and a name that is not a fail point never produce a statement or a warning. #118877 adds
SYSTEM DISABLE ALL FAILPOINTS; once it is in, the sequential branch can become that one statement.Verified against a local server:
no-paralleltest that aborts right afterSYSTEM ENABLE FAILPOINT dummy_failpointleaves nothing armed, including a second fail point armed before it ran;dummy_failpointand leaves the second fail point armed;dummy_failpointin a comment disarms nothing;0_statelesssuite the concurrent-mode scraping drops exactly the comment words (is,toggles,fails,already) and the twoclickhouse-local-only tests (04654,04658), and loses no name that a test really arms on the server.Example of the leak -
04648's abort at 18:57:20 and04340's three poisoned queries at 19:05:50 are both in that job's server log: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=1dd29f83596b117a895338eabb68bcec75042885&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20sequential%29Found from the
masterfailed-checks dashboard: https://play.clickhouse.com/play?run=1&color_modes=%7B%22ppm%22%3A%22none%22%2C%22test_name%22%3A%22categorical%22%7D&tab=Failed%20checksDocumentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/118863]