Skip to content

Reject unknown fail point names in SYSTEM FAILPOINT statements - #112680

Merged
PedroTadim merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-disable-failpoint-unknown-name
Aug 1, 2026
Merged

PedroTadim merged 4 commits into
ClickHouse:masterfrom
groeneai:fix-disable-failpoint-unknown-name

Conversation

@groeneai

@groeneai groeneai commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

SYSTEM DISABLE FAILPOINT now rejects a fail point name that does not exist, raising BAD_ARGUMENTS like SYSTEM ENABLE FAILPOINT already did. Previously a mistyped name reported success while leaving the intended fail point enabled, with no indication that nothing had been disabled.

Description

FailPointInjection::disableFailPoint accepted any string and silently did nothing when the
name was not a registered fail point, while its sibling enableFailPoint rejected it with
BAD_ARGUMENTS. A typo in SYSTEM DISABLE FAILPOINT therefore reported success and left the
intended fail point armed, with no diagnostic.

Two in-tree tests carry exactly that typo today: 02718_insert_meet_hardware_error and
02919_insert_meet_eternal_hardware_error both disable
replicated_commit_zk_fail_after_op, which is missing the _merge_tree infix and matches no
registry entry. They pass only because their fail point is ONCE and fires before the mistyped
disable is reached, so it has already self-disarmed.

Root cause: disableFailPoint never consulted the APPLY_FOR_FAILPOINTS registry that
enableFailPoint validates against, and fiu_disable returns -1 for both an unknown name
and a known-but-not-enabled one, so its return value cannot distinguish them. The fix adds the
missing registry check, mirroring enableFailPoint, and corrects the two mistyped tests.

The check is deliberately on registration and never on enabled state: disabling a registered
fail point that is not currently enabled stays a silent no-op, because callers do idempotent
cleanup (a trap on EXIT, a SCOPE_EXIT, the bulk reset proposed in #105942). Those bulk
disables read names out of system.fail_points, so they stay registered and keep working.

This changes documented behaviour for one input class: an unregistered name now raises
BAD_ARGUMENTS instead of returning success. It is reachable only with the SYSTEM_FAILPOINT
grant.

All 113 registered fail point names disabled by any stateless or integration test were issued
against the fixed server, and none was rejected. The new test uses clickhouse-local because
fail point state is process global, which keeps it parallel safe without a no-parallel tag.
SYSTEM WAIT FAILPOINT has the same silence for an unregistered name, but there it is
load-bearing for a registered name with no active channel, so it is left for a follow-up.

groeneai and others added 2 commits July 30, 2026 21:39
`FailPointInjection::disableFailPoint` accepted any string and silently did
nothing when the name was not a registered fail point, while its sibling
`enableFailPoint` rejected it with `BAD_ARGUMENTS`. A typo in
`SYSTEM DISABLE FAILPOINT` therefore reported success and left the intended
fail point armed, with no diagnostic.

Root cause: `disableFailPoint` never consulted the `APPLY_FOR_FAILPOINTS`
registry that `enableFailPoint` validates against. `fiu_disable` does return
-1 on a miss, but that value cannot be used as the trigger because it is also
-1 for a registered name that is simply not currently enabled.

Add the missing registry check, mirroring `enableFailPoint`. The check is
deliberately on registration and never on enabled state: disabling a
registered fail point that is not currently enabled must stay a silent no-op,
because callers do idempotent cleanup such as a trap on EXIT, a `SCOPE_EXIT`,
or a bulk reset that reads names out of `system.fail_points`.

Two in-tree tests carried exactly this typo and are corrected here:
`02718_insert_meet_hardware_error` and
`02919_insert_meet_eternal_hardware_error` both disabled
`replicated_commit_zk_fail_after_op`, which is missing the `_merge_tree`
infix and matches no registry entry. They passed only because their fail
point is ONCE and fires before the mistyped disable is reached, so it had
already self-disarmed. Without the test edits they would newly fail on the
checked build, which is what makes them part of this change.

The new test uses `clickhouse-local` rather than the shared server because
fail point state is process global; a shared-server test asserting that state
races concurrent copies of itself, so this form stays parallel safe without a
no-parallel tag.

Co-Authored-By: Claude Fable 5 <[email protected]>
The Style check's `check_functional_test_cases` rejects any functional test
whose path contains the substring `fail`, and it traverses the whole
`tests/queries` tree rather than the pull request diff, so the previous name
`04657_disable_failpoint_unknown_name` turned the check red regardless of what
this branch touches. It would have been the first such path among the 12978
traversal-eligible files, which is why no existing fail point test hit it. The
abbreviation `fp` is the form already used by `04095_wait_fp_pause_disable` and
`02294_fp_seconds_profile`.

Renumber to 04658 at the same time: master landed
`04657_cuturlparameter_documented_behavior` while this branch was open, so 04657
had become a duplicate number. Nothing in CI catches that, because the gap check
keys on a set of integers and the test runner has no duplicate guard, but it is
still a numbering collision a reader would trip over. 04658 is free and keeps
the large-gap count at zero.

Also condense the comment header. The bug narrative it carried is already in the
commit message of the fix and in the pull request description, and a comment that
restates them goes stale independently. The rationale a future editor cannot
recover from elsewhere is kept verbatim: why the test uses `clickhouse-local`
rather than the shared server, why `dummy_failpoint` is the carrier, and which
rows are must-not-change controls rather than evidence.

No behaviour change: the executable lines are byte-identical and the reference
file is unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds, 12 findings, click to expand)

Two independent review rounds ran against this change: a cold read of the resulting code, plus a
second-model gate pass. Round 1 raised one blocker and one major, both fixed here; round 2's gate
returned zero findings. Verdicts and evidence below.

Fixed in this PR

# Finding Verdict Evidence
❌ The new test's filename contained the substring fail, which ci/jobs/check_style.py:209-211 rejects for any file under tests/queries AGREE, fixed Proven both ways by driving the real check over all 12978 test files: the old name produced exactly 1 violation, the current name produces 0. The rule scans the whole tree, not the diff, so it would have fired regardless of what this PR touched.
⚠️ Test number 04657 became a duplicate: master landed 04657_cuturlparameter_documented_behavior during this branch's life AGREE, fixed Renumbered to 04658. Re-derived against live master and against the actual merged tree: one 04658_* pair, no duplicate, and check_gaps_in_tests_numbers returns empty for both the merged tree and master alone. Note git merge-tree returns 0 here, so a clean merge does not surface this.
💡 Test comments restated the PR description and the commit message AGREE, fixed Condensed the duplicated bug narrative; kept the clickhouse-local process-isolation rationale, the carrier-selection rationale, and the liveness-vs-control row labels, which are recorded nowhere else. All 10 changed lines are comments; zero executable lines and the .reference are byte-identical.

Raised and refuted before adjudication

Three candidate blockers were self-raised against the new BAD_ARGUMENTS throw, since a stale
name anywhere would turn CI red on merge. Each was refuted at a necessary step:

# Scenario Why it does not hold
💡 The test pins Code: 36, but a build without libfiu answers SUPPORT_IS_DISABLED instead, and no use-libfiu tag can exist because USE_LIBFIU is absent from system.build_options ENABLE_LIBFIU is an unconditional option(... ON) at CMakeLists.txt:567, independent of ENABLE_LIBRARIES, and contrib/libfiu is in the Fast test minimal submodule set, so libfiu survives -DENABLE_LIBRARIES=0. Corroborated by 84 failpoint-using stateless tests that carry no no-fasttest tag and are green today.
💡 04117_parser_system_query_variants.sql:98 issues SYSTEM DISABLE FAILPOINT fp, an unregistered name It is wrapped in EXPLAIN SYNTAX, which only re-formats the AST and never constructs InterpreterSystemQuery. Line 97 of the same file already does EXPLAIN SYNTAX SYSTEM ENABLE FAILPOINT fp, and enableFailPoint has rejected unregistered names since long before this PR, so that file would already be red if the statement executed.
💡 Nine SYSTEM DISABLE FAILPOINT {var} spellings in tests/integration are invisible to a literal-name sweep Each was resolved to its assignment or parametrize source; all 14 resolved names are in APPLY_FOR_FAILPOINTS.

The full sweep is 260 DISABLE FAILPOINT occurrences repo-wide reducing to 118 distinct tokens:
113 registered names, all accepted by the fixed server, and 5 non-registry tokens (2 deliberate
negatives in the new test, 2 prose words inside comments, and the fp placeholder used only on
parse-only EXPLAIN SYNTAX lines). No other surface issues these statements: tests/performance,
ci/, docker/, utils/ and programs/ contain none, and the config-driven fail_points_active
path only ever enables.

Noted, not blocking

# Finding Verdict
💡 SYSTEM WAIT FAILPOINT is also silent for an unregistered name Left for a follow-up, and disclosed in the description. Unlike DISABLE, its silence is load-bearing: waitForPause and waitForResume legitimately return early for a registered name with no active channel, so it cannot be closed the same way.
💡 NOTIFY reports Cannot find channel for fail point rather than the typo-oriented message the other verbs use DISAGREE. That wording is accurate for its own semantics, and NOTIFY is not touched here; changing it would be scope creep into an untested path.
💡 Only one of the 8 reference rows moves with the fix DISAGREE. That is by design: the other 7 are must-not-change controls pinning that the check is on registration and never on enabled state. Each is live against a different mutation.

Both directions are Build-ID verified: pristine master fails the new test, the fix passes it, a
mutation that makes the registry check always report success reddens it, and restoring the fix
relinked bit-identically with the source checksums restored, so no mutation residue ships.

Session id: cron:clickhouse-review-slot-10:20260730-224300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, 100%, no randomization needed. On master: SYSTEM ENABLE FAILPOINT replicated_merge_tree_commit_zk_fail_after_op; SYSTEM DISABLE FAILPOINT replicated_commit_zk_fail_after_op; SELECT enabled FROM system.fail_points WHERE name = 'replicated_merge_tree_commit_zk_fail_after_op' returns 1, and the mistyped disable raises nothing.
b Root cause explained? Yes. disableFailPoint (src/Common/FailPoint.cpp:354) never consulted the APPLY_FOR_FAILPOINTS registry that enableFailPoint (:326-353) validates against, and fiu_disable's -1-on-miss return is discarded at :366. That return cannot be used as the trigger either, since it is also -1 for a registered-but-not-enabled name.
c Fix matches root cause? Yes. The missing registry check is added at the layer that owns the registry, mirroring enableFailPoint. Rejected: fixing only the two tests (leaves the silent-failure mode); a style linter (cannot resolve the 10 shell and python variable disable spellings, nor help gtests or a human at a client); keying on fiu_disable's -1 (conflates unknown-name with not-currently-enabled).
d Test intent preserved / new tests added? Yes. New stateless test with 8 rows: 2 rejection rows (the fix), 1 silent-no-op row (pinning that the check is on registration, not enabled state), 2 working-path rows, 3 armed-leak rows. 02718/02919 keep their original intent; only the mistyped name is corrected and no assertion or reference changes.
e Both directions demonstrated? Yes, every arm Build-ID-verified: pristine master 0da1aff1 FAILS, fix 733ec3a6 PASSES. A mutation making the registry check always report success (0ebefd8d) reddens the test, and restoring the fix relinked bit-identically to 733ec3a6 with the source md5 restored, so no mutation residue ships. The literal "delete the throw" mutation was rejected by the compiler (-Werror,-Wunused-function) and so was re-expressed faithfully rather than counted as passing.
f Fix is general across code paths? Yes. Fixed at the single shared entry point, so the SQL path and all 6 direct C++ callers are covered by one check. No sibling has the same gap (enableFailPoint already validates, notifyFailPoint already throws). The USE_LIBFIU == 0 stub at :479 is deliberately untouched: SYSTEM DISABLE FAILPOINT already throws SUPPORT_IS_DISABLED earlier (InterpreterSystemQuery.cpp:1216-1219), so it is unreachable from SQL.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes, measured. All 244 registered names accepted; all 4 fail point kinds unaffected because the check precedes kind handling; empty string and arbitrary junk rejected; the enabled-vs-disabled axis covered in both directions. Full sweep: all 113 registered fail point names disabled by any stateless or integration test were issued against the fixed server and none was rejected. The extraction also picks up 5 non-registry tokens, each accounted for: this test's own 2 deliberate negatives, 2 prose words inside comments, and the fp placeholder used only on EXPLAIN SYNTAX parse-only lines in 04117.
h Backward compatible? (maintainer-approved exception only) Analysed rather than waved off. SYSTEM DISABLE FAILPOINT is documented, so one input class does change: an unregistered name goes from silent success to BAD_ARGUMENTS. What does not change: a registered-but-not-enabled name stays a silent no-op, which is the case real tests depend on. Reachable only with the SYSTEM_FAILPOINT grant on a build with ENABLE_LIBFIU. No setting added, removed, or re-defaulted, so no SettingsChangesHistory.cpp entry applies; no serialization, protocol, or ABI surface is touched.
i Invariants and contracts preserved? Yes. The check runs before the std::lock_guard, so it neither holds nor perturbs mu, and a rejected call performs no teardown at all, so fail_point_wait_channels can never be left partially updated (pinned by the still_armed row). For a registered name every prior side effect is byte-for-byte unchanged: channel epoch bump, disabled flag, both notify_all calls, erase, then fiu_disable. The helper is a pure function of its argument, touches no shared state, and introduces no lock ordering.

Session id: cron:clickhouse-review-slot-10:20260730-224300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Algunenano @nikitamikhaylov, could you review this? SYSTEM DISABLE FAILPOINT never consulted the APPLY_FOR_FAILPOINTS registry that its ENABLE sibling validates against, so a mistyped name reported success and left the intended fail point armed. Algunenano, 02718_insert_meet_hardware_error and 02919_insert_meet_eternal_hardware_error are yours and both carry exactly that typo (replicated_commit_zk_fail_after_op, missing the _merge_tree infix); they pass today only because the fail point is ONCE and has already self-disarmed.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cb53297]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_binary, parallel) FAIL
04612_join_runtime_filters_index_analysis_multi_key_anti FAIL cidb, issue ISSUE EXISTS
Fast test (arm_darwin) ERROR IGNORED

AI Review

Summary

This PR makes unknown fail point names reject consistently across the SYSTEM ... FAILPOINT statements that actually execute against FailPointInjection, and it fixes the two in-tree tests that were relying on a mistyped disable name. After checking the current diff, the surrounding FailPointInjection and interpreter code, prior review threads, and the all-green CI report, I did not find any remaining correctness, compatibility, or evidence gaps.

Documented surface
  • SYSTEM DISABLE FAILPOINT: docs/en/operations/system-tables/fail_points.md:13 says failpoints can be enabled and disabled at runtime, and Cloud-docs search for SYSTEM DISABLE FAILPOINT found only translated copies of that same page; none of those docs promise that an unknown name succeeds. Still valid.
  • SYSTEM WAIT FAILPOINT: no docs/en/ hits. Cloud-docs search found only the 26.2 release-note announcement in docs/cloud/reference/01_changelog/02_release_notes/26_2.md, which does not describe behavior for unknown names. Still valid.
  • SYSTEM NOTIFY FAILPOINT: no docs/en/ hits. Cloud-docs search found only the same 26.2 release-note announcement, which does not describe behavior for unknown names. Still valid.
Final Verdict

✅ No new review findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 30, 2026
Comment thread src/Common/FailPoint.cpp Resolved
@PedroTadim PedroTadim self-assigned this Jul 31, 2026
Comment thread src/Common/FailPoint.cpp Resolved
@PedroTadim
PedroTadim enabled auto-merge July 31, 2026 13:35
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-ci labels Jul 31, 2026
@PedroTadim PedroTadim changed the title Reject unknown fail point names in SYSTEM DISABLE FAILPOINT Reject unknown fail point names in SYSTEM FAILPOINT statements Jul 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 80.90% 86.50% +5.60%
Functions 91.40% 91.90% +0.50%
Branches 72.90% 78.70% +5.80%

Changed lines: Changed C/C++ lines covered: 23/23 (100.00%) · Uncovered code

Full report · Diff report

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - cb53297

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, parallel) / 04612_join_runtime_filters_index_analysis_multi_key_anti randomized-settings flaky (join_runtime_filter_min_probe_rows 4426; 142/142 fail with the randomized settings, 195/195 pass without) #111691 (external, merged 2026-07-31T20:56Z): this build predates it, so the pin arrives with the next master merge on this branch
Fast test (arm_darwin) job-level ERROR, run wedges with no test row (residual after merged #112267, which is already on this branch) a fix task is moved to pending (investigating at full effort, fixing PR link to follow on this PR)

Session id: cron:our-pr-ci-monitor:20260801-003000

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the 03652_threads_count_insert failure on this PR CI: #112853. The test derived its query_id from bash $RANDOM, so two of its four loop iterations sometimes shared one id and the system.query_log lookup returned an extra row. Not caused by this PR.

@PedroTadim
PedroTadim added this pull request to the merge queue Aug 1, 2026
Merged via the queue into ClickHouse:master with commit d34a7fa Aug 1, 2026
348 of 353 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default 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.

4 participants