Skip to content

Do not let artifact-collection rows discard a bugfix-validation verdict - #114400

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:ci-bugfix-validation-artifact-rows-do-not-vote
Aug 13, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:ci-bugfix-validation-artifact-rows-do-not-vote

Conversation

@groeneai

@groeneai groeneai commented Aug 12, 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):

...

Description

@ nikitamikhaylov asked me to investigate why Bugfix validation fails on #113397 and
suggest improvements (comment).
This fixes the harness defect I found while answering that. Related: #113397, @ tiandiwonder's
PR, which this one does not close.

There, both functional bugfix-validation jobs report FAIL even though the bug reproduced on
both arches: the regression-test row is OK, and the only FAIL row is Scraping system tables.

An ordering defect. invert_bugfix_validation_status decides the verdict, then the
COLLECT_LOGS stage appended artifact-collection rows with a bare extend_sub_results, which
re-derives the parent status from its children (praktika/result.py), so one failed
system-table dump overwrote the verdict with FAIL. new_tests_check.py reads that status
with strict is_success, so any_bugfix_validation_passed found no validating arch and
blocked the PR with "No per-arch Bugfix Validation job validated the bug". Those rows come
from prepare_logs, after the verdict, so they can never be part of it.

The fix attaches them through a helper that restores the captured status on a labelled
bugfix-validation job. The rows stay visible in the report, they just stop voting.
Restoring the captured status rather than forcing OK keeps all three verdicts:
reproduction OK, no-repro SKIPPED, inconclusive ERROR. An ordinary job still reddens.

The defect reproduces in-process, and six new cases in
ci/tests/test_bugfix_validation_inverter.py pin an ordering that had no coverage. Each was
checked against a mutated fix so its redness is attributable: dropping the restore fails
the three verdict cases, restoring the bare call fails the AST case, and applying the
restore unconditionally fails the ordinary-job control. One records why the rows must not
be labelled LOG_CHECK instead, which would count a broken dump as a reproduction.

Only the ordering is fixed here. The dump itself failed because a graceful-stop timeout left
the server holding its status-file lock, which is separate.

Version info

  • Merged into: 26.8.1.1299 (included in 26.8 and later)

A per-arch Bugfix Validation job could report FAIL, and so block the PR as
unvalidated, on a run where the bug did reproduce.

invert_bugfix_validation_status decides the verdict, then the COLLECT_LOGS
stage appended ClickHouseProc.extra_tests_results with a bare
extend_sub_results. That call re-derives the parent status from its children
(Result._update_status), so a single FAIL artifact row overwrote the verdict.
The gate in new_tests_check.py reads the job status with strict is_success, so
any_bugfix_validation_passed then found no validating arch and refused the
merge with "No per-arch Bugfix Validation job validated the bug". Those rows
are produced inside prepare_logs, after the run is over, so they can never be
part of the verdict.

Seen on ClickHouse#113397: the PR's own bug hung DROP TABLE ... SYNC, the graceful stop
timed out, the still-running server kept its status file locked and every
clickhouse local system-table dump failed with CANNOT_OPEN_FILE. Both arches
reported Failed: 1, Passed: 0 while their regression test row was OK. The more
convincingly such a bug reproduces, the likelier the job discarded its own
result.

Attach those rows through attach_post_verdict_artifacts, which restores the
captured status on a labelled bugfix-validation job. The rows stay visible in
the report, they just stop voting. The captured status is restored rather than
forced to OK so that every verdict the inverter can set survives: reproduction
OK, no-repro SKIPPED, inconclusive ERROR. Scoping the restore to
is_labeled_bugfix_validation, the same guard the inverter uses, leaves ordinary
functional jobs reddening on a failed dump, which is real signal.

Labelling the row LOG_CHECK or moving the append before the inverter was
rejected: extra_tests_results is empty at that point, and a FAIL row reaching
the inverter is flipped to OK and counted as a reproduction, so a broken log
dump would become evidence that the bug was validated. A test records this.

Only the ordering is fixed here. The graceful-stop timeout that left the lock
held is a separate problem.

Related: ClickHouse#113397
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (5 findings, all adjudicated, no blockers)

Independent cold review of the resulting code plus a second-model pass, adjudicated before
publishing. No source change was requested by either.

