Skip to content

Disable every fail point a stateless test enables, and check it in style - #120809

Merged
alexey-milovidov merged 3 commits into
masterfrom
explicit-disable-failpoint-in-tests
Sep 21, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
explicit-disable-failpoint-in-tests

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Related: #118863

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.

This adds the missing SYSTEM DISABLE FAILPOINT to the 15 stateless tests that had none, and a failpoints_disabled_in_tests sub-check to the style 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, in either direction;
  • EXPLAIN SYSTEM ENABLE FAILPOINT, which prints the parsed statement and arms nothing.
  • a test whose cleanup is SYSTEM DISABLE ALL FAILPOINTS, which disarms every fail point at once - credited only in a no-parallel test, because it also disarms what the tests running alongside armed, the way SYSTEM DROP does in various_checks.sh.

This replaces the approach in #118863, where clickhouse-test disarmed the fail points a test left behind: as noted there, that cannot be made safe while tests run in parallel, because the teardown of one test would disarm a fail point another test is relying on.

Tests changed: 02769, 02887, 02943, 03100_lwu_29 (both variants), 03622, 03753, 03787, 03810, 04009, 04024, 04028, 04421, 04506, 04652.

Changelog category (leave one):

  • CI Fix or Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.364-master (included in 26.10 and later)

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 #118863 (comment)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d94c1fd]

Summary: ✅


AI Review

Summary

This PR adds explicit SYSTEM DISABLE FAILPOINT cleanup to older stateless tests and introduces a new failpoints_disabled_in_tests style sub-check. The test cleanups are directionally correct, but the new checker still has two real parser gaps: it treats # / #! SQL comments as live failpoint statements, and it drops quoted heredoc bodies passed to clickhouse-client, so one common shell form still bypasses the guard.

Findings

⚠️ Majors

  • [ci/jobs/check_style.py:396] strip_sql_comments strips only /* ... */ and --, but ClickHouse SQL comments also use # and #!. That means a harmless line like # SYSTEM ENABLE FAILPOINT foo is currently parsed as a real enable and will spuriously require a matching disable. 0_stateless already uses this comment form heavily (for example tests/queries/0_stateless/02192_comment.sql), so this is a real false positive in the new check.

  • [ci/jobs/check_style.py:680] The .sh path reuses executable_shell_content, which drops quoted heredoc bodies wholesale. A test written as ${CLICKHOUSE_CLIENT} <<'SQL' ... SYSTEM ENABLE FAILPOINT foo ... SQL still talks to the shared server, but this code sees only the client invocation and never sees the failpoint statement, so the new sub-check silently misses the leak. Quoted client heredocs are already common in 0_stateless (for example tests/queries/0_stateless/00565_enum_order.sh, tests/queries/0_stateless/04260_wasm_abi_buffered_buffers.sh, and tests/queries/0_stateless/05145_join_disjunctions_push_down_wasm_udf.sh), so this is a real bypass, not an edge case.

Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  • Make the SQL-side scan discard # / #! comments before matching failpoint statements.
  • Make the shell-side scan preserve quoted heredoc bodies when they are stdin to a server client, or replace the reuse of executable_shell_content with a failpoint-specific parser.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 18, 2026
Comment thread ci/jobs/check_style.py
if test_case.endswith(".sh"):
# Drop comments, `echo` payloads and `clickhouse-local` invocations, so only the
# statements that reach the server are left.
content = executable_shell_content(file_content.splitlines())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This new sub-check still misses one common server-query carrier: a quoted heredoc fed to clickhouse-client. executable_shell_content drops quoted heredoc bodies entirely, so a test like

$CLICKHOUSE_CLIENT <<'SQL'
SYSTEM ENABLE FAILPOINT foo;
SELECT 1;
SQL

still reaches the shared server but produces enabled = [] here. Quoted client heredocs are already common in 0_stateless, so the next failpoint test written in that form will bypass the guard and can leak a server-global fail point again.

For this check we need to keep quoted heredoc bodies when they are stdin to a server client, or use a failpoint-specific shell parser instead of reusing executable_shell_content from the server-data check.

Comment thread ci/jobs/check_style.py
as well; no check here reads such a literal.
"""
text = SQL_BLOCK_COMMENT_RE.sub(" ", text)
return "\n".join(line.split("--")[0] for line in text.splitlines())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

# and #! are also ClickHouse SQL comments, and 0_stateless already has many .sql tests that use them. This helper only strips /* ... */ and --, so a commented-out line like # SYSTEM ENABLE FAILPOINT foo is treated as a live enable and will spuriously require a matching disable.

If this function is going to be the source of truth for failpoint scanning, it needs to discard # comments too.

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 18, 2026

@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.

This is great!

@alexey-milovidov alexey-milovidov self-assigned this Sep 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 20, 2026
alexey-milovidov and others added 2 commits September 20, 2026 23:28
The `failpoints_disabled_in_tests` check knows only `SYSTEM DISABLE FAILPOINT
<name>`, so the two tests that master gained for `SYSTEM DISABLE ALL FAILPOINTS`
- `05223_system_disable_all_fault_injection_points` and
`05225_system_disable_all_fault_injection_points_wakes_paused` - fail it: they
arm fail points and clear them with the statement that exists for exactly that.
The check runs over the whole test tree, not only the changed files, so this
passed on the pull request and failed in the merge queue, where the branch is
tested merged with master:
https://github.com/ClickHouse/ClickHouse/actions/runs/35539310363

`SYSTEM DISABLE ALL FAILPOINTS` now stands in for the per-name disables, but
only in a `no-parallel` test: it is server-wide in the other direction too, and
disarms what the tests running alongside armed. `SYSTEM DROP` carries the same
requirement in `various_checks.sh`. A test that relies on it without the tag
gets an error that says so, instead of being told to add a disable it already
has.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 21, 2026
Merged via the queue into master with commit d536963 Sep 21, 2026
177 checks passed
@alexey-milovidov
alexey-milovidov deleted the explicit-disable-failpoint-in-tests branch September 21, 2026 16:14
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 21, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@alexey-milovidov — ClickGap found the following in this PR:

Close anything that's wrong or already addressed.

alexey-milovidov added a commit to rorylshanks/ClickHouse that referenced this pull request Sep 22, 2026
…t of them

The `failpoints_disabled_in_tests` style rule (from ClickHouse#120809, now on `master`) requires every `SYSTEM ENABLE FAILPOINT` in a stateless test to have a matching `SYSTEM DISABLE FAILPOINT`. Eight tests of this branch enabled `ONCE` fail points that disarm themselves after firing and never disabled them explicitly; a paused `ALTER` also stayed parked if a test exited early.

The seven `.sh` tests now install a `trap cleanup EXIT` that disables every fail point they enable (a disable of an unarmed fail point is a no-op), and `05210_readonly_settings_rollback.sql` disables the throw fail point after each `ALTER` that is expected to fail.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119559&sha=ebfc6ba3f7ab9ecf56874e4c5a7dea2a39a78297&name_0=PR&name_1=Style%20check
PR: ClickHouse#119559

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants