Skip to content

AST fuzzer oracle: collapse per-oracle dispatch + fix neighbor/runningAccumulate false mismatch - #117189

Merged
fm4v merged 3 commits into
masterfrom
oracle-dispatch-refactor
Sep 1, 2026
Merged

fm4v merged 3 commits into
masterfrom
oracle-dispatch-refactor

Conversation

@qoega

@qoega qoega commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Two related cleanups to the server-side AST-fuzzer oracle dispatcher:

  1. check() ran each of the nine oracles inside an identical try/catch block —
    re-throwing AST_FUZZER_ORACLE_MISMATCH, swallowing every other error with the
    same log line. That was ~150 lines of copy-paste every new oracle had to
    duplicate. They now go through one run_oracle(name, fn) guard; the per-oracle
    log wording and the outer mismatch-settings annotation are preserved.

  2. neighbor and runningAccumulate read across rows in physical block order, so
    any oracle rewrite that reorders/repartitions/reblocks the input changes their
    per-row output legitimately. They were missing from non_deterministic_functions
    and could produce a false oracle mismatch; add them next to rowNumberInBlock /
    runningDifference.

Behavior-preserving: the existing oracle stateless tests still pass and the
oracles still fire (generic ProfileEvent 0->103, TLP-aggregate 0->1 in a local run).

Related: #99980

Changelog category (leave one):

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

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

Version info

  • Merged into: 26.9.1.497 (included in 26.9 and later)

qoega and others added 2 commits August 30, 2026 19:40
…inistic

Both read across rows in physical block order (offset neighbours / a running
state), so any oracle rewrite that reorders, repartitions or reblocks the input
(TLP partitions, NoREC, DQP setting toggles, multi-threaded reads) changes their
per-row output legitimately. Left out of QueryOracleChecker's
non_deterministic_functions denylist, they could produce a false oracle mismatch,
so add them alongside the existing rowNumberInBlock / runningDifference entries.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
check() ran each of the nine oracles inside an identical try/catch block that
re-threw AST_FUZZER_ORACLE_MISMATCH and swallowed every other error with the
same log line — ~150 lines of copy-paste that any new oracle had to duplicate.
Replace them with a single run_oracle(name, fn) lambda that applies the guard
uniformly; the per-oracle log wording and the outer mismatch-settings
annotation are preserved, so behavior is unchanged. Verified: the existing
oracle stateless tests still pass and the oracles still fire (generic and
TLP-aggregate ProfileEvents still increment).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bdc78f8]

Summary: ✅


AI Review

Summary

This PR refactors QueryOracleChecker::check to run each oracle through a shared run_oracle guard and also claims to stop neighbor / runningAccumulate from producing false oracle mismatches by adding them to non_deterministic_functions. The dispatch cleanup looks fine, but the behavioral fix is still unproven and appears ineffective on the successful-query path: these functions are already rejected by the existing FunctionFactory::tryGet(...)->isDeterministic() gate, so I do not see evidence that the new denylist entry changes oracle eligibility or fixes the mismatch source described in the PR.

Findings

⚠️ Majors

  • [src/Interpreters/QueryOracleChecker.cpp:84-88] The new neighbor / runningAccumulate denylist entry does not appear to change the behavior this PR claims to fix. For queries that can actually run successfully, both functions already resolve through FunctionFactory::tryGet and return isDeterministic() == false (src/Functions/neighbor.cpp:64, src/Functions/runningAccumulate.cpp:73), so hasNonDeterministicFunctionsImpl was already skipping them before this patch. Queries that need inline SETTINGS allow_deprecated_error_prone_window_functions = 1 are also rejected earlier by hasNonStrippableInlineSettings, so this added list entry still does not explain a real false-mismatch path. As written, the PR can leave the actual bypass unfixed while making the review history look as if the issue was addressed.
    Suggested fix: add a focused reproducer that demonstrates how a successful query containing one of these functions still reached an oracle before this patch, then gate that concrete path; otherwise drop or reframe this behavioral change as a cleanup rather than a mismatch fix.
Tests
  • ⚠️ The existing “oracles still fire” counter check is not evidence for the advertised neighbor / runningAccumulate fix. Please add the smallest focused regression test or reproducer showing a query with one of those functions that failed with an oracle mismatch before this change and is skipped or handled correctly after it.
Final Verdict

Request changes. The dispatch refactor is acceptable, but the neighbor / runningAccumulate part should not merge as a claimed false-mismatch fix without a concrete reproducer or a change on the code path that actually lets those queries reach an oracle.

LLVM Coverage Report

Measured on commit bdc78f8.

Metric Baseline Current Δ
Lines 88.60% 88.60% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 80.90% 80.90% +0.00%

Changed lines: Changed C/C++ lines covered: 18/22 (81.82%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 30, 2026
/// order (offset neighbours / a running state), so any rewrite that reorders,
/// repartitions or reblocks the input (TLP partitions, NoREC, DQP setting
/// toggles, multi-thread reads) changes their per-row output legitimately.
"neighbor", "runningAccumulate",

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.

neighbor and runningAccumulate already look excluded by the existing FunctionFactory::tryGet(...)->isDeterministic() gate in hasNonDeterministicFunctionsImpl: both resolvers return false from isDeterministic() (src/Functions/neighbor.cpp:64, src/Functions/runningAccumulate.cpp:73). So this denylist addition does not seem to change oracle eligibility for the normal function form the PR description talks about.

If there is still a false-mismatch reproducer here, it needs to bypass that resolver path, and this PR does not touch that path. Please either add a focused repro/test for the actual bypass or move the fix to the code that still lets these queries reach an oracle.

@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing bdc78f879 with master 8627fa22f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline.

Job report

Unrelated flaky failure: Stress test (arm_tsan) — Hung check possible deadlock.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@qoega qoega closed this Sep 1, 2026
@qoega
qoega deleted the oracle-dispatch-refactor branch September 1, 2026 08:29
@qoega
qoega restored the oracle-dispatch-refactor branch September 1, 2026 14:50
@qoega qoega reopened this Sep 1, 2026
@fm4v fm4v self-assigned this Sep 1, 2026
@fm4v
fm4v enabled auto-merge September 1, 2026 19:23
@fm4v
fm4v added this pull request to the merge queue Sep 1, 2026
Merged via the queue into master with commit f3a460f Sep 1, 2026
341 of 344 checks passed
@fm4v
fm4v deleted the oracle-dispatch-refactor branch September 1, 2026 19:50
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 1, 2026
alexey-milovidov added a commit that referenced this pull request Sep 2, 2026
…zzer-oracle

Resolve conflicts: master refactored `QueryOracleChecker.cpp` (#117189) after this
branch deleted it; the deletion wins since the whole oracle is being reverted.
The generated workflow files were regenerated with `python3 -m praktika yaml`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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