# Sev Finding Verdict
1 ⚠️ major The draft description cited Failed: 1, Passed: 0 as the symptom. That string is set in FTResultsProcessor.run (functional_tests_results.py:328) from the raw runner counts, before the inversion and before the artifact append, so a correct single-test reproduction produces it too. Over 30d of CIDB it appears on 2161 of 4843 SUCCESS runs and on 14 of 14 failure runs, so it does not discriminate. AGREE, fixed before publishing. The description now cites the job status and the child-row split, which is the actual discriminator: regression-test row OK, sole FAIL row Scraping system tables.
2 💡 nit The commit message repeats the same figure. AGREE. Not blocking: it is stated there as co-occurring observed state next to the OK test row, not as proof. Left as is rather than rewriting gated history for a nit.
3 💡 nit 14-line docstring on a 4-line helper, mentioning new_tests_check.py's strict is_success. AGREE. Not blocking: comments do not outnumber added code (11 vs 12), and the two functions bracketing it carry docstrings of the same shape, so trimming this one alone would be inconsistent.
4 💡 nit The AST pin matches the literal extra_tests_results in positional-arg source text, so binding the list to a local first would evade it. AGREE. Not blocking: the same accepted trade the neighbouring GATE_EXPR string pin documents in test_collect_core_dumps.py. It still pins the call site against the exact pre-fix form.
5 💡 nit The module docstring, the section banner and one test docstring each restate the ordering mechanism. AGREE. Not blocking: partial overlap only (the banner adds the observed instance, the docstring covers the refuted alternative), and the file already used this form before this change, including a section banner citing #110158.

Verified independently while reviewing, not taken on trust:

  • The full chain: verdict set at invert_bugfix_validation_status, then
    extend_sub_results -> _update_status sets FAIL on any failing child, then the gate
    reads the job status with strict is_success and refuses the merge.
  • The rows provably cannot belong to the verdict: extra_tests_results is appended only in
    dump_system_tables, reachable only from prepare_logs, whose only functional caller is
    the COLLECT_LOGS stage. This is also why moving the append before the inverter is inert.
  • Nine invariant carriers, enumerated independently first: the CHECK_ERRORS append runs
    before the inverter and is already covered by the LOG_CHECK exclusion; the
    integration-test validator has no append after its own inversion; the unit validator uses
    a different gate; fast_test.py and clickbench.py never read those rows; DIAGNOSTICS
    is not in stages for this job; failures_cnt is already unconditionally overridden. No
    divergence from the plan.
  • Test liveness traced case by case: reverting the production hunk fails four of the six new
    cases, and the ordinary-job case is a control that genuinely reddens when the restore is
    applied unconditionally.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, in-process, 100%: invert_bugfix_validation_status on a reproduced result gives OK, and a bare extend_sub_results([Result("Scraping system tables", FAIL)]) turns it into FAIL. Same for the SKIPPED and ERROR arms. No randomization, no server, no build.
b Root cause explained? The inverter sets the verdict, then the COLLECT_LOGS stage appended artifact rows with a bare extend_sub_results, whose _update_status re-derives the parent from its children, so any FAIL child forces FAIL. new_tests_check.py reads that with strict is_success, so any_bugfix_validation_passed saw no validating arch and blocked the PR. The rows come from prepare_logs, after the verdict.
c Fix matches root cause? Yes: the restore is at the recomputation that overwrites the verdict, in the consumer that owns the ordering. No row is hidden, no failure suppressed, nothing widened.
d Test intent preserved / new tests added? 6 new cases in ci/tests/test_bugfix_validation_inverter.py, which had 15 cases and zero references to this ordering. The 15 existing cases are unchanged and green.
e Both directions demonstrated? Yes. Job-level: reproduction goes FAIL/not-validated without the fix, OK/validated with it; SKIPPED and ERROR arms unchanged. Each new case was also run against a mutated fix so its redness is attributable: dropping the restore fails the 3 verdict cases, restoring the bare call fails the AST case, applying the restore unconditionally fails the ordinary-job control.
f Fix is general across code paths? 9 carriers checked. The CHECK_ERRORS append runs before the inverter, so its rows already pass the LOG_CHECK exclusion (left untouched). integration_test_job.py has no appends after its inversion (grep-verified). The unit-test bugfix job uses a different gate with allow_failure=True. fast_test.py and clickbench.py call prepare_logs but never consume extra_tests_results. The fix pins the consumer, so a future producer (core dumps, jemalloc profiles) is covered without further edits.
g Fix generalizes across inputs? The input space is the verdict state and the label, not datatypes. All three verdicts asserted (OK / SKIPPED / ERROR), both preserve_verdict values, and the LOG_CHECK-vs-plain distinction for a FAIL row. failures_cnt still counts the artifact row, which only makes that path more permissive.
h Backward compatible? Nothing user-visible: no settings, no serialization, no SettingsChangesHistory.cpp. A non-bugfix job is byte-identical, which the negative control proves is genuinely scoped.
i Invariants and contracts preserved? The invariant is that a post-verdict artifact row must not change a bugfix-validation verdict. extend_sub_results keeps its own contract (still called, still recomputes; the caller restores after). The helper has a single path, no early return. The rows stay in test_result.results, so the report tree and CIDB still see them. sort() only reorders and create_from reads the restored status, so neither re-clobbers it.

Session id: cron:clickhouse-impl-slot-4:20260811-224900

@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c21d76e]

Summary: ✅


AI Review

Summary

This PR fixes the bugfix-validation status flow in ci/jobs/functional_tests.py: post-run artifact rows from COLLECT_LOGS no longer get to overwrite a verdict that invert_bugfix_validation_status has already decided. The change is scoped to the extra_tests_results append path, keeps ordinary functional jobs reddening on real artifact-collection failures, and adds focused coverage for the helper plus the call-site ordering. I did not find a correctness or contract issue in the current patch.

Missing context / blind spots
  • ⚠️ I could not rerun the focused Python tests locally because python3 -m pytest failed in this environment with No module named pytest. The PR's Praktika report is all-green, including CI Tests and the bugfix-validation jobs, which partially closes that gap.
Final Verdict

✅ No blocking findings.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus @maxknv, could you review this? The bugfix-validation inverter sets the per-arch verdict, then the COLLECT_LOGS stage appended the system-table-dump rows with a bare extend_sub_results, which re-derives the parent status from its children, so one failed dump overwrote an OK verdict and new_tests_check blocked the PR as unvalidated.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - c21d76e

Every failure below has an owner: a fixing PR (ours 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
Build (arm_release) / Post Hooks infra: build_profile_hook.py fails closed when the build-profile telemetry INSERT into the shared CI logs cluster is rejected (LogCluster query failed with code 500, 8 retries exhausted). Not gating - the Build (arm_release) check-run itself is green, only this CIDB row is red. a fix task is moved to pending (investigating at full effort - fixing PR link to follow on this PR)
Config Workflow / Pre Hooks superseded: can_be_tested: 'can be tested' label is required at 00:03:36Z, before the label was applied. The re-run at 00:04:47Z is green, and this head's Config Workflow check-run concluded success. not a live failure at this head
Sync - CH Inc sync (private, not actionable)

No test-level failure on this head: 176 check-runs, 0 queued or in progress, 32 success and 144
skipped, praktika top-level OK with 0 dropped jobs. The high skip count is legitimate and
self-describing - every skip carries a reason (Not affected by the changed files and not required
x66, only CI scripts changed; running amd_asan_ubsan integration ... x32, only CI scripts changed; running stateless batch 1 ... x25, not labeled with 'pr-performance' x6, no tests to run x4, reused from cache x3), which is expected for a ci/-only diff.

Gates: (a) 0 incomplete non-exempt checks; (b) Finish Workflow and Config Workflow both
success; (c) last completion 05:58:54Z, >20 min buffer; (d) every line above has an owner.

Session id: cron:our-pr-ci-monitor:20260812-063000

@alexey-milovidov alexey-milovidov self-assigned this Aug 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 13, 2026
Merged via the queue into ClickHouse:master with commit 2790ac4 Aug 13, 2026
528 of 532 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 Aug 13, 2026
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 2026
pull Bot pushed a commit to Spencerx/ClickHouse that referenced this pull request Sep 20, 2026
`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`.
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 groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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