Skip to content

Do not name a CI failure after a failure message quoted in a multi-line query - #121339

Merged
alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-ci-failure-name-from-quoted-multiline-query
Oct 1, 2026
Merged

alexey-milovidov merged 7 commits into
ClickHouse:masterfrom
groeneai:fix-ci-failure-name-from-quoted-multiline-query

Conversation

@groeneai

@groeneai groeneai commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #111708

Changelog category (leave one):

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

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

...

Description

Upgrade check (amd_release) reported Assertion `parameters == nested_func->getParameters()' failed
on an unrelated PR (report).
Nothing asserted. The name is a comment in
04057_aggregate_function_nothing_with_parameters.sql about an already fixed issue, echoed back as
query text after the stress phase injected a memory limit fault.

find_failure already skips such a match (c4cc3b682605d), but only when the marker is on the same
line. toOneLineQuery deliberately re-emits a newline after every SQL comment, so a multi-line query
spans several log lines and only the first carries (in query:.

The cost is not just a wrong name: find_failure returns the first unguarded candidate, so the quote
hides every real failure after it. Here the quote is at line 134,699 and the real <Fatal> record at
line 900,288.

The guard now walks back to the record a match belongs to. The quoted query is the last field of both
executeQuery messages, so it ends at the stack trace marker or the ) closing (in query:; any
other shape, and an exhausted lookback, keeps the match as today.

One shape stays uncovered: a comment line ending in ) reads as the closing one, 3 of the 42 such
lines in 0_stateless (e.g. 04097_buffer_subcolumn_virtual_column_crash.sql:2). A stricter test
covers them but then hides a real failure logged bare after such a record. Happy to make that trade
if you prefer.

Validated on that job's 900,323 line artifact: the parser now reports the real record, not the quote.

#111708 touches the same file but is orthogonal (it anchors Logical error to a real <Fatal> record).


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

Version info

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

…ne query

`Upgrade check (amd_release)` reported ``Assertion `parameters ==
nested_func->getParameters()' failed`` on a PR whose diff touches no aggregate
function code. Nothing asserted. The name came from line 8 of
tests/queries/0_stateless/04057_aggregate_function_nothing_with_parameters.sql,
a comment documenting the symptom of the already fixed ClickHouse#100584, which
`executeQuery` echoed back as query text when the stress phase injected a
memory limit fault.

`find_failure` already skips a failure pattern matching inside a quoted query,
added in c4cc3b6, but the test is line local: it looks for `(in query:`
in the part of the *same* line before the match. `toOneLineQuery` collapses a
query to one line except that it deliberately re-emits a newline after every
SQL comment (src/Parsers/toOneLineQuery.cpp), so a statement with N leading
comments is logged as an N+1 line message and only its first line carries the
marker. A match on line 2..N is not skipped.

The cost is not only a wrong name. `find_failure` returns the first unguarded
candidate and `failure_candidates` caps the scan at 50, so a real failure
logged later in the same log is never reached. In the artifact above the quote
is at line 134,699 and the log's only real <Fatal> record is at line 900,288,
which the quote hid. That is the failure mode c4cc3b6's own message
records for ClickHouse#115707.

So the guard now also asks whether a matched line continues a query quoted
earlier in its record, by walking back to the record start. The quoted query is
the last field of both message formats in src/Interpreters/executeQuery.cpp, so
it ends either at the stack trace marker or at the `)` that closes
`(in query:`, whichever is met first while walking back. Every other shape,
including an exhausted 100 line lookback, reports "not inside", so this can
only ever stop naming a run after a quote, never suppress a real failure. The
guard sits in `find_failure`, which all eight ERROR_PATTERNS families are
matched through, so no pattern needed to change.

Measured on that job's own 900,323 line artifact: before this change
`parse_failure` returns "Assertion `parameters ==
nested_func->getParameters()' failed (STID: None)", byte identical to the CI DB
row; after it, the real watchdog record at line 900,288. A second in-tree
carrier with the phrase on a comment line,
04210_intdiv_array_nullable.sql, is covered the same way.

Five tests are added to ci/tests/test_log_parser.py, each pinned in both
directions. Making the guard decline to fire reddens all five; dropping either
terminator reddens one each, and dropping the record start gate reddens one, so
no branch of the new code is unpinned and no test passes vacuously.

MAX_FAILURE_CANDIDATES = 50 is deliberately left alone: it is a cost bound on
an `rg | head` over a possibly multi gigabyte log, and this change reduces how
many candidates are quotes in the first place.

Failure this fixes, Upgrade check (amd_release):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=121251&sha=05c8bec9562561b4cfd0f63b54ec582884e3c7e1&name_0=PR

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 21, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

An independent model reviewed this cold in two rounds; the second re-read both files in full and returned
no findings. I did the adjudicating, so any mistake in these verdicts is mine.

# Finding Verdict
❌ Four of the six tests first written still passed with the guard disabled entirely AGREE, fixed. Three now carry a quoted failure phrase on a continuation line of the record they already build, so each reddens both ways, and the one test that could not discriminate is deleted rather than padded. Disabling the guard reddens all 5; each terminator and the record-start bypass reddens exactly one.
⚠️ inside_quoted_query reads record boundaries from query-controlled text, so a comment line ending in ) stops the walk and a quote behind it is still named AGREE on the mechanism, DISAGREE on blocker. 39 of the 42 comment lines in 0_stateless quoting a failure phrase are covered; the 3 that are not (04097_buffer_subcolumn_virtual_column_crash.sql:2) are byte-identical to today, so not a regression. For a continuation-line match the only evidence the query ended is what executeQuery.cpp:405/412 emit: the ) closing (in query:, or the stack trace marker. Treating everything between record starts as query text would instead skip a real failure logged bare after such a record. Measured in the description; happy to take the stricter trade if you prefer.
⚠️ Patterns whose alternation starts with .* match at offset 0, so the same-line marker check sees an empty prefix and cannot fire DISAGREE, pre-existing and unreachable. Identical at the base commit. parse_failure routes the sanitizer and runtime-error patterns to stderr.log, which carries no (in query: records, and tests/queries has zero quoters of the two that remain. On a continuation line the new guard is position-based, so match offset does not reach it.
💡 is_log_record_start was a third spelling of a predicate already inline twice AGREE, fixed. Both sites call the helper; and binds tighter than or, so it is behaviour-identical.
💡 The docstring justifies its two terminators via executeQuery, but QUERY_TEXT_MARKERS also carries (query:, whose producers do not put the query last AGREE, noted, not fixed. No behaviour follows: onFault logs Received signal N (...) as its own earlier <Fatal> record, which the record-start bypass keeps; DDLWorker's is real quoted DDL that should be skipped; ClientBase's goes to a stream this parser never reads.
💡 The walk's terminal "not inside" (lookback exhausted) is asserted in the description but no test reddens if it is flipped AGREE, declined. It is the fail-open direction, so its failure mode is today's behaviour, and the three branches that can actually suppress a match are each pinned.

Two suspicions raised and killed, so nobody re-derives them: that the walk could hide a real SIGSEGV
(refuted by that earlier <Fatal> record), and that the per-candidate sed is quadratic (it runs only
for the quoted continuations this change skips, on a path that previously burned 22 minutes of CPU on
this same log).

@clickhouse-gh clickhouse-gh Bot closed this Sep 21, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 21, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c9bdb66]

Summary: ✅


AI Review

Summary

This PR improves FuzzerLogParser so quoted multi-line query text no longer steals the failure name, but the current quoted_query_ends heuristic still closes SignalHandlers.cpp crash records too early. Because (query:) preserves raw query newlines, an intermediate query line ending with ) can still make the parser report quoted Assertion / Logical error text instead of the actual crash classification, so I do not think this is ready to merge yet.

Findings

⚠️ Majors

  • [ci/jobs/scripts/log_parser.py:318] quoted_query_ends treats any earlier physical query line ending with ) as the end of a (query:) crash record, but SignalHandlers.cpp keeps the raw query newlines. A record like ... (query: SELECT tuple(1)\n-- Assertion \quoted_expr` failed\nUNION ALL SELECT 2) Received signal 11 (Segmentation fault)still returns the quotedAssertionon the current PR head, so the parser can still name the run after quoted text instead of the crash. Suggested fix: only treat bare)as a terminator forexecuteQuery's toOneLineQueryrecords, and for(query:)crash records look for the real closing) Received signal ` on the actual crash line rather than on arbitrary earlier query lines.
Final Verdict

Changes requested.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 21, 2026
@groeneai
groeneai requested a review from maxknv September 21, 2026 12:17
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 22, 2026
Comment thread ci/jobs/scripts/log_parser.py Resolved
Comment thread ci/tests/test_log_parser.py Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3cae437

Every failure below has an owner: a fixing PR (mine 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
AST fuzzer (amd_release, oracle) / Subquery wrap oracle mismatch wrong result, not caused by this PR: SELECT DISTINCT * APPLY (toTypeName, 'f_') FROM (SELECT 255 AS A, 257 AS B) AS X ALL LEFT JOIN (SELECT 257 AS A, 2 AS B) AS Y USING (B) names both A columns f_A, and wrapped as SELECT * FROM (...) it returns UInt16, UInt16, UInt16 instead of UInt16, UInt8, UInt16. Reproduced on master e5b8853baca3. The same oracle message hit 21 PRs in 30 days #107127 (mine, open): it gives the later of two same-named subquery columns a unique internal name, so the outer SELECT * keeps both values
Mergeable Check, PR rollups, red only because of the row above #107127 (mine, open)

This PR cannot reach it: the diff is CI Python only (ci/jobs/scripts/log_parser.py and the
removal of ci/tests/test_log_parser.py), which names a failure after the run and cannot change a
query result.

All 172 check runs completed (36 pass, 133 not selected, 3 red), Finish Workflow is green and
CH Inc sync passed. CIDB has no FAIL or ERROR test row on this head; the mismatch is on the
job-level row.

Session id: cron:our-pr-ci-monitor:20260927-093142

alexey-milovidov and others added 2 commits September 28, 2026 10:03
…uery

`inside_quoted_query` treated any preceding line ending with `)` as the end of
the quoted query. Every continuation line of a quoted query exists because
`toOneLineQuery` keeps the newline after a `--` comment, so a line such as
`-- Selecting subcolumns (e.g. .null, .size0, tuple elements, map keys/values)`
(from `04097_buffer_subcolumn_virtual_column_crash.sql`) ends with the comment's
`)`, not the query's. Only a `)` on a line without a `--` comment now ends it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121339&sha=3cae43799588f8dc278a5d23f2692760a9d2929b&name_0=PR&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

It looks like #122327 (SELECT * EXCEPT/APPLY/REPLACE with JOIN USING gives a different result when wrapped in a subquery). It is unrelated to this PR, which only touches ci/jobs/scripts/log_parser.py.

Comment thread ci/jobs/scripts/log_parser.py Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

Acknowledged. The duplicate name comes from my #109223 (merged on 09-21): it made the analyzer honor the APPLY (f, 'prefix') name prefix and, as the old analyzer did, puts it on the short column name. Over a join, X.A and Y.A therefore both come out as f_A (plain APPLY toTypeName keeps them apart as toTypeName(A) and toTypeName(Y.A)), and the outer SELECT * of the wrapped query then returns one of them in both positions. #122327 is the same bug. I'll send a separate PR for it and link it here, instead of relying on the broader #107127 from the ledger.

…query lines

`inside_quoted_query` kept a quoted query open past any line containing `--`,
so `SELECT if(1, '--', 'x'))` did not close it and a real failure logged after
it was skipped as quoted text; and `#`, `//` and `/* ...` comment lines ending
with `)` still closed it. `ends_in_comment` now scans the query part of the line
(after the `(in query:` marker on the record's first line), skipping string
literals and quoted identifiers, and reports whether the line ends inside a
`--`, `//`, `# `, `#!` or unterminated `/*` comment, like the `Lexer`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread ci/jobs/scripts/log_parser.py Resolved
@groeneai

Copy link
Copy Markdown
Collaborator Author

The fix is #122702: the prefixed name now keeps the qualifier (f_Y.A, like toTypeName(Y.A)), so the query from the ledger above returns UInt16, UInt8, UInt16 with and without the SELECT * FROM (...) wrapper. It also closes #122327.

`inside_quoted_query` decided line by line whether a `)` ending a line
closed the quoted query, so a `/* ... */` comment spanning several lines
lost its state and a `)` ending a line inside it was taken as the end of
the query. Now the marker line is found first and the query text is
scanned forward from it, carrying the (nested, as in `Lexer`) block
comment depth from line to line.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread ci/jobs/scripts/log_parser.py Resolved
…ved signal`

The crash record of `SignalHandlers.cpp` is `(query: {}) Received signal {} ({})`
and keeps the query's raw newlines, so for a multi-line query the `)` closing
the quoted query precedes the match in the same line, not at its end. Check the
current line's text before the match too, and treat `) Received signal ` as the
end of the quoted query, so such a crash is named `Segmentation fault` /
`Received signal` instead of falling back to a generic `<Fatal>`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread ci/jobs/scripts/log_parser.py Resolved
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Sep 30, 2026
The analyzer names a matched column whose bare name also binds to another
table expression, an alias or an ARRAY JOIN expression with a qualified
projection name (`r.a`), and an unprefixed `APPLY f` wraps that name
(`toString(r.a)`). ClickHouse#109223 made the analyzer honor the `APPLY` name prefix,
but seeded the prefixed name from the short column name, so `l.a` and `r.a`
of a join both became `f_a`. Two different columns under one name then
collide wherever the name is the key: `SELECT * FROM (...)` over the query
reads the first `f_a` twice (wrong result, issue ClickHouse#122327 and the AST fuzzer
"Subquery wrap oracle mismatch" on ClickHouse#121339 and in two other PRs), two
different constants under one name fail the block structure check with
`Code: 352 AMBIGUOUS_COLUMN_NAME`, and `remote()` over such a query fails
with `Code: 44`.

Seed the prefixed name from the column's projection name instead: `f_r.a`,
the same base `*` and `APPLY f` use, and the same base a chained prefix after
an unprefixed transformer already had (`q_toString(r.a)`). Names change only
where the unprefixed name is already qualified: joins, a SELECT alias equal
to a column name, an ARRAY JOIN clash and `tuple.*` (`f_tup.x`); a plain
single-table `*` keeps `f_a`. A `REPLACE` result keeps the replaced column's
name, so a `REPLACE (untuple(a) AS a)` expansion resets the accumulator to it
(`a.1`, not `r.a.1`).

The new test covers JOIN USING/ON, two tables, three joins, qualified and
tuple matchers, join_use_nulls, a lambda, chained prefixes, named untuple and
COLUMNS, with single-table and REPLACE controls. 04401 now expects `f_x.a`
for a column qualified by a clashing SELECT alias, like its unprefixed
`toString(x.a)`.

Closes ClickHouse#122327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ClickHouse:master with commit bb982cb Oct 1, 2026
149 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2026
maxjustus pushed a commit to maxjustus/ClickHouse that referenced this pull request Oct 1, 2026
The crash record of `SignalHandlers.cpp` keeps the query's raw newlines, so an
earlier line of the query ending with `)` (e.g. `SELECT tuple(1)`) does not
close the quote, and the real end of the query may be inside a comment
(e.g. `SELECT 1 -- c) Received signal 6`). `quoted_query_ends` now ends the
quote of a crash record only at `) Received signal `, so the failure is no
longer named after failure text quoted on a later line of the query.

Follow-up of ClickHouse#121339 addressing
its unresolved review thread.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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 comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding manual approve Manual approve required to run CI 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