Skip to content

Do not refute a bugfix unit test on a build that cannot observe it - #116662

Merged
alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
groeneai:unit-bugfix-validation-escalate-to-tsan
Sep 20, 2026
Merged

alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
groeneai:unit-bugfix-validation-escalate-to-tsan

Conversation

@groeneai

@groeneai groeneai commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

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):

Not required (CI only).

Description

Bugfix validation (unit tests) built the merge-base "before" binary under one build type
(BuildTypes.AMD_ASAN_UBSAN) and refuted the regression gtest when it passed there. A test
whose property only shows under another sanitizer passes there either way, so the job
reported Failed to reproduce the bug. and new_tests_check.py made Finish Workflow red.

Only a build type that both compiled the overlaid tests and ran them now has a verdict.
Three outcomes have none and escalate instead of deciding: every touched test passed; a case
of a changed test file did not run; or the overlaid tests do not compile there, which one
sanitizer can do alone. A GTEST_SKIP()
case is reported as result="SKIPPED" with status="RUN" and a disabled one as
"SUPPRESSED", both of which from_gtest reads as a pass, so gtest_resize_transform.cpp
(one TEST, skipped under every sanitizer) was refutable with nothing executed. A case behind
a preprocessor guard is absent from the report instead, so the cases each changed file
declares are also matched against it, through all four gtest naming forms; six in-tree files
compile out some cases on one sanitizer arm and keep others. The last arm refutes only when
all of them ran the tests and passed, reports XFAIL when none compiled the overlay, and is
inconclusive otherwise; new_tests_check.py still blocks on failed-to-reproduce alone and
is untouched.

On #115659's two gtests without its fix, TSan aborts on the Context::getReadSettings /
SettingsImpl::set race 5/5 runs, where ASan+UBSan reports fail: 0, passed: 9. Over 60
days of CIDB, 30 runs across 17 PRs returned XFAIL from the first arm; each now pays a second
cold arm, 50-75 min against a 240-min timeout. amd_msan and amd_debug stay blind spots: every arm is a cold
build. The ci/tests/ hunk only adapts stub signatures; that directory is going away.

Requested on #113397; #114400 was the first answer.

Related: #115659
Related: #113397
Related: #114400


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

Version info

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

`Bugfix validation (unit tests)` built the merge-base "before" binary under a single
build type (`BUILD_TYPE = BuildTypes.AMD_ASAN_UBSAN`, introduced by b5abadc and
never changed) and refuted the PR's regression gtest whenever every touched test passed
on it. A regression test whose asserted property is only observable under a different
sanitizer passes on that binary either way, so `main()` reported `Result.Status.FAIL` /
"Failed to reproduce the bug." and `new_tests_check.py:220-227` turned that into a red
`Finish Workflow` for a unit-only bugfix PR. The refutation was guaranteed by
construction and independent of whether the fix and the test were correct: the run could
not observe what it was asked to judge.

This is an asymmetry with the job's own siblings, not an oversight in the abstract.
`ci/jobs/scripts/bugfix_validation.py:9-10` already validates functional/integration
tests across `[amd_asan_ubsan, amd_tsan, amd_msan, amd_debug]` and passes if any arm
reproduces. Those validators can afford four because they download prebuilt master
binaries, while this job must build each arm cold (~1h, ~0% sccache hits, documented in
`configure_before_binary`), which is why its set was never widened.

Escalate lazily instead: keep ASan+UBSan as the first arm and try the next build type
only when an arm ran every touched test with none failing. The arms share one build
directory, emptied between them fail-closed, because configuring a different `SANITIZE`
value on top of the previous `CMakeCache.txt` builds one sanitizer while the report names
another. FAIL after the last arm still blocks, preserving the contract set by
0154e71 ("only on failed-to-reproduce"), and `new_tests_check.py` is untouched.

Each arm's `Result` carries its build type, which is a correctness requirement rather
than cosmetics: `Result.from_commands_run` derives the log path from the result name
(`{TEMP_DIR}/{normalize_string(name)}.log`), so two arms sharing a name write one file
and the second overwrites the configure and compile logs of the arm that started the
escalation.

`run_gtests` now pins `external_symbolizer_path`. A sanitizer report is symbolized before
the process aborts, and with no unversioned `llvm-symbolizer` on PATH the runtime falls
back to `addr2line`, which does not finish on the multi-GB binary: measured locally, two
runs of the TSan before-binary sat at 900 s and 420 s with no output while the writer
thread held `Context::mutex` inside `Addr2LineProcess::ReadFromSymbolizer`, and with the
option set the same run aborts in 8 s with a fully symbolized report.
`ci/docker/test-base/Dockerfile` creates that symlink deliberately, but this job runs in
binary-builder, which installs `llvm-symbolizer-<version>` and symlinks only
profdata/cov/bolt/merge-fdata.

