Skip to content

Do not name a stress failure after a query that quotes a failure message - #117963

Merged
alexey-milovidov merged 1 commit into
masterfrom
ci-log-parser-skip-query-text
Sep 5, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
ci-log-parser-skip-query-text

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Related: #115707
Related: #113292

FuzzerLogParser.parse_failure named a stress / AST fuzzer failure after the first line of the server log matching one of its failure patterns, no matter where in the line the match was. A query the server logs is data: both a test comment and a fuzzed query may contain any text, so a line like

... <Error> executeQuery: Code: 394. DB::Exception: Query was cancelled. ... (in query: -- Consuming the rowless chunk is `Logical error: 'max_rows > 0'` in debug and sanitizer builds. Every

was reported as the failure. In the Stress test (amd_msan) run of #115707 (report) this hid the real failure — Logical error: 'Can't determine table for parallel replicas', the known issue #113292 — behind a max_rows > 0 name that names no failure at all; the same mis-titled name was recorded for #116247 as well. The name goes into the CI database and into automatically created fuzzer issues, so such a match splits one failure into per-quote names and buries the failure that actually happened.

A match that is preceded on its line by (in query: or (query: is now skipped and the search continues. Only the part of the line before the match is checked, so a real failure that quotes the query it happened on keeps its name. The query id of the failed query and the Format string: line are taken from the failure that was found instead of being searched for again, so they cannot come from a different, quoting line either.

Matching a stack trace string no longer goes through echo '<string>' | rg: a log line contains single quotes, which terminated the shell quoting, so the quotes were dropped from the failure name (and the log content reached the shell).

Verified on the real 100 MB clickhouse-server.err.log of the run above: the failure is now named Logical error: Can't determine table for parallel replicas (STID: 3634-4123). Checked against the previous implementation on plain logical error, assertion, segfault and memory limit logs, in both server log and stack trace string modes: the failure names and infos are unchanged.

Changelog category (leave one):

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

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

`FuzzerLogParser.parse_failure` took the first line of the server log
matching one of its failure patterns, no matter where in the line the
match was. A query the server logs is data, and both a test comment and
a fuzzed query may contain any text, so a line such as

  ... <Error> executeQuery: Code: 394. DB::Exception: Query was cancelled.
  ... (in query: -- Consuming the rowless chunk is `Logical error:
  'max_rows > 0'` in debug and sanitizer builds. Every

was reported as the failure. In the `Stress test (amd_msan)` run of
#115707 that hid the real
failure, `Logical error: 'Can't determine table for parallel replicas'`
(issue #113292), behind
a `max_rows > 0` name that names no failure at all, and the same
mis-titled name was also recorded for
#116247. The name goes to
the CI database and to automatically created fuzzer issues, so such a
match splits one failure into per-quote names and buries the failure
that actually happened.

Skip a match that is preceded on its line by `(in query:` or `(query:`
and keep searching. Only the part of the line before the match is
checked, so a real failure that quotes the query it happened on keeps
its name. The query id of the failed query and the `Format string:`
line are now taken from the failure that was found rather than searched
for again, so they cannot come from a different, quoting line either.

Matching a stack trace string no longer goes through
`echo '<string>' | rg`: a log line contains single quotes, which
terminated the shell quoting, so the quotes were dropped from the
failure name (and the log content reached the shell).

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

clickhouse-gh Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c4cc3b6]

Summary: ✅


AI Review

Summary

This PR teaches FuzzerLogParser.parse_failure to skip failure-like text quoted inside logged queries, but the current implementation still misidentifies quoted text as the failure on multi-line queries and can give up entirely after 50 skipped matches. Because both behaviors break the PR's stated contract of finding the real failure name, this should not merge as-is.

Findings

⚠️ Majors

  • [ci/jobs/scripts/log_parser.py:238] The quoted-query guard only looks for (in query: or (query: earlier on the same line. executeQuery logs multi-line queries verbatim, so continuation lines inside the same quoted query have no marker and are still accepted as failures. With a log containing ... (in query: SELECT 1, then -- Logical error: quoted in query text, then the real <Fatal> : Logical error: real failure, parse_failure() returns Logical error: quoted in query text. Suggested fix: keep query-text state until the next real log record, or skip continuation lines after a query marker, instead of checking only the current line prefix.
  • [ci/jobs/scripts/log_parser.py:202] MAX_FAILURE_CANDIDATES = 50 changes the parser from "find the first real failure" to "find it only if at most 50 quoted matches appear first". I reproduced a log with 60 executeQuery lines containing (in query: -- Logical error: ...) before one real fatal line; all 50 candidates are skipped and parse_failure() falls back to Unknown error / Lost connection to server. Suggested fix: stream matches until a non-query failure is found, or use a bound that fails explicitly instead of silently dropping the real failure.
Final Verdict

Status: ⚠️ Request changes
Minimum required actions:

  • Make the quoted-query filter cover multi-line query text, not just same-line markers.
  • Remove or redesign the 50-match cutoff so skipped quoted matches cannot hide the actual failure.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 3, 2026
if not match:
continue
if any(
marker in line[: match.start()] for marker in self.QUERY_TEXT_MARKERS

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.

executeQuery logs multi-line queries verbatim, but this guard only checks for (in query: or (query: earlier on the same line. A quoted failure string on a continuation line still gets treated as the failure.

I reproduced this with a synthetic server.log containing:

... (in query: SELECT 1
-- Logical error: quoted in query text
...
<Fatal> : Logical error: real failure

parse_failure() returns Logical error: quoted in query text, so the PR still mis-titles the very case it is trying to fix.

This needs to keep track of being inside quoted query text until the next real log record, not just inspect the current line prefix.

# Only the matching lines are read - the log itself can be gigabytes.
output = Shell.get_output(
f"rg --text -n '{pattern}' {file}"
f" | head -n {self.MAX_FAILURE_CANDIDATES}",

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 hard cutoff can hide the real failure entirely. If there are more than 50 quoted matches before the actual fatal line, find_failure exhausts the candidate list here and parse_failure() falls back to Unknown error / Lost connection to server.

I reproduced it with 60 executeQuery lines containing (in query: -- Logical error: quoted ...) before one real Logical error: line: all 50 candidates were skipped here and the actual failure was never reached.

Because fuzzed queries are arbitrary input, a count-based limit changes the parser's contract from "find the first real failure" to "find it only if there are <= 50 false positives first". This needs a streaming search that continues until a non-query match is found, or at least a bound that cannot silently drop the real failure.

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 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.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Sep 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 4, 2026
Merged via the queue into master with commit 4d7615e Sep 5, 2026
174 checks passed
@alexey-milovidov
alexey-milovidov deleted the ci-log-parser-skip-query-text branch September 5, 2026 01:43
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 5, 2026
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.

2 participants