Repository navigation
Conversation
The functional/stress crash reporter (FuzzerLogParser in
ci/jobs/scripts/log_parser.py, invoked by
ClickHouseProc.check_fatal_messages_in_logs) named a failure by running
`rg -o 'Logical error.*'` over the whole clickhouse-server.log and taking
the first match. executeQuery logs the full query text (including SQL
comments), so when a job hit a real logical-error crash, the reporter could
pick up a different test's comment that merely quotes "Logical error '...'"
and use it as the failure name, while the STID and stack came from the
actual crash. This mislabels unrelated crashes and pollutes failure
tracking.
Changes, in log_parser.py:
- Match a logical error only when it is the message of a real formatted log
record, anchored to the actual line prefix
(^<date> <time> [ tid ] {query_id} <Level> [logger]: Logical error ...).
A query echo, a comment continuation line, and query text embedded on a
<Fatal> signal record's own line all fail that anchor. Genuine logical
errors are always emitted via LOG_FATAL (abortOnFailedAssertion), so
nothing real is missed. The sanitizer, assertion, segfault, signal, and
memory patterns are unchanged.
- get_failed_query() reuses the query id of the selected fatal record
instead of re-grepping the log from the top, so the reported failing
query matches the crash; an explicitly empty id (background exception)
reports no query rather than an unrelated one; and the inline
"Inconsistent AST formatting" query (which aborts before an executeQuery
record is logged) is still extracted. User-controlled query ids are
matched literally (re.escape + shell single-quote escape) inside their
exact {...} delimiters, so a metacharacter id runs safely and a prefix id
(q2) does not attribute a longer id's (q20) query.
Regression tests in ci/tests/test_log_parser.py: a query-echo comment
before a genuine <Fatal> logical error is not used as the name; a
non-fatal <Warning> mentioning the phrase is not selected over a later
fatal; an embedded fake log-record prefix inside a signal record's query
is ignored; the inline Inconsistent AST formatting query is returned even
when a fatal-record query id is supplied and is scoped to the selected
record (not an earlier echo); and a user-controlled query id is treated as
literal shell/regex data with exact {...} matching. Each test was verified
to fail against the pre-fix parser and against a surgically-degraded parser
(anchor removed / escaping reverted), proving it exercises its protection.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-1:20260723-232900 |
Internal second-model review — adjudication log (click to expand)Pre-publication review by an independent model (engine: codex). The reviewer drove the fix from an early per-pattern approach to the final, minimal, regression-free design. Consolidated dispositions across the review:
Severity: ❌ blocker / Session id: cron:clickhouse-author-slot-1:20260723-232900 |
|
cc @maxknv - could you review this? It fixes the functional/stress crash reporter ( |
|
Workflow [PR], commit [81c79d3] Summary: ❌
AI ReviewSummaryThis PR fixes the original single-line/query-comment misattribution in Findings❌ Blockers
Final VerdictStatus: ❌ Block Minimum required action: close the remaining multiline |
Query ids are arbitrary strings (Context::setCurrentQueryId does not
validate them) and may carry leading/trailing whitespace, e.g. `{ q }`.
parse_failure captured the id via `rg -r '$1'` and additionally called
`.strip()` on it; Shell.get_output also strips its output. A record id
` q ` was therefore reduced to `q`, after which get_failed_query's exact
`{...}` executeQuery lookup no longer matched the real `{ q }` record and
the crashing query was dropped from the reported info (the logical-error
name was still correct).
Extract group 1 of the matched record with re.match instead, so the id
between the `{...}` delimiters is preserved verbatim regardless of the
surrounding-whitespace strip. Add a regression test through the full
parse_failure path using the spaced id `{ q }`.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Master gained five commits in the same FuzzerLogParser code this branch rewrites (3193d5c, f371033, 33cbc0f, edf3aa8, cf2cfec), all bounding the `Format string:` search by the matched failure. Both changes are wanted and neither subsumes the other, so the branch's anchoring is re-expressed on top of master's bounded-search version rather than reverting it: the resolved tree differs from master only in this branch's own delta. The pattern list stays master's class-level ERROR_PATTERNS (it now has two consumers) and is extended from 3-tuples to 4-tuples with the `server_pattern` axis, instead of reintroducing a second local copy that could drift. Two composition points needed real work. First, the anchored pattern must not simply replace the unanchored one. It matches only whole formatted server-log records, so on an input with no such records - stderr.log standing in for an absent server log, which master's new test_parse_failure_logical_error_file_without_thread_ids feeds - a logical error stopped being detected at all and the failure was reported as "Unknown error". It is now used only where it can apply, mirroring the distinction find_format_string already draws on thread ids. An unconditional fallback was tried first and rejected: it re-admits what the anchoring exists to exclude, namely a fully-formed record prefix appearing mid-line inside an echoed query. Second, find_format_string locates the failure block with `rg -n -m1` on the pattern that matched. Passing the unanchored pattern makes it land on the query-echo comment - the very line this branch skips - so master's bounded search would bound the wrong block. parse_failure now records the pattern that actually produced the output. All nine of master's parser tests and all eight of this branch's pass together (18 with a new arm pinning the second point above). Verified by mutation: each of the two composition fixes, the anchored scan, the byte-for-byte query id capture and the id plumbing reddens its own arm when reverted. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Merged master to resolve the conflict. Flagging it because the resolution was not mechanical. Master gained five commits in Two composition points needed real changes, and one of them was a bug in my branch that only
All 18 parser tests pass together (9 from master, 9 here, the last of which is a new arm pinning This lands on top of an existing approval. The intent of the diff against master is unchanged, |
|
One correction to a claim I made on this branch's review rounds, now that I have measured it on a running server. I had argued the query id was the only carrier able to forge a whole formatted record, and that no consumer-side rule could close it. Both halves are wrong. Against the anchored So sanitizing the query id would not have closed the attribution hole, and this PR's anchoring is not weakened by leaving it unsanitized. I am not raising a follow-up: the TCP path does lack the control-character strip that |
Master removed ci/tests/test_log_parser.py in ClickHouse#114675 ("Remove unit tests for CI scripts"), which produced a modify/delete conflict against the test file this branch extends. That pull request deleted 71 files under ci/tests and then restored 39 of them over the following two days, each restore commit naming the criterion: coverage that is the only focused guard for a still-live CI job or merge gate. test_log_parser.py was not among the restored files and was not raised in that pull request's review, so this merge honours the deletion instead of reinstating it, and the branch now changes only ci/jobs/scripts/log_parser.py. The parser change itself is unaffected: master has not touched log_parser.py since cf2cfec (2026-08-05), which this branch already merged, so the file is byte-identical to the previously reviewed version. The 18 assertions the deleted file carried were kept as a throwaway harness and run against the merged tree, per the guidance added in ClickHouse#114703 that CI script changes may be validated with a throwaway test rather than a committed one. All 18 pass, and each of the five behaviours this branch introduces was confirmed still pinned by reverting it in turn: stripping the captured query id, bypassing the anchored server pattern, applying it unconditionally, scanning for the format string with the unanchored pattern, and dropping the query id passed to get_failed_query. Every one reddens the corresponding assertion.
|
Merged master to resolve the conflict. Flagging one decision, since it changes what this pull request contains. The conflict was a modify/delete on The parser change itself is untouched: master has no commits to I kept the 18 assertions the deleted file carried as a throwaway harness and ran them against the merged tree, per the guidance #114703 added for CI script changes. All 18 pass. I also reverted each of the five behaviours this branch introduces in turn, to confirm they are still pinned rather than merely passing: stripping the captured query id, bypassing the anchored server pattern, applying it unconditionally, looking up the format string with the unanchored pattern, and dropping the query id passed to |
| # Group 1 is the query id, group 2 the message. | ||
| LOGICAL_ERROR_SERVER_PATTERN = ( | ||
| r"^[0-9]{4}\.[0-9]{2}\.[0-9]{2} [0-9:.]+ \[ [0-9]+ \] " | ||
| r"\{([^}]*)\} <Fatal> [A-Za-z0-9_:]*: (Logical error:.*)" |
There was a problem hiding this comment.
This anchor still accepts forged line-start records from user-controlled multiline fields, so the reporter can still name a real logical-error failure after echoed text.
executeQuery logs log_comment verbatim, and the signal handler logs query verbatim. A value containing a newline followed by 2026.07.23 ... {fake} <Fatal> : Logical error: 'forged' becomes a continuation line that satisfies this regex exactly. On current head, parse_failure() then returns the forged name and fatal_query_id = fake instead of the later genuine {q2} fatal. Minimal repro:
2026... {q1} <Debug> executeQuery: (comment: harmless
2026... {fake} <Fatal> : Logical error: 'forged')
...
2026... {q2} <Fatal> : Logical error: 'genuine crash'.
So the PR's core contract still does not hold for multiline log_comment / embedded query text. This needs either producer-side newline escaping/sanitization for those fields or a parser-side discriminator that a continuation line cannot synthesize.
There was a problem hiding this comment.
The mechanism is real: I ran your example through parse_failure() on the current head and it returns Logical error: 'forged') (stage: Complete) with fatal_query_id = fake, as you describe.
It is not introduced here, and it is not narrowed by anything this PR could do. Same input on pre-fix master gives the identical name, so this is master's behaviour, unchanged.
Two carriers, measured A/B on both parsers:
| carrier | master | this PR |
|---|---|---|
SQL -- comment echoed by executeQuery |
misattributed | correct |
raw newline in log_comment / query text (your case) |
misattributed | misattributed |
The first one is the carrier this PR exists to fix, and the anchor does fix it: toOneLineQuery re-emits the newline after a Comment token (src/Parsers/toOneLineQuery.cpp:22-26), so the continuation line still carries -- and fails the anchor. Your case has no such prefix, so the continuation is a well-formed record. Nothing regresses either way.
On the parser-side option: I do not think one exists. OwnPatternFormatter::formatExtended writes msg.getText() verbatim (src/Loggers/OwnPatternFormatter.cpp:65) with no escaping, no newline handling and no record terminator, so a continuation line of a multiline message is byte-identical in form to a genuine record. Checked directly against the anchor: forged and genuine lines both match and both yield a well-formed query id and message. There is no property local to the line that separates them, and record boundaries cannot be recovered from a stream that never marked them. That leaves your first option, producer-side escaping, as the only sound remedy, and it changes server logging (executeQuery, the signal handler, the formatter) rather than the reporter.
I am not doing that here: it is a different concern, it would invalidate the existing approval, and there is no observed occurrence to justify the scope. CIDB over 90 days has 0 logical-error failure names carrying the (stage: or (comment: tail such a forgery leaves, against 12078 logical-error rows as a control. That is no evidence of occurrence rather than proof of absence, since a carefully crafted comment would not be distinguishable in that column, so I am recording the residual here rather than filing it.
CI finish ledger — 295620aEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task 177 check runs: 150 skipped, 26 success, 1 failure.
The failure is not caused by this PR: the job aborted in the package-download prologue, before Breadth over 3 days for that signature: 40 rows across 40 distinct pull requests, 0 on master, Session id: cron:clickhouse-maint-slot-16:20260817-173600 |
CI finish ledger - 81c79d3Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link is
Session id: cron:our-pr-ci-monitor:20260831-040000 |
|
Fixing PR for the The four leaked |
|
Dear @maxknv, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #108735
The functional/stress crash reporter (
FuzzerLogParserinci/jobs/scripts/log_parser.py, invoked byClickHouseProc.check_fatal_messages_in_logs) names a failure by runningrg -o 'Logical error.*'over the wholeclickhouse-server.logand taking the first match.executeQuerylogs the full query text (SQL comments included) into the server log, and the signal handler embeds the crashing query inside a<Fatal>record. So when a job hits a real logical-error crash, the reporter can pick up a different test's comment that merely quotesLogical error '...'and use it as the failure name, while the STID and stack come from the actual crash. This mislabels unrelated crashes and pollutes failure tracking.Concrete example (MasterCI,
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)): the real crash was<Fatal> : Logical error: 'Got read request from replica 1 for unknown stream ...'(ParallelReplicasReadingCoordinator), but the reporter named it after a regression test's!part.empty()/Bad cast ...comment. This wrongly reopened an unrelated tracking task.Fix, in
log_parser.py:Logical erroronly as the message of a real formatted log record, anchored to the line prefix^<date> <time> [ tid ] {query_id} <Fatal> [logger]: Logical error: .... A query echo, a comment continuation line, and query text embedded mid-line on a<Fatal>signal record all fail that anchor. The anchor also requires the<Fatal>level and theLogical error:colon, so a benign<Warning> ...: Logical error. Not all polled messages ...is not selected. Genuine logical errors are always emitted viaLOG_FATAL(abortOnFailedAssertion), so nothing real is missed. The other patterns (sanitizer, assertion, segfault, signal, memory) are byte-for-byte unchanged.get_failed_query()reuses the query id of the selected fatal record instead of re-grepping the log from the top, so the reported failing query matches the crash. An explicitly empty id (background exception with no query) reports no query rather than an unrelated one; the inlineInconsistent AST formattingquery (which aborts before anexecuteQueryrecord is logged) is still extracted, scoped to the selected record; and the query id is matched inside its{...}delimiters and escaped, soq2no longer also matches{q20}and a metacharacter id is literal.Added regression tests in
ci/tests/test_log_parser.py; existing tests unchanged.Workflow [PR]
Sync PR [sync-upstream/pr/111708]