Skip to content

Disable the fail points a stateless test enables once it is over - #118863

Closed
alexey-milovidov wants to merge 5 commits into
masterfrom
disable-failpoints-after-test
Closed

alexey-milovidov wants to merge 5 commits into
masterfrom
disable-failpoints-after-test

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Related: #118877
Related: #118831
Related: #118832
Related: #118417

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Description

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. master spent 2026-09-06 to 2026-09-08 demonstrating it:

  • 04648_distributed_plan_task_error_propagation lost a race (fix: Report a distributed plan's root cause, not its exchange teardown error #118417) and got POCO_EXCEPTION where it expected CANNOT_SCHEDULE_TASK. Being a .sql test, it aborted there - before SYSTEM DISABLE FAILPOINT distributed_plan_record_failure_while_starting_tasks.
  • Every distributed-plan query for the rest of that job then failed at task start with 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 reported reenqueue 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. Only 04340 looked like a flake; nothing about it was.

So clickhouse-test now disarms, once a test that mentions a fail point is over and whatever its outcome, the fail points it left armed, in the finally that already resets the per-test environment. The source of truth is the server: system.fail_points reports 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 an EXPLAIN, or in a clickhouse-local invocation 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:

  • A sequential test (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.
  • A concurrent test shares the server with the tests running next to it, and a fail point armed by one of them must stay armed. So only the names this test arms with a literal SYSTEM ENABLE FAILPOINT <name> statement are disabled, and only if the server reports them armed. Comments are skipped, and a shell test that runs clickhouse-local anywhere 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 a trap is 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:

  • a no-parallel test that aborts right after SYSTEM ENABLE FAILPOINT dummy_failpoint leaves nothing armed, including a second fail point armed before it ran;
  • the same test run concurrently disarms dummy_failpoint and leaves the second fail point armed;
  • a concurrent test that only mentions dummy_failpoint in a comment disarms nothing;
  • over the whole 0_stateless suite the concurrent-mode scraping drops exactly the comment words (is, toggles, fails, already) and the two clickhouse-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 and 04340'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%29

Found from the master failed-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%20checks

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Workflow [PR]
Sync PR [sync-upstream/pr/118863]

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]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cffdd1d]

Summary: ✅


AI Review

Summary

This PR teaches clickhouse-test to auto-disarm failpoints after a stateless test finishes so one broken test does not poison later ones. The earlier raw-text false positives are fixed, but the current version still has two correctness gaps in the teardown logic, so I do not think it is ready to merge yet.

Findings

⚠️ Majors

  • [tests/clickhouse-test:2704] Concurrent cleanup still has no sound ownership model for failpoints. Static source scraping misses the two in-tree runtime-name tests 03100_lwu_29_concurrent_merges.sh and _v1, so they can still leak a failpoint on abrupt failure, and it also over-owns shared literal names such as slowdown_parallel_replicas_local_plan_read and parallel_replicas_wait_for_unused_replicas, which are used by multiple concurrent stateless tests. A test that fails before reaching its own SYSTEM ENABLE FAILPOINT can therefore disable another still-running test's failpoint in finally. Suggested fix: keep automatic disarming sequential-only until concurrent tests either self-clean or have unique/static ownership, or teach the harness a stronger ownership rule than file-text scraping.
  • [tests/clickhouse-test:4372] The disarm runs after self._cleanup(...), but _cleanup_database() still sends SHOW TABLES / DROP DATABASE to the shared server. A test that leaves drop_database_before_exclusive_ddl_lock armed, such as 03920_drop_db_hang_with_trx.sh when its shell trap does not run, can therefore block the harness cleanup path before disable_failpoints() executes. Suggested fix: disable leftover failpoints before any cleanup query that depends on the same server.
Final Verdict

⚠️ Request changes.

LLVM Coverage Report

Measured on commit cffdd1d.

Metric Baseline Current Δ
Lines 88.50% 88.50% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.70% 80.70% +0.00%

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

Full report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 8, 2026
Comment thread tests/clickhouse-test Resolved

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

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, disable_failpoints here collapses to a single SYSTEM DISABLE ALL FAILPOINTS and the name scraping goes away, which is strictly better in two ways I ran into while writing this:

  • 27 of the 170 stateless tests that arm a fail point build the name at runtime ($FP, ${FAILPOINT}), so no amount of scraping sees them. The single statement does not need the name.
  • Scraping also picks up names that only appear in prose or inside an EXPLAIN (fp, this_fail_point_does_not_exist), and disableFailPoint throws BAD_ARGUMENTS for an unregistered name. I just pushed a commit to keep quiet about those; with the new statement the question does not arise.

One thing worth your call when I make that change: 22 of those 170 tests are not tagged no-parallel, so calling DISABLE ALL FAILPOINTS after one of them could disarm a fail point that a test running next to it had just armed. I plan to send the statement only when the test ran non-concurrently, which covers the 146 no-parallel ones - including both tests from #118831 / #118832, which is where this started. Tagging the other 22 no-parallel instead would be more thorough but is a bigger change to make blind.

alexey-milovidov and others added 3 commits September 17, 2026 02:15
…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]>
Comment thread tests/clickhouse-test Resolved
Comment thread tests/clickhouse-test Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member Author

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.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Sent as #120809: the 15 stateless tests that enabled a fail point without disabling it now disable it explicitly (from a trap ... EXIT in the .sh ones), and a new failpoints_disabled_in_tests style sub-check requires every SYSTEM ENABLE FAILPOINT <name> under tests/queries/0_stateless to be matched by a SYSTEM DISABLE FAILPOINT <name> in the same test.

The check skips what cannot leak or is already correct: a test that arms fail points only inside clickhouse-local (process-global state that dies with the process), a disable whose name comes from a shell variable, and EXPLAIN SYSTEM ENABLE FAILPOINT, which arms nothing.

Leaving this one open for you to decide - the teardown here is superseded by that approach, so it can be closed.

groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Sep 20, 2026
`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]>
pull Bot pushed a commit to admariner/ClickHouse that referenced this pull request Sep 21, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-testing Test content only (no production code). pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant