Skip to content

CI log parser: recognize AST Fuzzer oracle mismatch and any <Fatal> - #118056

Merged
maxknv merged 6 commits into
masterfrom
fuzzer-log-parser-oracle-and-generic-fatal
Sep 10, 2026
Merged

maxknv merged 6 commits into
masterfrom
fuzzer-log-parser-oracle-and-generic-fatal

Conversation

@maxknv

@maxknv maxknv commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

The AST Fuzzer oracle runs inside regular functional tests. On a mismatch the server logs a <Fatal> ASTFuzzer: AST Fuzzer oracle mismatch detected! message (in executeQuery), but FuzzerLogParser (ci/jobs/scripts/log_parser.py) had no pattern for it. So parse_failure fell through to "Unknown error" and the report showed a bare "Fatal error: this job has unknown error" even though the real reason and the reproducer query were right there in the server log.

This change:

  • Adds an AST Fuzzer oracle mismatch pattern, checked first, folding the oracle kind (e.g. TLP Aggregate) into the failure name so distinct oracles group separately in CI DB, keeping the fuzzed query in the info.
  • Adds a generic <Fatal> fallback: when no specific pattern matches, surface the first <Fatal> message (its context, with the <Fatal> prefix stripped) instead of "Unknown error"; only fall back to "Unknown error" when there is no <Fatal> at all. This makes future unclassified fatals visible too.
  • Adds ci/tests/test_log_parser.py covering the oracle mismatch (with and without a recognizable oracle kind), the generic fatal fallback, the no-fatal "Unknown error" case, and specific-pattern precedence.

Verified against the real clickhouse-server.err.log from the CI report below: the parser now reports AST Fuzzer oracle mismatch: TLP Aggregate with the reproducer, instead of "Unknown error".

Related: #72199

Changelog category (leave one):

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

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

Version info

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

The AST Fuzzer oracle runs inside regular functional tests and, on a
mismatch, the server logs a `<Fatal> ASTFuzzer: AST Fuzzer oracle mismatch
detected!` message (`executeQuery`). `FuzzerLogParser` had no pattern for
this message, so `parse_failure` fell through to "Unknown error" and the
report showed a bare "Fatal error: this job has unknown error" even though
the real reason (and reproducer query) was right there in the server log.

- Add an `AST Fuzzer oracle mismatch` pattern, checked first, that folds the
  oracle kind (e.g. `TLP Aggregate`) into the failure name so distinct
  oracles group separately in CI DB, keeping the fuzzed query in the info.
- Add a generic `<Fatal>` fallback: when no specific pattern matches, surface
  the first `<Fatal>` message (with its context, `<Fatal> ` prefix stripped)
  instead of "Unknown error"; only fall back to "Unknown error" when there is
  no `<Fatal>` at all. This makes future unclassified fatals visible too.
- Add `ci/tests/test_log_parser.py` covering the oracle mismatch (with and
  without a recognizable oracle kind), the generic fatal fallback, the
  no-fatal "Unknown error" case, and specific-pattern precedence.

Verified against the real server log from the CI report below: the parser
now reports `AST Fuzzer oracle mismatch: TLP Aggregate` with the reproducer.

CI report: http://ci-reports:8080/clickhouse-test-reports-private/praktika.html?PR=72199&sha=44cd74859f170577c193462e13b06f8743eba2a0&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20cache%2C%20meta%20in%20keeper%2C%20s3%20storage%2C%20sequential%29
Related: #72199

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

clickhouse-gh Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [df4a62a]

Summary: ✅


AI Review

Summary

This PR teaches FuzzerLogParser to classify AST fuzzer oracle mismatches, adds a generic <Fatal> fallback, and updates the stress job to scan every replica log pair instead of stopping at the first non-Unknown error. One blocker remains: the generic-fatal fallback still misclassifies ordinary query text as a fatal if the quoted text embeds the full structured log prefix.

Findings

❌ Blockers

  • [ci/jobs/scripts/log_parser.py:537] get_generic_fatal still accepts a false match from quoted query text because GENERIC_FATAL_PATTERN is not anchored to the start of the log record and the fallback bypasses the QUERY_TEXT_MARKERS filtering used by find_failure. A concrete repro on the current head is a single <Debug> executeQuery: SELECT '[ 7 ] {xyz} <Fatal> not an error' line: parse_failure returns not an error' and sets is_generic_fatal = True, so stress_job.py, clickhouse_proc.py, and ast_fuzzer_job.py can report arbitrary query text as a fatal failure. Suggested fix: anchor the regex to the beginning of the log line (for example by including the timestamp prefix), or run the generic fallback through the same query-text filtering path, and add a regression for this exact shape.
Tests
  • ⚠️ The new coverage does not include a quoted string or comment that contains the full [ <tid> ] {<qid>} <Fatal> prefix. Add a focused regression that asserts this still returns Unknown error and leaves is_generic_fatal unset.
Final Verdict

Request changes: the generic <Fatal> fallback still has a quoted-query false positive on the current head.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 4, 2026
Comment thread ci/jobs/scripts/log_parser.py Resolved

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good

Address review on PR #118056: the oracle-kind capture used `[\w ]`, so it
missed the `Identity WHERE ({}) oracle mismatch!` messages from
`QueryOracleChecker` (e.g. `Identity WHERE (p AND 1) oracle mismatch!`), which
then collapsed into the generic `AST Fuzzer oracle mismatch` bucket instead of
grouping separately in CI DB.

- Widen the capture to `[\w ()]` so parenthesized-but-fixed kind labels
  (`Identity WHERE (p AND 1)`, `Identity WHERE (NOT(NOT p))`) are kept, while
  DQP's variable `Setting: <name>` trailer (after the `!`) stays excluded.
- Add a parametrized regression test covering every oracle-kind message emitted
  by `QueryOracleChecker`.

Related: #118056

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread ci/jobs/scripts/log_parser.py Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026
Address review on PR #118056: `parse_failure` stops at the first matching
pattern class, so putting the oracle pattern before the sanitizer entry let a
server-side oracle mismatch suppress a higher-signal ASan/TSan report in
`stderr.log` when both were present.

- Move the oracle pattern to right after `Sanitizer` so a sanitizer report
  (memory safety, highest signal) wins. Kept ahead of the generic server-log
  patterns so an unrelated `Logical error` from another test in the same run's
  aggregated server log does not steal the oracle classification.
- Add a regression test with both logs populated, asserting the sanitizer
  failure is reported.

Related: #118056

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread ci/jobs/scripts/log_parser.py Resolved
Address review on PR #118056: `stress_job.py` scans the log pair of each
replica and treats the first `name != UNKNOWN_ERROR` as definitive, breaking
the loop. The generic `<Fatal>` fallback turned an unclassified fatal into a
non-`UNKNOWN_ERROR` name, so a transient generic fatal on one replica could
preempt a higher-signal sanitizer/known failure on another replica that the
loop would previously have reached (the generic fatal used to parse as
`UNKNOWN_ERROR`).

- `FuzzerLogParser` now exposes `is_generic_fatal`, set only when the result
  came from the generic `<Fatal>` fallback rather than a specific pattern.
- `stress_job.py` uses three priority tiers across replicas: a specific
  classification wins outright and stops the scan; a generic fatal is preferred
  over "Unknown error" but does not preempt a specific failure on another
  replica (scan continues); "Unknown error" is the last resort.
- Tests assert the flag is set only for the generic fallback (not for specific
  classifications or "Unknown error").

Related: #118056

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread ci/jobs/stress_job.py Resolved
Address review on PR #118056: the previous three-tier selection still broke
the replica scan on the first specific classification, so a main-replica
oracle mismatch could suppress a later replica's sanitizer report (before this
PR the main replica parsed as `Unknown error`, so the scan reached the ASan
report).

- Extract the selection into `select_replica_failures`, which scans every
  replica's (server, stderr) log pair without breaking early. It collects all
  specific classifications and returns every distinct one (deduplicated by
  name, since replicated setups surface the same failure on several replicas).
  A generic `<Fatal>` and "Unknown error" are used only when no replica yielded
  a specific classification.
- Add `ci/tests/test_stress_job.py` with regressions spanning two replica log
  pairs: a specific failure on the second replica is not hidden by the first;
  a generic fatal does not suppress a sanitizer on another replica; the same
  specific failure across replicas is reported once; generic fatal / unknown
  fallbacks are used only when nothing specific was found.

Related: #118056

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread ci/jobs/scripts/log_parser.py Resolved
Address review on PR #118056: `get_generic_fatal` matched a `<Fatal>`
substring anywhere on a line, so an ordinary <Debug>/<Error> log line quoting
`<Fatal>` inside query text or a comment (e.g. `executeQuery: SELECT '<Fatal>
not an error'`) was turned into a bogus failure name with `is_generic_fatal`
set - even though no fatal record existed.

- Anchor the generic-fatal search to the structured log prefix
  `[ <thread> ] {<query_id>} <Fatal>` (the same log-level heuristic the rest
  of the parser uses), so a quoted `<Fatal>` in query text is not matched.
- Add a regression asserting a quoted `<Fatal>` in query text yields
  "Unknown error" and does not set `is_generic_fatal`.

Related: #118056

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@maxknv
maxknv enabled auto-merge September 9, 2026 13:53
@maxknv
maxknv added this pull request to the merge queue Sep 10, 2026
Merged via the queue into master with commit a4c8e56 Sep 10, 2026
343 of 344 checks passed
@maxknv
maxknv deleted the fuzzer-log-parser-oracle-and-generic-fatal branch September 10, 2026 09:26
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 10, 2026
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Sep 10, 2026
`QueryOracleChecker` compares a query's result against a metamorphic rewrite
of it for exact row equality, so it keeps a backstop set of aggregates whose
`State`/`Merge` path legitimately diverges from direct evaluation. `topK` and
`topKWeighted` were in that set; their space-saving counterparts
`approx_top_k` and `approx_top_sum` were not, even though `QueryFuzzer`'s
aggregate swap list offers `approx_top_k` for any single-argument aggregate.
Every oracle mismatch recorded on master over the last three weeks is that
substitution - four of them, all false:

    Fuzzed query: SELECT g, count(), approx_top_k(v), max(v)
                  FROM oracle_tlp_agg WHERE v > 50 GROUP BY g ORDER BY g ASC
    TLP Aggregate oracle mismatch!

Which elements survive the bounded counter table, and the counts reported for
them, depend on the order the values arrive in and on how the partial states
merge, so the three-way `WHERE` partition the TLP Aggregate oracle builds is
entitled to disagree with the whole-table reference.

The failure surfaced twice over: as the failing test, and again as a
blocker named `Unknown error` whose description reads "Lost connection to
server. See the logs." Nothing had crashed and no connection was lost -
`clickhouse_proc.py` treats any `<Fatal>` line in the server log as a
failure to classify, the oracle reports a mismatch with `LOG_FATAL`, and
`FuzzerLogParser.ERROR_PATTERNS` has no pattern for it, so it fell through to
`UNKNOWN_ERROR`. ClickHouse#118056 fixes
that reporting side; this change removes the mismatch itself.

Aliases are now resolved through `AggregateFunctionFactory` instead of being
enumerated. ClickHouse aliases plenty of aggregates the set already rejects -
`min_by`/`max_by` for `argMin`/`argMax`, `array_agg` for `groupArray`, `lttb`
for `largestTriangleThreeBuckets`, every `median*` for the matching
`quantile*`, `STDDEV_POP`/`VAR_SAMP`/`COVAR_POP` for the `stddev*`/`var*`/
`covar*` families - and each unlisted spelling is another false mismatch
waiting to red master. The expansion is stripped of combinators in turn, so
`array_concat_agg` reaches `groupArray` through `groupArrayArray`, and the
raw spelling is still tested first so the set stays free to name a function
by whichever spelling reads best.

The remaining additions are the aggregates `QueryFuzzer` can substitute in
that fall in classes the set already rejects: `sumCount` and the `sumMap*`
family (non-associative floating-point addition, like `sum`),
`corrMatrix`/`covarPopMatrix`/`covarSampMatrix` (like `corr`),
`analysisOfVariance` and `studentTTestOneSample` (like `studentTTest`),
`quantileExactWeightedInterpolated` and `quantilePrometheusHistogram` with
their plural forms, `groupArrayIntersect` (hash-table iteration order, like
`groupUniqArray`), `mergedJSONPatch` (last write per path wins, by sort key)
and `boundingRatio` (on ties in the x argument the first point seen wins).
`min`, `max`, `count`, `uniq`, `uniqExact` and the `groupBitmap*` family stay
checkable, so oracle coverage of the interesting cases is untouched.

Reports:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=6c335833c268d3c52d83b47abf4c2f807251e716&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20sequential%29
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=6c335833c268d3c52d83b47abf4c2f807251e716&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20sequential%29

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 14, 2026
…-info-head-window

`ci/tests/test_stress_job.py` was the only conflict, and it is a
modify/modify against a file that was deleted and then restored at a
different shape: ClickHouse#115650 removed it, `bc83cbe9312d2` ("Restore live CI
regression coverage") brought it back covering `select_replica_failures`
instead, and ClickHouse#118056 has been maintaining it since. The 249-line file this
branch added its tests to no longer exists in any form on master.

Resolved by taking master's 124-line file verbatim - all five
`select_replica_failures` tests are kept byte-for-byte - and re-applying
this branch's six hung-check tests on top, with the imports merged and the
module docstring extended to name both subjects. The `pytest` import and
the `__main__` block this branch relied on are dropped rather than
restored, because master's copy does not have them.

`ci/jobs/scripts/stress/stress.py` and `tests/clickhouse-test` merged
without conflict; both were verified by hand afterwards, since the target
block in `stress.py` had moved about 190 lines (the hung-check call site is
now at :1254) and `tests/clickhouse-test` had drifted far enough that a
clean auto-merge is not by itself evidence the two added lines still landed
inside the polling loop they are meant to pace. They did, and the loop
shape the AST test pins is unchanged: one `while` containing
`get_processlist_size`, with the zero-hung `break` before the added
`sleep(1)`.
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