Measured on ClickHouse#115659's two gtests overlaid on a tree without its fix: the TSan
before-binary aborts on a data race between `Context::getReadSettings` and
`SettingsImpl::set` in 8-9 s, 5 of 5 runs; ASan+UBSan reports `fail: 0, passed: 9`,
matching what CI reported; with the fix applied TSan is green 3 of 3. Fed through
praktika's own runner, the aborted run yields `Result.Status.FAIL` with the crashed test
recovered as `Context.GetReadSettingsRace`, which is the reproduction branch of `main()`.
One arm took 57.7 min against the job's 240-min timeout, and 14 of 3782 `Bugfix
validation (unit tests)` rows over 180 days (0.37%) reach a second arm.

Scope: ASan+UBSan and TSan. `amd_msan` and `amd_debug` stay excluded, so a regression
test that needs one of them is still refuted by a run that cannot observe it; adding
either is a one-element change to `BEFORE_BUILD_TYPES` plus a timeout increase.

ClickHouse#96868 validated bugfixes against multiple build types eagerly and was reverted three
hours later by ClickHouse#97011. This differs by escalating lazily on a job that already builds
cold, two arms rather than five, no S3 artifact dependency, and no change to job
scheduling or `ci/defs/`.

The eight new arms in `ci/tests/test_unit_tests_bugfix_validation.py` are mutation-proven:
removing the return after a reproduction, deleting the escalation, dropping the
refutation status, escalating from the "ran no touched test" branch, making the build-dir
reset best-effort, and collapsing the per-arm result names each redden their own arm.
… is per build type

Review round 1 on the escalation change asked for three things.

The `set_sanitizer_symbolizer_options` guard shipped with no test arms, although its
failure mode is silent: with no symbolizer pinned the sanitizer runtime falls back to
`addr2line`, which does not finish on `unit_tests_dbms`, so a reproduction arrives as a
240-min job timeout rather than as a verdict. Nothing existing could catch a regression
in it either, because the escalation arms replace `run_gtests` wholesale. Four arms now
pin its four branches: the unversioned symbolizer is applied to every var in
`_SANITIZER_OPTION_VARS`; the fallback name is derived from `ToolSet.COMPILER_C` rather
than hardcoded, so a compiler bump does not silently stop resolving it; nothing is found
and the helper warns and changes nothing; and a second call keeps an already-pinned path
and appends to pre-set options instead of replacing them. Each arm is proven by a mutant
that reddens it and no arm that predates it. The helper's behaviour is unchanged.

Failing open when no symbolizer exists is deliberate, and one of the arms now records
that decision: the helper runs on every arm of every run, while 3457 of 3829 job rows in
90 days return a verdict without ever emitting a sanitizer report. Refusing to run would
turn those into inconclusive runs, and an inconclusive unit validation does not block a
merge, so it would disable the gate for exactly the refutations it exists to block.

The module docstring still described a single before-build and named `Unit tests
(asan_ubsan)` as the only after-side counterpart. It now says the before-binary is built
and judged once per build type in `BEFORE_BUILD_TYPES`, that a clean arm escalates rather
than refutes, and that the after-side counterpart is the `Unit tests` job of the arm that
reproduced, so a bug reproduced under TSan is complemented by `Unit tests (tsan)`.

The five em-dashes this change had added are now plain ASCII. The two in message text are
`Result` info strings that nothing parses; the remaining em-dashes in both files predate
the change and are left alone.

The environment isolation in the new arms uses `monkeypatch.setenv`, not
`monkeypatch.delenv(..., raising=False)`: `_pytest.monkeypatch.delitem` records an undo
entry only for a key that is already present, so on an absent var it records nothing and
a value the helper then writes survives the arm. Measured both ways; `ci/tests` runs as a
single pytest process, so a leaked `external_symbolizer_path` would reach every later
module. `ci/tests/test_expect_debuglog_separation.py` makes the same distinction.
Review round 2 found three mutants in the escalation mechanism that the whole test module
leaves green, so each is a capability this change claims and nothing checks.

`configure_before_binary` looks its cmake flags up per arm, which makes "arm i is
configured with build type i's flags" a new invariant. With the wrong index the second arm
builds ASan+UBSan again while its `Result` name, `arms_tried` and the final refutation info
all name `amd_tsan`, so a TSan-only regression test would be refuted with a false claim
that TSan was validated. That is worse than the honest single-arm refutation this change
replaces, and it is the defect class the change exists to remove. The capture the log-path
arm already performs is factored into `_drive_configure_and_compile`, and one new arm
asserts that the two arms' `-DSANITIZE=` tokens differ and that arm i carries the token of
its own build type's entry in `BUILD_TYPE_TO_CMAKE`. Both expectations are derived from
`BUILD_TYPE_TO_CMAKE` and `BEFORE_BUILD_TYPES` rather than from literals, so adding a third
build type needs no test edit. The log-path arm keeps its assertions byte for byte.

`reset_before_build_dir` was covered only by its predicate, and that arm stubs
`Shell.check`, so deleting the `rm -rf` outright left it green. Without the deletion the
directory survives, the predicate returns False on every escalation and no second build type
is ever built: fail-closed, but the mechanism silently stops working. One new arm runs the
real `rm -rf` against a `tmp_path` it asserts it owns.

Nothing pinned that `run_gtests` calls the symbolizer helper at all. The helper's own arms
call it directly and every orchestration arm replaces `run_gtests` wholesale, so removing
the single call between them changed no test. One new arm captures `TSAN_OPTIONS` inside the
stubbed `Result.from_gtest_run`, that is, at the moment the child would be launched; reading
the environment after the call would also pass if the option were set too late.

Each of the three mutants reddens its own arm and none of the 109 arms that predate this
round, with the production file restored byte for byte and its sha256 asserted equal. No
production code changes in this round.

The wiring arm also pins `OPENSSL_CONF`, which `run_gtests` sets to `/dev/null`. Measured
both ways: without that line the value survives the arm and reaches every later module,
since `ci/tests` runs as a single pytest process. The arm asserts nothing about it, because
that line is not part of this change.
`ci/tests/` is being removed, so this change stops adding to it. The review that approved
ClickHouse#115825 reads, in full, "We don't use ci/tests, they will be removed.", and ClickHouse#115650
(+9/-24715) is open against that directory: its file list includes
`ci/tests/test_unit_tests_bugfix_validation.py`,
`ci/tests/test_new_tests_check_unit_gate.py` and `ci/jobs/ci_tests_job.py`, the runner that
executes them. The first tranche, ClickHouse#114675 (+0/-6543), merged on 2026-08-15. The 15 arms
added in the three earlier rounds of this change are therefore deleted rather than thinned
or relocated: thinning still adds to a directory that is going away and still leaves a
conflict to resolve. The earlier precedent for adding there, ClickHouse#114400, merged on 2026-08-13,
before both that tranche and that review, so it does not license adding there now.

What remains under `ci/tests/` is three stub signatures, and they are not arms kept by
preference. `configure_before_binary` and `compile_before_binary` take a build type in this
change, so without the adaptations 9 of that module's 97 existing cases raise `TypeError`
and the live `CI Tests` job goes red on this PR. With them the module is 97/97 and the
sibling gate module is 5/5.

The correctness argument does not depend on the deleted arms. Fourteen mutants across the
three earlier rounds each reddened only the case written for it and never a pre-existing
one, and the last three were first run against all 109 pre-existing cases and survived,
which is what established that each claim was genuinely uncovered rather than redundant.
That record is evidence about this change, not shipped coverage. The module's own docstring
already states that the build and run orchestration is validated separately in CI, so the
file returns to exactly the coverage it had rather than below it; what is given up is a live
regression guard for the escalation loop until ClickHouse#115650 lands.

Separately, the module docstring claimed this job "builds the before binary in parallel with
the build matrix (it starts as early as the functional/integration validators)". It does
not: `ci/workflows/pull_request.py:139` is
`JobConfigs.bugfix_validation_ut_job.set_run_after(CORE_BLOCKING_JOB_NAMES)`, the comment
directly above it says the job is deferred behind the core blocking jobs, and that list
includes every unit-test job. The clause was master's, but this change re-flowed the
paragraph around it, so it is corrected here. The artifact-dependency half is true and
stays: the job does not need the PR's `UNITTEST_AMD_ASAN_UBSAN` artifact, so it is not
gated behind `build_amd_asan_ubsan`.
The compile-failure attribution branch runs once per escalation arm, so on any
arm after the first it reported XFAIL with "the changed test code depends on the
interface this PR introduces". Escalation is only reachable after an earlier arm
compiled the identical overlay and ran every touched test cleanly, so that arm
has already disproved the interface-dependency explanation. Report ERROR
(inconclusive) instead, which is what this module's doctrine already prescribes
for a compile failure that is not attributable to a missing interface.

Gating is unchanged. new_tests_check.py blocks only on Result.Status.FAIL, while
Result.create_from maps an XFAIL sub-result to an OK job and an ERROR sub-result
to an ERROR job. Neither is FAIL, and the job carries set_allow_failure(True)
precisely so that an inconclusive ERROR does not hard-block merge.

Also remove two stale scheduling claims from this file. The "runs in parallel
with the build matrix" claim was raised twice by the pre-publication review: the
previous round corrected only the sentence that round cited and left an identical
claim further down, so the module docstring and configure_before_binary ended up
contradicting each other. Ground truth: pull_request.py:139 sets
run_after(CORE_BLOCKING_JOB_NAMES), which includes every JobConfigs.unittest_jobs
entry, and one of those requires UNITTEST_AMD_ASAN_UBSAN, so this job is
transitively ordered after build_amd_asan_ubsan. Only the direct artifact
dependency is absent, which is all the docstring claims now. A third copy of the
claim in ci/defs/job_configs.py is deliberately left alone: editing it would pull
the ci/defs digest and the praktika yaml regeneration surface into this change
for the sake of a comment.

Finally, drop "must fail" from the per-arm run's Result name. On the escalation
path arm 1's run is appended with status OK while its name still read "must
fail", pairing a green outcome with a contradictory label. The expectation is
still carried by mark_reproduced, which sets XFAIL on a reproduction, and by the
refutation path's "Failed to reproduce the bug" info. The {build_type}
interpolation stays, because it is what keeps the per-arm log filenames distinct.
…as confined, not excluded

The later-arm compile-failure branch reported that the failure "is specific to
this build type, not a dependency on the interface this PR introduces". That
exclusion is not warranted.

Sanitizer-conditional compilation of gtest bodies is real in tree:
base/base/sanitizer_defs.h:29-35 defines THREAD_SANITIZER, and
src/QueryPipeline/tests/gtest_resize_transform.cpp:114 and
src/IO/tests/gtest_memory_resize.cpp:274 already compile a block only under a
subset of sanitizers. A #if defined(THREAD_SANITIZER) guard is therefore one
token away, so a PR adding an interface used only inside such a guard compiles
on the first arm and fails on the second with the error localized in the
overlaid test file, which compile_failure_attribution attributes. This branch
then fires and the old message is false.

What the earlier arm does establish is narrower: it compiled the same overlay,
so the failure is confined to what this build type compiles differently. That
may itself be a sanitizer-conditional part of the test depending on the fix's
interface. Either way the run concludes nothing, which is what the report now
says.

The status stays Result.Status.ERROR, so gating is unchanged:
new_tests_check.py blocks only on Result.Status.FAIL and treats ERROR as
inconclusive rather than as a refutation.

Also reword the escalation info string, which was a comma-spliced fragment
("..., not a refutation."), and drop two restated lines from the
BEFORE_BUILD_TYPES comment. The escalation precondition is stated at the loop
head, at the escalate branch and in the module docstring; the comment keeps the
two properties that are not obvious from the code, namely that one arm cannot
separate "the test does not catch the bug" from "this build cannot observe it",
and that amd_msan/amd_debug remain blind spots because every arm is a cold
build.

No control flow, status, Result name or gating changes.
…first build type

The module docstring and the first bullet of the step 4b comment both stated,
without qualification, that a compile failure attributed to the overlaid test
files is reported as XFAIL with nothing to validate. That holds only on the
first build type. On a later one an earlier arm already compiled the same
overlay, so the same attribution no longer isolates the test changes: only what
that build type compiles differently can be at fault, and the step is reported
as an ERROR (inconclusive) instead.

Both statements therefore described a behaviour the branch a few lines below
them does not implement. Scope each to the first build type and state the
later-arm outcome next to it.

Documentation only. No status, message, gating or control-flow line changes,
and the existing unit modules for this job pass unchanged.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Aug 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

Before opening this I ran an independent cold review of the diff plus a separate second-model
gate each round, then adjudicated every finding.

Four rows below were adjudicated by adding test arms under ci/tests/, which a later round
then deleted in full, per "We don't use ci/tests, they will be removed" (#115825) and #115650
"Remove ci/tests (attempt 2)". Their measurements stand as evidence about the change; none of
them is shipped coverage, and this PR adds no test case. That is stated on each affected row
rather than left to be inferred.

# Finding Verdict
❌ Nothing pinned that arm i is configured with build type i's flags: the arm that captures the cmake commands discarded them, so building ASan twice while reporting amd_tsan kept every test green AGREED. Arm written, asserting the two arms' -DSANITIZE= tokens differ and match their own build type, and mutation-proven; then removed with the ci/tests/ additions
❌ Nothing pinned that the build-directory reset actually deletes: the arm stubs Shell.check, so removing the rm -rf kept both assertions green AGREED. Arm written against a real tmp_path removal, mutation-proven; then removed with the ci/tests/ additions
❌ run_gtests calling set_sanitizer_symbolizer_options was untested: the helper's arms call it directly and every orchestration arm replaces run_gtests, so deleting the call kept every test green AGREED. Arm written, capturing TSAN_OPTIONS at child launch, mutation-proven; then removed with the ci/tests/ additions
❌ set_sanitizer_symbolizer_options had no test arms at all, although the escalation it enables is useless without it AGREED. Four arms written, one per branch, each mutation-proven; then removed with the ci/tests/ additions
⚠️ The module docstring still described a single before-build and named only Unit tests (asan_ubsan) as the PR-side proof AGREED, fixed
⚠️ Five new em-dashes in comments and report strings AGREED, fixed
⚠️ Related links were three shorthand references on one line, against AGENTS.md's "full GitHub URLs, one relationship per line" AGREED, fixed
⚠️ The docstring claimed the job runs in parallel with the build matrix and is not gated behind build_amd_asan_ubsan. Raised in two consecutive rounds: the first correction fixed one sentence and left an identical claim further down the same file AGREED, fixed at both sites. pull_request.py:139 orders this job after CORE_BLOCKING_JOB_NAMES, which includes every unittest_jobs entry; only the direct artifact dependency is absent, which is all the text claims now
⚠️ A later escalation arm that failed to compile still reported "the changed test code depends on the interface this PR introduces", an explanation the earlier arm had already disproved by compiling the same overlay AGREED, fixed: that case now reports ERROR (inconclusive), which this module's doctrine already prescribes. Gating is unchanged, new_tests_check.py blocks only on FAIL
⚠️ The replacement message then over-corrected, asserting the failure cannot be an interface dependency. base/base/sanitizer_defs.h defines THREAD_SANITIZER, and gtest_resize_transform.cpp:114 already compiles a block only under a sanitizer, so a PR-added interface used inside a TSan-only guard would compile on arm 1 and fail on arm 2 AGREED, fixed: the message now states that the failure is confined to what this build type compiles differently, which may include such a guard, and that nothing can be concluded either way. Status stays ERROR
⚠️ (r6) Third round on the same subject: the module docstring and the step-4b comment still promised XFAIL for any compile failure attributed to the overlaid tests, which is now true only on the first build type. The file therefore contradicted itself 15 lines apart AGREED, fixed. Both generic statements are scoped to the first build type and both name the later-arm ERROR. The arm-1-only XFAIL message was left alone, being reachable only there
⚠️ A clean escalating arm produced an OK row still named "must fail" AGREED, fixed. The expectation is carried by mark_reproduced and by the refutation path's info instead; {build_type} stays in the name because praktika derives the per-arm log filenames from it
💡 The escalation info string ended in an unanchored appositive ("...specific to another build type, not a refutation") AGREED, fixed: split into two sentences, same length
💡 One comment block ran to six lines AGREED, trimmed to four. The two properties it exists to explain are kept verbatim in substance: why a single arm cannot separate "the test does not catch the bug" from "this build cannot observe it", and why amd_msan/amd_debug stay blind spots
💡 Fail closed with ERROR when no llvm-symbolizer is found, instead of warning and running DISAGREED. The helper runs on every arm of every run, and 3457 of 3829 job rows in 90 days return a verdict at p50 3.7 min without ever emitting a sanitizer report. new_tests_check.py treats ERROR as non-blocking, so failing closed would disable the gate for the 14 genuine refutations it exists to block, to avoid at most one non-blocking timeout
💡 One [ RUN ] marker is treated as proof that every derived suite ran, so a PR touching both a gtest*.cpp and a standalone src/**/tests/*.cpp can be refuted on a partial measurement DISAGREED as out of scope, and the mechanism is real. It is byte-for-byte pre-existing, and this change cannot worsen it: a second arm is only reached when the first completed with every executed test passing, so the partial-coverage verdict is FAIL either way
💡 Comment edits in ci/defs/ for the same docstring reason DISAGREED. ci/defs/ staying untouched is what keeps digest and workflow regeneration out of scope, and it is a real difference from #96868, which changed job_configs.py and the generated pull_request.yml; job_configs.py already points at the module docstring, which is fixed

Also verified rather than assumed, since most of this diff is a 148-line re-indent: stripping
all leading whitespace from both revisions and diffing yields exactly the semantic edits, so
nothing changed inside the moved block. The merge gate reads only the job's status, so the
per-arm result renames cannot reach it, and they reach no CI DB row either, because the job
declares result_name_for_cidb="Tests" and has no sub-result by that name. A second arm cannot
inherit the first arm's gtest report: Result.from_gtest_run deletes the fixed report path
before every run, and a missing report maps to ERROR, which the job already treats as
inconclusive. The build-directory reset is not belt-and-braces: the two arms' cmake flags
differ by more than -DSANITIZE, so a cache entry the second configure does not re-specify
would survive.

The three surviving lines under ci/tests/ are signature adaptations only, without which nine
pre-existing cases raise TypeError and the live CI Tests job goes red.

One thing this does not address, noted for completeness: a reproduction that hangs rather than
failing arrives as a job timeout, i.e. inconclusive. Five job rows in 90 days ran 240.3-241.7
min that way. An earlier draft of this note said a hang always stops on the first arm; that is
too strong. A test that hangs only under TSan is newly reachable on the second arm, and the
240-min job timeout is its only bound, because run_gtests passes no command_launcher while
Unit tests (tsan) wraps the same binary in timeout -s INT -v 90m gdb. The verdict is
inconclusive rather than a false refutation either way, so this is a gap in reach, not in
correctness.

This is the sixth and final fix round the pipeline allows, so the tree is published as it
stands. The last second-model gate ran on the previous commit; the only commit after it is
documentation-only, and the executable content is token-identical (same token count, and the
sole differing tokens are the module docstring strings). Nothing below was held back as a
blocker.

This round I reviewed the diff once more cold, and reached three verdicts:

# Finding Verdict
💡 The escalation itself has no case under ci/tests/, unlike the 73 cases covering the pre-existing behaviour DISAGREED, on the same directive as the four rows above, plus AGENTS.md: "When you want to test changes in the CI scripts, you can write and run a throwaway test, but you don't need to commit it to the repository". Adding cases to a directory a maintainer is deleting is work against that direction
💡 run_gtests generalised its comment from "ASan+UBSan build" to "Sanitizer builds" while keeping the LSan justification for not wrapping in gdb. A -DSANITIZE=thread build links no LSan, so the stated reason does not cover the second arm AGREED on the fact, not fixed. It is a one-line comment, and the behaviour it describes is correct for both arms; the reach consequence is the timeout gap stated above
💡 __tsan_default_options compiles in halt_on_error=1 abort_on_error=1, so a pre-existing TSan race anywhere in the touched suite aborts the second arm and counts as a reproduction AGREED on the mechanism, not fixed. The ASan arm has the identical hole today, and it fails towards a green job rather than a false red: a genuinely broken test is still caught by the PR's own Unit tests (tsan) leg

@clickhouse-gh clickhouse-gh Bot added manual approve Manual approve required to run CI labels Aug 27, 2026
@clickhouse-gh clickhouse-gh Bot closed this Aug 27, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, both layers. The harness defect: Bugfix validation (unit tests) = FAIL / Touched unit tests on the before-binary (must fail): fail: 0, passed: 9 on #115659; reproduced locally by running the pre-fix ASan+UBSan before-binary through praktika's own runner, which returns OK with info fail: 0, passed: 9 (byte-identical to CI) and lands on the refutation branch. The underlying claim: the TSan before-binary aborts 5/5 runs in 8-9 s, rc=134.
b Root cause explained? BUILD_TYPE = BuildTypes.AMD_ASAN_UBSAN made the before-binary a single build type, so a regression gtest whose property is only observable under another sanitizer passes on it, main() reaches Result.Status.FAIL / Failed to reproduce the bug., and new_tests_check.py:220-227 turns that FAIL into a red Finish Workflow for a unit-only bugfix PR. The verdict is produced by a run that could not observe the property it judged.
c Fix matches root cause? The instrument is widened to the build type that can observe the property, rather than relaxing what a verdict means. The merge gate, new_tests_check.py, the verdict semantics and ci/defs/ are untouched; FAIL after the last arm still blocks, and a FAIL can only become a reproduction via a real reproduction.
d Test intent preserved / new tests added? No test cases are added. ci/tests/ is being removed: the review on #115825 states "We don't use ci/tests, they will be removed.", and #115650 (+9/-24715) deletes both that module and the runner that executes it. The only change under ci/tests/ is three stub signatures in test_unit_tests_bugfix_validation.py, needed because configure_before_binary and compile_before_binary now take a build type; without them 9 of that module's 97 existing cases raise TypeError and the live CI Tests job goes red on this PR (measured in both directions). With them the module is 97/97 and the sibling test_new_tests_check_unit_gate.py is 5/5, so no existing assertion is weakened. Correctness of the change was established by mutation during development instead: 14 mutants over three rounds, each reddening only the case written for it and never a pre-existing one, and the last three were first run against all 109 pre-existing cases and survived. That is what proves each claim was genuinely uncovered rather than redundant; those development cases are deliberately not in the diff.
e Both directions demonstrated? Without the change, the ASan arm's all-pass is the whole verdict and the job refutes (reproduced end to end locally, and in production on #115659). With the change, the same all-pass escalates and the TSan arm's abort is judged a reproduction: praktika returns FAIL with the crashed test recovered as Context.GetReadSettingsRace and the SUMMARY: ThreadSanitizer: data race line as info, so main() reaches its XFAIL branch.
f Fix is general across code paths? The loop wraps the whole configure/compile/run/judge sequence, so every verdict branch keeps its per-arm meaning. Both non-measuring branches (runner errored; no gtest [ RUN ] marker) deliberately do NOT escalate, since they are inconclusive on every build type and escalating would turn a documented ERROR into a possible FAIL. The functional/integration validators already carry this invariant and are untouched.
g Fix generalizes across inputs? The loop is driven by BEFORE_BUILD_TYPES and BUILD_TYPE_TO_CMAKE is indexed by the loop variable, so a third arm is a one-element change plus a timeout increase. Scope is stated narrowly in both the code and the description: ASan+UBSan and TSan only, with amd_msan and amd_debug still blind spots.
h Backward compatible? Yes. No setting, no serialization format, no SettingsChangesHistory entry, and no ci/defs/ change, so no digest change and no workflow regeneration. The only behaviour change is that a would-be FAIL can become a reproduction; nothing that blocks today starts passing without one.
i Invariants and contracts preserved? The invariant is that a did-not-reproduce verdict is a refutation only after every build type in BEFORE_BUILD_TYPES ran the touched tests with none failing. Carriers: the shared build directory is emptied fail-closed between build-type arms, because configuring a different SANITIZE over a surviving CMakeCache.txt would build one sanitizer and report another; every arm's Result name is unique, because praktika derives each log path from the name and a collision would silently overwrite the logs of the arm that started the escalation; peak disk is unchanged since at most one build tree exists at a time.

Session id: cron:clickhouse-review-slot-10:20260827-082400

@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a0816c5]

Summary: ✅


AI Review

Summary

This PR fixes the main false-refutation bug in Bugfix validation (unit tests) by escalating a clean amd_asan_ubsan arm into amd_tsan, and it adds better handling for skipped / compiled-out gtests. But two remaining paths still accept non-evidence as a validating outcome, so I would not approve the current head yet.

Findings

❌ Blockers

  • [ci/jobs/unit_tests_bugfix_validation_job.py:1224] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/116662#discussion_r3872303076] The new contract says only a build type that both compiled the overlaid tests and ran them gets a verdict, but the failure path still promotes any selected-suite failure into a reproduction as soon as one "[ RUN ]" marker exists. On the current head, changed_cases_unexercised can already prove that the changed file's cases were never registered or were skipped, yet that evidence is only consulted on the clean-pass path. A concrete trace with the existing src/Storages/tests/gtest_streaming_storage_registry.cpp file shows the problem: a report containing only failing StreamingStorageRegistryTest.SimpleRename while the guarded UnregisterNonExistentThrows / RenameNonExistentThrows cases are absent makes changed_cases_unexercised return True, but the branch at 1224 still marks the run reproduced. That lets a pre-existing TSan-only sibling failure validate a unit bugfix PR even when the changed regression case never ran.
    Suggested fix: before mark_reproduced, use the same case-level evidence as the refutation path. When gtest JSON exists, require the failing or crashed case to belong to the changed-file cases; when JSON is missing, at least use the recovered last "[ RUN ]" case from the log and fail closed to ERROR if you cannot tie the failure to a changed case.

⚠️ Majors

  • [ci/jobs/unit_tests_bugfix_validation_job.py:685] compile_failure_attribution still returns the first-basis success ("every compile error is inside the PR's changed test files") before it checks unreadable. On the current head, a compile log shaped as
    FAILED: <test edge> / clang++ ... -c before_src/.../changed_test.cpp / changed_test.cpp:...: error: ... / FAILED: <second edge with no command line>
    returns an attributed result and the caller converts the arm into XFAIL, even though the unreadable second edge could be the fix source or the link step. I reproduced that locally against the helper in this revision; it returns ("every compile error is inside the PR's changed test files (...)", [], "") for exactly that input.
    Suggested fix: if there is any extra unreadable FAILED: edge, fail closed to ERROR unless you can prove it is the same compile edge already explained by the overlaid diagnostic. In practice that means checking unreadable before the first-basis success.
Tests
  • ⚠️ The two branches above no longer have live regression coverage in-tree after ci/tests was removed. The smallest proof after a fix would be one focused local harness case for compile_failure_attribution with an extra unreadable FAILED: edge, and one for the mark_reproduced path where changed_cases_unexercised is True but the overall gtest result is FAIL.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  1. Do not count a failing sibling in the filtered suites as a reproduction when the changed regression case was skipped, compiled out, or otherwise cannot be identified as the failing case.
  2. Do not turn a compile failure into XFAIL while any additional unreadable FAILED: edge is still unexplained.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? Bugfix validation (unit tests) builds the merge-base "before" binary under amd_asan_ubsan only, so a regression gtest whose property needs a different sanitizer passes there either way, the job reports Failed to reproduce the bug., and new_tests_check.py turns that into a red Finish Workflow. This makes a clean arm escalate to an amd_tsan arm instead of refuting, so only the last build type reports FAIL.

…uting

Two ways an arm decided the job while having validated nothing.

A case that calls GTEST_SKIP() at runtime is reported by gtest as
"result": "SKIPPED" with "status": "RUN"
(contrib/googletest/googletest/src/gtest.cc:4741-4747), and
ResultTranslator.from_gtest maps only "status": "NOTRUN" to a skipped Result
(ci/praktika/result.py:1628), so the run arrives as OK with
"fail: 0, passed: N" and it does print the "[ RUN " marker that
before_run_started_a_test looks for. A regression case gated off under
sanitizers therefore reached the last arm as "all touched tests pass" and was
refuted with nothing executed. src/QueryPipeline/tests/gtest_resize_transform.cpp
is exactly that: one TEST, skipped under THREAD_SANITIZER, MEMORY_SANITIZER and
ADDRESS_SANITIZER, hence under both entries of BEFORE_BUILD_TYPES. Measured on a
gtest binary built from contrib/googletest: two GTEST_SKIP() cases give
translator status OK, sub-results OK, "fail: 0, passed: 2" and two "[ RUN "
markers, while a failing control gives FAIL. No refutation in the 60-day CIDB
record hit it yet (none of the 11 refuted PRs touched one of the 14 suites that
can skip on both arms), so this closes a reachable gap rather than a firing one.

The gtest filter selects whole suites, and a single test file can hold both a
conditionally skipped case and a runnable one
(src/Common/tests/gtest_ssl_send_timeout.cpp), so a sibling case completing says
nothing about the PR's own case. Cases are therefore attributed to the changed
files: gtest records each case's "file", which -ffile-prefix-map
(CMakeLists.txt:324) reduces to the source-relative path that test_files already
uses, and ANY case of a changed file that reports SKIPPED or SUPPRESSED costs the
arm its verdict, since which case is the regression one is not known here. Both
values matter: a disabled case comes back as SUPPRESSED/NOTRUN, measured on a
gtest binary from contrib/googletest, and one in-tree file mixes disabled and
runnable cases (src/Storages/MergeTree/UniqueKey/tests/gtest_unique_key_encoding.cpp). With no case matchable the
rule falls back to "every selected case skipped", so a matching miss preserves
the previous behaviour. Demanding instead that every case of the whole suite
completed would leave 14 in-tree suites permanently un-refutable, among them
CoordinationChangelogTest with a conditional skip in 32 of its 34 cases, and none
of the 11 refutations in the CIDB window touched a file carrying a skip.

An attributed compile failure on the first build type also returned XFAIL
("nothing to validate") before the second one was configured, on 30 runs across
17 PRs in the same window. What a test compiles is build-type-dependent too, so
a sanitizer-conditional part of it can reference the fix's interface on one build
type while the other compiles and reproduces the bug at runtime. The later-arm
branch now keys off whether an arm actually compiled the overlay rather than off
the arm index.

An arm that produced no verdict escalates and is remembered; the last build type
refutes only when every one of them exercised the changed cases and they passed,
reports XFAIL when none compiled the overlay, and is inconclusive otherwise.
Driving main() of both revisions over ten scenarios, with the gtest reports taken
from real googletest json: skip-only on both arms FAIL -> ERROR, changed case
skipped while a sibling case ran FAIL -> ERROR, first-arm no-compile with a
reproducing second arm XFAIL-with-zero-runs -> "Bug reproduced", first-arm
no-compile with a passing second arm XFAIL -> ERROR. The genuine refutation, the
arm-1 reproduction, the no-arm-compiles XFAIL, the skip-then-reproduce case, the
unmatched-file fallback and the control where the changed file's case did run are
all unchanged, so new_tests_check.py keeps blocking on failed-to-reproduce alone.
The cost is one extra configure+compile when no build type compiles the overlay.

The compile stub in test_unit_tests_bugfix_validation.py returned one shared
Result for every arm, so the relabelling of the arm being escalated from leaked
into the next arm and read as a compile success. It builds a fresh Result per
arm now, as the production compile does.
…egistered

A case declared behind a preprocessor guard is never registered with gtest, so it
is absent from the report rather than reported as not run.
changed_cases_unexercised looked only for cases reporting SKIPPED or SUPPRESSED,
and it attributes cases to the changed files by each case's "file", so a sibling
case of the same file kept the attribution non-empty and the last build type
still refuted the PR with the regression case never built.
src/Storages/tests/gtest_streaming_storage_registry.cpp is that shape: two of its
seven cases sit behind #ifndef DEBUG_OR_SANITIZER_BUILD, while SimpleRename in
the same file is always present. Of 519 in-tree unit-test sources, 89 declare a
case inside a preprocessor guard, and six lose part of their cases to a
sanitizer-named guard while keeping the rest (five unconditionally, one inside
#if USE_AVRO).

Each changed file's declared cases are now matched against the report, and a
declaration that never appears counts as no verdict, exactly like SKIPPED or
SUPPRESSED. The filter covers every suite those files declare, so a registered
case is always reported and an absent one is positive evidence rather than a gap
in the run. Declarations come from the overlaid PR-head file under
ci/tmp/before_src, not from the primary checkout: that checkout is the synthetic
base+PR merge ref determine_merge_base documents, so a case the base added to a
file the PR also touches would read as unregistered and would turn a genuine
refutation into a non-blocking ERROR. Matching covers every naming form
build_gtest_filter documents plus Suite.Case/0, which is what an
INSTANTIATE_TEST_SUITE_P with an empty prefix reports (gtest-param-util.h:567
clears the suite name instead of prefixing it, and the typed macro static_asserts
a non-empty prefix, so it has no such form).

A clean run that registered no case at all was reported as "the touched suite is
not compiled into unit_tests_dbms" and ended the job on the first build type.
That is right for a translation unit grep_gtest_sources does not glob, whose cases
are in no build type's binary, and wrong for anything that can reach the binary:
zero cases from a gtest*.cpp mean its cases were compiled out on that build type
alone, which is the whole-file guard shape of src/Common/tests/gtest_lsan.cpp and
of three more in-tree files, and a header has no translation unit of its own and
reaches the binary through whichever gtest*.cpp includes it, the arrangement gtest
documents for TYPED_TEST_SUITE_P. The immediate report is therefore kept only when
nothing among the changed files that can reach the binary declares a case, and
otherwise the declaration check leaves the arm without a verdict so the build types
left can still register those cases and fail on them. Exactly one in-tree file is
in the first group, src/Databases/DataLake/tests/test_hive_catalog_url_parsing.cpp,
which the comment there already names, so almost nothing pays a second cold build
for a suite no build type can run.

Driving main() of the previous revision and of this one over the same eighteen
scenarios, with every gtest report taken from real googletest json paired with a
source declaring exactly those cases, four move and all of them away from a
verdict nothing measured: the guarded case with a running sibling goes FAIL to
ERROR, a gtest*.cpp guarded out on the first arm and reproducing on the second
goes from inconclusive-after-one-build to "Bug reproduced" after two, the same
through a header does too, and one guarded out on both arms stops claiming it is
not compiled in. The other fourteen are identical, among them the genuine
refutation, the standalone translation unit still deciding on the first build
type, a changed header declaring no case, the changed file's own case having run,
a file whose typed and parameterized cases are all present, and the empty-prefix
TEST_P form. new_tests_check.py keeps blocking on failed-to-reproduce alone.

The two compile-failure test helpers reach a second arm after the previous commit
and were running the production build-directory reset; both stub it now.
results.append(compile_result)
arms_without_a_verdict.append(f"{build_type} (overlay does not compile)")
continue
if attributed_to:

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.

compile_failure_attribution still fails open on a truncated log that contains an extra FAILED: edge after an overlaid-test diagnostic. On this revision, the following log shape returns ("every compile error is inside the PR's changed test files (...)", [], "") here, so main() reports XFAIL:

FAILED: src/CMakeFiles/x.dir/gtest_wb.cpp.o
/usr/local/bin/clang++ ... -c /ClickHouse/ci/tmp/before_src/src/Disks/tests/gtest_write_buffer_inline_or_blob.cpp
/ClickHouse/ci/tmp/before_src/src/Disks/tests/gtest_write_buffer_inline_or_blob.cpp:56:21: error: too many arguments to function call
FAILED: src/CMakeFiles/y.dir/WriteBufferInlineOrBlob.cpp.o

The second edge could still be the fix source or the link step; we only lost the command line. Treating overlaid_errors as sufficient before checking unreadable turns that inconclusive build into a green "nothing to validate". I think any additional unreadable edge has to keep this ERROR unless you can prove it is the same overlaid compile edge the diagnostic already covered.

return
# At least one touched test failed or crashed on the before-binary — the bug is
# reproduced. Flip the expected failure to a success for the report.
mark_reproduced(before_result)

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 branch still counts any failing sibling in the selected suites as a reproduction, even when the changed case never ran on that build type. changed_cases_unexercised is only consulted on the clean-pass path below, so a report that fails only StreamingStorageRegistryTest.SimpleRename still reaches mark_reproduced even though the same changed file declares UnregisterNonExistentThrows / RenameNonExistentThrows behind #ifndef DEBUG_OR_SANITIZER_BUILD and they may never have registered on the sanitizer arm.

That violates the new contract from the module docstring ("only a build type that both compiled the overlaid tests and ran them has a verdict"). With BEFORE_BUILD_TYPES now reaching amd_tsan, any pre-existing TSan-only failure in the same suite can newly satisfy this branch and falsely validate a unit-only bugfix PR. Can we gate mark_reproduced on the same case-level evidence as the refutation path, at least when a gtest report or recovered last [ RUN ] case is available?

Master removed the whole `ci/tests` directory in `5b3d66b1a66` ("Remove ci/tests
(attempt 2)", 51 files, no replacement location), so this branch's edits under
`ci/tests` arrive as modify/delete conflicts. Accepted the removal, and dropped
the files this branch adds there as well - keeping them would re-create a
directory master deliberately deleted.

The product change this pull request is about is unaffected; what is lost is its
CI-side unit coverage, which has nowhere to live upstream any more.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@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 self-assigned this Sep 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 20, 2026
Merged via the queue into ClickHouse:master with commit cbc807e Sep 20, 2026
175 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 20, 2026
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-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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