Repository navigation
Conversation
On the nightly per-test coverage job, tests are reported as `result differs with reference` where the only divergence is the profiling runtime's own diagnostics. Over 30 days: 13 carrier tests, 76 rows, and for every carrier the added diff lines are the `LLVM Profile Error:` lines. The tests' own output is correct. `clickhouse-test` sets `LLVM_PROFILE_FILE=...-%2m.profraw` per worker, and `%2m` is a two-slot merge pool (`ProfilePoolId = getpid() % MergePoolSize`), so short-lived `clickhouse-client` processes of one worker collide and a loser prints one of three messages on stderr. The harness already strips those from stderr, but a test that itself does `... 2>&1` merges the client's stderr into its own stdout before the harness sees either stream, and stdout is the file that gets diffed against `.reference`. The existing filter is correct and sits on the wrong stream. Apply the same rule to `stdout_file` at the post-processing tail of `run_single_test`, where that file is already rewritten in place before the reference diff runs. The transform removes the matched message span rather than the whole line. In four of four recorded occurrences of `00933_ttl_replicated_zookeeper` the third message arrives as `...profraw": Success200`, with the test's real `200` glued onto it by byte interleaving in the merged pipe, so dropping the line would delete real output and leave the test failing. The span is bounded by the `strerror` table, matched longest-first, because that table contains values with digits and values that are prefixes of other values. A per-test filter cannot replace this. The noise reaches stdout by four routes: a direct `2>&1` on a client line, the shared `query_with_retry` helper in `shell_config.sh` (so the test carries no redirection of its own), process substitution into a `grep` whose stdout is the test's stdout, and a `.python` pipe; a fifth carrier uses `clickhouse-keeper-client`, a different binary. 918 stateless `.sh` files use `2>&1` and none of them filters this. The failing job is scheduled from `nightly_coverage.py` and is absent from `pull_request.py`, so this change cannot be exercised by its own CI. It was validated locally in both directions through the real runner, against all 182 distinct message spans observed in 90 days, and against a mutant implementing the filter as a line drop, which fails exactly the glued cases.
…mment The comment above the pattern claimed the three matched messages were the only ones the profiling runtime can print. It cannot: `InstrProfilingFile.c` alone has 24 `PROF_ERR` sites, the whole `compiler-rt/lib/profile` has 33 with 23 distinct format strings, and the merge path this change is about has five (`:399`, `:407`, `:431`, `:469`, `:522`) of which the pattern covers one. Matching only the observed shapes is deliberate and correct, because an unmatched message is left alone rather than mistaken for real output; only the wording was wrong. A classification of every `LLVM Profile <level>:` span observed in the CI database over 180 days returns exactly the three handled shapes plus `Warning:`, and nothing else, so that is what the comment now says. No code byte changed: the four symbols' source segments are identical to the previous revision. The regression test is feasible even though a 237-line predecessor for a similar runner filter was deleted from `ci/tests/`. That removal was mechanical, not a judgement on runner tests: the deleted file constructed a `TestCase` and called `process_result_impl`, so it broke when those internals moved and blocked CI. The surviving 103-line sibling `test_shared_engine_replacer_discovery.py` uses the same `runpy.run_path` loader and passes, because it only calls pure helpers. `strip_llvm_profile_errors_in_file(filename)` is pure, so this arm takes the same shape and references neither `TestCase` nor `TestSuite` nor `process_result_impl` nor `argparse`. It is also the only CI signal this change can have. `per_test_coverage` runs from `nightly_coverage.py` on a schedule and is absent from `pull_request.py`, while `ci_tests` is a pull-request job whose digest already includes both `./ci` and `./tests/clickhouse-test`. Nine byte-exact arms cover each message alone on a line, a message glued onto real output, a byte-identical no-op on clean stdout, non-UTF-8 bytes around a stripped span, a surviving `LLVM Profile Warning:` line, and an errno outside the `strerror` table keeping the whole message. A tenth assertion pins the call site by parsing `run_single_test`: the call must sit after every in-place `stdout_file` rewrite, so it sees their output, and before the return. Four mutants show the two halves are independently load-bearing: replacing the span strip with a whole-line drop reddens only three fixture arms, deleting the transform body reddens five, and deleting or hoisting the call site reddens only the wiring assertion. The added blank line before `str_to_numeric` removes a pre-existing `black` opinion about the file rather than adding one.
The comment budget allows at most three consecutive comment lines and requires added comments not to outnumber added code. The rewrite above had grown the block to four; this reflows the same three facts (the observed message set, the `file:line` citations, the strerror bound) onto three lines of 89 to 91 characters, within the file's own convention. No code byte changes.
Internal second-model review (click to expand)An independent reviewer read the resulting code cold (without the author's evidence) and a Second-model gate: 0 findings on the final commit. Its stated coverage: the full filter, The independent pass raised 3 items, all accepted. All three were inaccuracies in the
Because the description changed, the second-model gate was re-run against the corrected Checks the code passed, verified independently of the author's evidence:
Noted and deliberately left alone: the |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-42:20260806-021200 |
|
cc @fm4v @leshikus, could you review this? |
|
Workflow [PR], commit [fab1e8a] Summary: ❌
AI ReviewSummaryThis PR extends Findings
Tests
Final Verdict❌ Changes requested. Gate the stdout scrubber to actual coverage builds before merge; otherwise LLVM Coverage Report |
The profiling runtime's message ends with strerror(errno) and nothing delimits it from the test's own output, which the filter must keep. Three strerror values are prefixes of another one -- `Interrupted system call`, `No such device` and `Too many open files` -- so for those the noise case and a case where the test's output merely begins with the rest of the longer value are byte-identical. The regex sorted its alternatives longest-first, which is not a safety property: on that ambiguous input the longer value matched and 24 of 24 such arms lost real output. Requiring the whole longer value to be noise is the wrong bet, because deleting output makes a test pass incorrectly, while keeping a message leaves a diff. Matching only the 253 prefix-free values makes the alternation an antichain, so at most one member can match at any position and the result no longer depends on ordering (verified: identical output under both orderings). The three dropped values are still stripped when they own a whole line, since the newline delimits them there. Measured over the 182 spans this failure has produced in 90 days, in four embedding shapes: 728 of 728 outputs byte-identical to before, and none of those spans contains a dropped value. The prefix-pair arms are new and data-driven from libc, so a future libc gains coverage automatically; reverting the alternation to the full table reddens exactly those three and nothing else. Co-Authored-By: Claude Fable 5 <[email protected]>
Where one strerror value is a prefix of another, a message ending in the shorter value followed by the test's own output is byte-identical to a message ending in the longer one. Matching the shorter value there strips only part of a real profiling error and leaves the remainder glued into the test's stdout: 'LLVM Profile Error: Failed to write file "x": No such device or address\n200\n' came out as ' or address\n200\n', so the message was neither removed as noise nor left whole for the diff to show. Match a prefix-free value only when the bytes after it cannot extend it into another strerror value. An ambiguous tail then matches nothing and reaches the diff intact, which is the direction the pattern comment promises. libc reports 3 such pairs among its 256 values. The 182 spans this failure produced in CIDB over 90 days come out byte-identical to before, and a prefix-free value followed by ordinary output is still stripped, including one delimited by a newline from the rest of a longer value.
| # A test that merges a client's stderr into its own stdout (2>&1) does so | ||
| # before the harness sees either stream, so the stderr-side filter above | ||
| # cannot reach it and the noise is diffed against .reference. See #97020. | ||
| strip_llvm_profile_errors_in_file(self.stdout_file) |
There was a problem hiding this comment.
run_single_test is no longer transparent for ordinary stdout: this scrubber runs on every invocation, but the profiling noise it targets exists only on coverage-instrumented builds. With the current head, a test that legitimately prints
LLVM Profile Error: Failed to write file "x": Invalid argument
has that line deleted from stdout_file even on a normal run:
strip(b'prefix\nLLVM Profile Error: Failed to write file "x": Invalid argument\nsuffix\n')
# -> b'prefix\nsuffix\n'Because the worker loop exports LLVM_PROFILE_FILE unconditionally, seeing this literal in stdout is not proof that it came from the profiler. That means the new call can make a test pass incorrectly by deleting real output. Please gate it on actual coverage instrumentation (WITH_COVERAGE / WITH_COVERAGE_DEPTH, or an equivalent coverage_active check) so non-coverage runs keep stdout byte-for-byte.
|
@groeneai remove ci/tests/test_llvm_profile_stdout_filter.py |
Requested in review by fm4v. The filter in tests/clickhouse-test is unchanged; only its pytest arm goes away, and nothing else in the tree exercises strip_llvm_profile_errors_in_file now. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Removed in fab1e8a, so the PR is now only the One consequence for the record: nothing else in the tree exercises |
CI finish ledger -
|
| Check / test | Reason | Owner / fixing PR |
|---|---|---|
Stress test (arm_tsan) / Logical error: Not-ready Set is passed as the second argument for function 'A (STID 0250-41a5), Failures: 1/5 |
trunk logical error, server abort in a build with abort_on_logical_error. A speculative in-place IN-set build takes the destructive path for a source plan that cannot be cloned, and stops without creating the set and without throwing, so nothing is recorded in in_place_build_failure, FutureSetFromSubquery::build returns a null plan, every caller reads that as "nothing left to build", and FunctionIn throws at src/Functions/in.cpp:128 once the main pipeline evaluates the condition. src/Interpreters/PreparedSets.cpp:536-560 names this residual in master itself: for a non-clonable source "only the rare silent-failure case stays unrecoverable". 223 CIDB rows over 171 distinct pull requests in 30 days, 22 of them on master, first seen 2026-07-31, most recent 2026-08-29 00:44Z. This diff changes only how the test runner filters LLVM Profile Error: lines out of captured stdout, so it cannot reach that path. |
#102308 (external, open) |
That PR is the remedy for the residual, not a same-area coincidence: it makes the subquery plan
rebuildable after a failed in-place build (QueryPlanBuilder, setQueryPlanBuilder,
createQueryPlanForRetry) and builds into a temporary Set so a partial build cannot leak.
None of those symbols exists on master today. Tracking issue: #107619.
Session id: cron:our-pr-ci-monitor:20260829-010000
194df77
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
clickhouse-testnow removesLLVM Profile Error:messages from a test's stdout as well as its stderr, so coverage runs stop reportingresult differs with referencefor tests whose own output is correct.Description
On
Stateless tests (amd_llvm_coverage_per_test, per_test_coverage, N/8)(NightlyCoverage, master-only) tests are reportedresult differs with referencewhere the only divergence is the profiling runtime's own diagnostics. 30 days: 13 distinct carrier tests, and for every one the added diff lines are theLLVM Profile Error:lines. Only 4 have a fixing PR (#110716).Root cause.
clickhouse-testsetsLLVM_PROFILE_FILE=...-%2m.profrawper worker, so short-livedclickhouse-clientprocesses contend over a 2-slot merge pool and a loser prints, on stderr, one of the three messages ever observed for this failure. The harness already strips those from stderr (#102420, citing #97020), but a test that itself does... 2>&1merges the client's stderr into its own stdout before the harness sees either stream, and stdout is what gets diffed against.reference.Change. Apply the same rule to
stdout_fileat the post-processing tail ofrun_single_test, where that file is already rewritten in place 18 times before the reference diff runs.It strips the matched message span, not the whole line: in 4 of 4 recorded occurrences of
00933_ttl_replicated_zookeeperthe third message arrives as...profraw": Success200, with the test's real200glued on by byte interleaving, so a line-drop would delete that output.A per-test filter cannot replace this: the noise reaches stdout by four routes, including the shared
query_with_retryhelper andclickhouse-keeper-client.grep -rl '2>&1' tests/queries/0_stateless/*.shmatches 917 files; none carries a filter.Validation. The
per_test_coverageflavour every carrier was observed on is absent frompull_request.py; it runs only fromnightly_coverage.py, on a schedule. This PR's CI does run other coverage-instrumented stateless jobs, but the leak is a race between short-lived clients, so a green run there is not evidence either way. Verified locally, details below.Local validation (this PR's CI cannot reach the failing path)
Through the real runner, same server and same client shim emitting the verbatim captured bytes, only the runner differing:
result differs with reference,+...: Success200-200 / -400, real output deletedThat last arm is why the fix strips a span rather than a line.
Fixture level, driving the shipped transform extracted from the file by AST: 11 arms pass, including a byte-identical no-op control on clean stdout, non-UTF-8 input, a
LLVM Profile Warning:line surviving, and the message glued mid-line. All 182 distinct spans observed in CIDB over 90 days match an independently derived oracle. The line-drop mutant fails exactly the glued arms and leaves the others green; deleting the transform fails every carrier arm.Regression surface (the transform runs for every stateless test): a 164-test sample on both runners, identical pass/fail sets, identical failure reasons, zero regressions; plus 50 randomized runs of two controls, all green.
Left alone deliberately: the
%2mpool size (widening it only lowers the collision rate and changes what the coverage job measures), andLLVM Profile Warning:(3 rows in 90 days, all in the integration suite, with no reference diff).Workflow [PR]
Sync PR [sync-upstream/pr/113619]
Version info
26.9.1.312(included in26.9and later)