Skip to content

Publish a failing job step's cause to CIDB, not just the failure count - #115526

Merged
alexey-milovidov merged 15 commits into
ClickHouse:masterfrom
groeneai:cidb-publish-failing-step-cause
Sep 21, 2026
Merged

alexey-milovidov merged 15 commits into
ClickHouse:masterfrom
groeneai:cidb-publish-failing-step-cause

Conversation

@groeneai

@groeneai groeneai commented Aug 20, 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

When a job dies in a step outside the node named by result_name_for_cidb (Install ClickHouse,
Start ClickHouse Server), the job's own info is just Failures: N/M, so the cause reaches no CIDB
row, report page or issue body and survives only in job.log. 152 failing master job instances land
in this shape over 30d; at b03544a19bc the failing Start ClickHouse Server node carried 301 lines
and CIDB got 13 bytes (report).

Asked for on this thread by @ maxknv ("in result.py ... generate a line of failed step and trim the
line if too long",
comment) and by
@ alexey-milovidov, who approved it and pushed 2d058e2e200f and 2dc83d2d117e here himself. The
consumer is master-CI triage off CIDB, where those 152 instances show no cause.

_add_job_summary_to_info now names each failing direct child after the count line, which stays
first and unchanged so queries against it keep matching. Doing it here rather than in cidb.py lifts
every surface that renders a job summary, per review.

Two measured bounds. from_commands_run puts the cause near the front in one branch and at the tail
in the other, so the trim keeps both ends, anchored on the first : error: or : warning:. A job
whose children are test cases already publishes a row per case, so naming all of them grew this row
with the failure count (40 cases gave 120 KB); at most the first few are named.

Not addressed (predates this change): a job whose info is already non-empty when the summary runs, so
a later Collect logs failure still publishes no cause. Keeper Stress naming a
result_name_for_cidb no child carries is likewise unchanged.

Validation: both payload branches, both trim directions, both anchors, the per-shape bound and the
real publisher path, on both sides of the change; the pinning test was deleted in 7428aec.


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

Version info

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

groeneai and others added 4 commits August 19, 2026 17:53
When a praktika job dies in a result node that is not the one named by
result_name_for_cidb, CIDB receives one row whose entire test_context_raw is
"Failures: N/M" and zero test rows. json_data_generator emits the job row with
test_context_raw = result.info, plus one row per child of the single node
_get_sub_result_with_test_cases matches by exact name, so a failing sibling of
that node is visited by neither loop and its info is dropped during row
generation. The job row does not compensate, because result.info there is the
count-only fallback Result._add_job_summary_to_info writes while info is empty.

The cause is then readable only from job.log, so no test-name-keyed and no
signature-keyed CIDB query can see this class of failure, including anti-join
scans that require test_name != ''. Every Stateless job sets
result_name_for_cidb="Tests" while Install ClickHouse, Start ClickHouse Server,
Collect coverage and Collect logs are its siblings. 30d on public CIDB: 22
master jobs, 498 jobs total, 39 distinct checks. On master commit
b03544a the failing Start ClickHouse Server
node carried 301 lines while CIDB got 13 bytes.

Append "<name>: <info>" for each failing direct child that reaches no other
row, after the existing text so the old value stays a strict prefix. Child rows
are deliberately unchanged: a test_name='Install ClickHouse' row would enter
per-test statistics and every flaky-rate aggregation. Direct children only,
because Result.results has no cardinality bound. No second truncation, because
Result.from_commands_run already caps each payload at 300 lines.

Skip a child whose info is already contained in the job's own text. Two real
routes need this: ci/jobs/fast_test.py copies the Tests node's info onto the
root without clearing it while the named node is never in its own published
set, and Result.create_from(with_info_from_results=True) already lifts child
info in this same "<name>: <info>" shape under a result_name_for_cidb that
matches no child. Without the check the summary is duplicated on every ordinary
Fast test failure.

Not addressed here: Keeper Stress names a result_name_for_cidb no child
carries, so its cases reach no row and their parent's own info is empty. That
is a different root cause in different files, and this change is a verified
no-op there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Two coverage gaps in the tests added by the previous commit. Each survived a
mutation of ci/praktika/cidb.py that left all 13 arms green, so a later refactor
could have narrowed the behaviour without CI noticing. No behaviour change: the
generator already handles both shapes correctly, only the tests were missing.

Narrowing the collector's predicate from not r.is_ok() to r.is_failure() was
silent, because every positive arm used FAIL while is_ok() is {OK, SKIPPED,
XFAIL} and is_failure() is {FAIL, XPASS}, so only ERROR distinguishes them.
ci/jobs/performance_tests.py appends a direct Download datasets child with
status=ERROR and populated info under result_name_for_cidb="Tests", so the ERROR
half is the production shape, not a hypothetical. Parametrize the primary arm
over FAIL and ERROR rather than duplicating the fixture; the count fallback in
Result._add_job_summary_to_info uses the same predicate, so the job summary is
Failures: 1/3 for both.

Adding the selected node's own id to published_ids was also silent. The node
_get_sub_result_with_test_cases returns is never in its own published set, since
that set holds its children, and this asymmetry is what makes the node's own
info reach a row at all. Both existing arms that give it a non-empty info also
copy that text onto the root, so the containment clause suppressed the append
and the published_ids clause was never exercised on the container. The new arm
gives the root a different string, as ci/jobs/performance_tests.py does when it
builds Tests through Result.from_commands_run while the root carries the report
message, and asserts the whole context by equality so ordering and the prefix
property are pinned too.

Both mutations now fail exactly one arm each, the five byte-identity negative
controls and the two duplication guards stay green under all five mutations, and
the arm count rises from 13 to 15 pytest items.

Also state the empty-info arm's docstring as the invariant it checks instead of
attributing a status and a field to a node that has neither.

Co-Authored-By: Claude Opus 5 <[email protected]>
The large-payload arm asserted that a big diagnostic is appended verbatim, but
its fixture was 300 lines and 2945 chars while a real master payload is 301
lines and ~26 KB. Result.from_commands_run truncates to a leading marker plus
the last 300 lines, so 301 is the ceiling, and the cause sits in the tail.

A line clip at 300 and a byte clip at 4 KiB both left the suite green. The
fixture now matches production on both axes and the arm asserts the line count
and the byte size explicitly, so either clip reddens it.
The large-payload arm covered only the default truncation branch of
Result.from_commands_run, which emits a marker plus the last 300 lines. Its
error-centered branch wraps 300 retained lines in both a leading and a
trailing marker, so it can emit 302 lines and the cause need not be last. A
301-line clip of the appended diagnostic therefore left the whole suite green,
leaving the verbatim-append contract unpinned exactly at its real boundary.

Parametrize the arm over both real shapes, each asserting its own line count,
and add a fixture built the way the error-centered branch builds its output. A
sweep of every error index over log lengths 301 to 5000 confirms 302 is the
ceiling, so this pins the boundary rather than another sample value. The tail
assertion becomes a containment check because the trailing truncation marker,
not the cause, is last in that shape; exact equality still pins every byte.

No change to ci/praktika/cidb.py.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Aug 20, 2026
@groeneai

groeneai commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: 3 majors agreed and fixed over 3 rounds, final round clean

Four independent cold reviewer sessions plus four automated review passes ran against this diff
before it was opened. Three rounds each raised one blocking finding, fixed in its own commit; the
fourth found none. Every verdict below is backed by a measurement, not an opinion. All three
blockers were test-liveness gaps found by mutating the source and observing that the suite stayed
green - the source behaviour was correct in each case, but unpinned.

❌ Agreed and fixed

1. The ERROR half of the predicate was unpinned. Replacing not r.is_ok() with
is_failure() left the whole suite green. Reachable in production: ci/jobs/performance_tests.py
appends a direct root child Download datasets with status=ERROR and populated info, in a job
whose result_name_for_cidb is Tests. is_ok() is {OK, SKIPPED, XFAIL} and is_failure() is
{FAIL, XPASS}, so ERROR falls between them. Fixed by parametrizing the primary arm over
[FAIL, ERROR]; the swap now fails exactly the ERROR case.

2. The published-row-set clause was unpinned. Adding the selected node to its own published set
left the suite green. That the selected node is never in its own set is the load-bearing asymmetry
of the design - CIDB publishes its children - and Result.from_commands_run fills a failing
node's own info (with_info_on_failure defaults true), so a failing Tests node's command log
would reach no row at all. Fixed with an arm asserting that node's own info is named, on a root
info that containment cannot suppress; the mutation now fails exactly that arm.

3. The large-payload arm could not detect truncation. Its fixture was 300 lines / 2.9 KB, while
Result.from_commands_run emits 301 lines on its default branch and 302 on its error-centered
branch, at ~26 KB - re-derived by sweeping every error index over log lengths 301 to 5000, and
confirmed against real master payloads. Clipping the appended text to 300 lines, to 301 lines, or
to 4 KiB (modelled on the existing [: 32 * 1024] guard on this same column) all stayed green,
while a control mutation reverting the fix reddened 8 arms, so the probes were live. Fixed by
making both real shapes fixtures at their measured line counts and sizes, each pinning its own line
count and byte size; all three clips now redden. The error-centered fixture was verified
line-by-line against the branch's actual output rather than written to the prescription, which was
itself off by one.

Each of the three predicate clauses, and the absence of a cap, is now covered by a mutation that
fails only its own arms. The five byte-identity negative controls and two duplication guards stay
green under all eight mutations.

💡 Noted, not blocking

The if result.info guard in the final join is not covered: deleting it leaves the suite green. It
is unreachable rather than untested - every job that sets result_name_for_cidb calls
complete_job with the job summary enabled, so the job info is never empty at insert time, and
when result_name_for_cidb is empty the early return fires before the join. Kept as defensive code
rather than pinned against a shape production cannot produce.

A 30-day census total moves with the window (497 to 505 across six independent measurements). The
description quotes only the two digits stable across all six.

Verified beyond the fixtures

Re-checked at source level and against real master report JSON: the hoisted selector call is pure
and still evaluated exactly once; identity keying is sound because Result is an unhashable
dataclass and every keyed object outlives the generator; the old value is always a strict prefix,
so no existing query on this column regresses; row count, row order, the test_name set and every
child row's context are unchanged; result_name_for_cidb="" is a strict no-op. The appended set
equals the is_ok() complement for all ten Result.Status values, and the row's Failures: N/M
count agrees with the steps it names in all ten, so the count and the identity cannot contradict
each other. Size introduces no new class: the column already holds 15 KB at p99.99 and 12.6 MB at
max over 853M rows in the last 7 days. All eight result_name_for_cidb configurations and their
job scripts, the single production call site, the other insert paths, the with_info_from_results
users and every in-repo consumer of this column and of the Failures: N/M text were enumerated
independently in each round.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. python3 -m pytest ci/tests/test_cidb_job_row_carries_step_failure.py (pure Python, fixed fixtures, no clock, no network, no build) - 16 items green, and 800/800 over 50 repeats. Pre-fix signature: the failing step's payload is absent from rows[0]["test_context_raw"]. Field side: 22 master jobs across 39 checks in 30d.
b Root cause explained? Yes. json_data_generator emits rows from two disjoint loops, both keyed on the single exact-name child match of _get_sub_result_with_test_cases, so a failing sibling of that node is visited by neither and its info is dropped during row generation. The job row does not compensate: Result._add_job_summary_to_info writes the count-only Failures: N/M, and only while info is empty.
c Fix matches root cause? Yes, applied at the row-generation site where the drop happens. Two alternatives rejected on measurement: fixing _add_job_summary_to_info never fires once functional_tests.py has lifted Tests text into the job info, and would also change job.log, the GitHub issue bodies and the report page (all correct today); emitting the step as an extra child row would put test_name='Install ClickHouse' into per-test statistics and every flaky-rate aggregation.
d Test intent preserved / new tests added? Yes. No existing test modified or weakened. 13 new logical arms (16 pytest items), of which 5 are byte-identity negative controls and 2 are duplication regression guards. Eight mutation checks prove no arm is vacuous.
e Both directions demonstrated? Yes, and per clause. With the fix: 16 passed. Source hunk reverted, tests kept: 8 failed / 8 passed, the 8 that pass being the controls and guards that assert unchanged behaviour by construction. Each predicate clause deleted in isolation fails only its own arms: containment -> the 2 duplication guards; the published-row set -> the empty-result_name_for_cidb control; not is_ok() -> the ERROR case. Clipping the appended text to 300 lines, to 301 lines, or to 4 KiB each redden as well, so the absence of a second cap is a tested fact rather than an assumption.
f Fix is general across code paths? Yes. All eight jobs that set result_name_for_cidb go through this one function, so all are covered by the same lines with no per-job change. Siblings checked and untouched: insert_storage_usage, insert_compute_usage and Revert CI regressions build their own TableRecord and never call json_data_generator; the runner.py CIDB label loop reads get_sub_result_by_name independently of the base row; the legacy tests/ci/clickhouse_helper.py writer is a separate path. The predicate is not r.is_ok(), the same one _add_job_summary_to_info uses to count failures, so the row's count and its named steps agree by construction rather than coincidence - verified for all 10 Result.Status values (OK, SKIPPED, XFAIL never appended; the other 7 always).
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. Arms cover empty result.info (the Failures: N/M path) and non-empty (the lifted 3 tests failed path); zero, one and two failing steps; both truncation shapes Result.from_commands_run can really emit - its default branch at 301 lines / 26 KB with the cause last, and its error-centered branch at 302 lines / 26 KB with the cause mid-payload - each pinned on its own line count and byte size; a failing step with empty info; a SKIPPED step that has info; a failing test inside the published node; the published node's own info; result_name_for_cidb=""; a name matching no child; a nested failing leaf. result.info is typed str = "" and every writer joins into a str, so the containment test cannot see None.
h Backward compatible? (maintainer-approved exception only) Yes. The old result.info is always a strict prefix of the new value (pinned in both info shapes), so no test_context_raw query regresses on text it used to match. Row count, row order and the test_name set are unchanged, and every child row's context is untouched. grep -rn "Failures: " ci/ --include=*.py finds only writers plus test_integration_rabbitmq_recreation_report.py, which tests in result.info and is green. No ClickHouse setting, no serialization format, no user-visible behaviour, so no SettingsChangesHistory.cpp entry. One intended consequence: an anchored match('^Failures: [0-9]+/[0-9]+$') census stops matching fixed jobs; the test_rows = 0 anti-join arm still works.
i Invariants and contracts preserved? Yes. json_data_generator stays a generator yielding the same rows in the same order with the same test_name set; only the base row's test_context_raw value changes, which the arms assert. Hoisting the _get_sub_result_with_test_cases call above the TableRecord construction is pure: it reads only result.results, returns an existing node, mutates nothing, and the child loop consumes the same object, so it is still called exactly once. Identity keying is sound because Result is a dataclass whose __hash__ is None, and every keyed object is held for the generator's life. No new exception path (only non-None str/list dataclass members are read), no lock, no concurrency, no IO, no early-return path. Row size introduces no new class: this column already holds 15 KB at p99.99 and 12.6 MB at max over 853M rows in 7d, and payloads are capped upstream at 300 retained lines.

Session id: cron:clickhouse-review-slot-8:20260819-230208

@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5c52c5e]

Summary: ✅


AI Review

Summary

This PR moves the failed-step cause into Result._add_job_summary_to_info, trims oversized step payloads, and updates the stateless functional-test digests so that changes in the stateless selection stack actually reschedule the affected lanes. The result.py trimming bugs raised earlier look fixed on the current head, but one sibling of the new digest invariant is still missing: targeted integration tests still import the same selection stack without tracking it in their digest, so PRs that change integration-test selection can still be auto-skipped before that lane runs.

Findings

⚠️ Majors

  • [ci/defs/job_configs.py:196] common_ft_job_config now treats find_tests.py, CIDB, and Info as runner inputs because they decide which tests a targeted or selected lane runs, but integration_test_targeted_pr_jobs still reuses common_integration_test_job_config, whose digest omits all three. ci/jobs/integration_test_job.py:1756-1757 still calls Targeting.get_all_relevant_tests_with_info(), and on the current head JobConfigs.integration_test_targeted_pr_jobs[0].is_affected_by(['ci/jobs/scripts/find_tests.py']), ...(['ci/praktika/cidb.py']), and ...(['ci/praktika/info.py']) are all False. A PR that changes targeted integration-test selection can therefore still be filtered out before the targeted lane imports those modules.
    Suggested fix: give the targeted integration jobs a digest that tracks the same selection inputs, or extend common_integration_test_job_config if you want that coverage on all integration lanes.

  • [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/115526#discussion_r4055067500] [ci/praktika/result.py:375] Result._add_job_summary_to_info now has no committed automated regression coverage after ci/tests/test_job_summary_names_failed_step.py was deleted and ci/tests stopped running. This path already needed two post-review fixes on this PR (cef6bcc5afbe and 5c52c5e4246b), which is exactly the failure mode the deleted focused tests used to catch. I agree that restoring coverage is not fixable inside this branch after the ci_tests removal, but the gap itself remains real.
    Suggested fix: restore a running Python CI test surface for ci/praktika and move this helper coverage there.

Final Verdict

Changes requested: the new stateless digest invariant still needs the same selection-input coverage for targeted integration jobs.

LLVM Coverage Report

⚠️ No coverage measurement for commit 5c52c5e: incomplete coverage measurement: 16 of 21 shard profiles are missing: LLVM_COVERAGE_FILE_ft_2.profdata, LLVM_COVERAGE_FILE_ft_3.profdata, LLVM_COVERAGE_FILE_ft_s3_async_sequential.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_parallel_2.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_parallel_3.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_sequential_1.profdata, LLVM_COVERAGE_FILE_ft_s3_db_repl_sequential_2.profdata, LLVM_COVERAGE_FILE_ft_s3_sequential.profdata, LLVM_COVERAGE_FILE_it_1.profdata, LLVM_COVERAGE_FILE_it_2.profdata, LLVM_COVERAGE_FILE_it_3.profdata, LLVM_COVERAGE_FILE_it_4.profdata, LLVM_COVERAGE_FILE_it_5.profdata, LLVM_COVERAGE_FILE_it_6.profdata, LLVM_COVERAGE_FILE_it_7.profdata, LLVM_COVERAGE_FILE_it_8.profdata.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? A praktika job that dies in a step outside the node named by result_name_for_cidb publishes only Failures: N/M to CIDB and no test rows, so the step's log tail reaches no row and no query can see the cause (22 master jobs across 39 checks in 30d). This appends each such failing direct child's info to the job row, leaving child rows and the old prefix untouched. Note it touches json_data_generator next to your #115425, semantically disjoint but textually adjacent.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 20, 2026
Comment thread ci/praktika/cidb.py Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d0b43566a with master c29afa34d (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 704.41 MiB 701.36 MiB -3.05 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@maxknv

maxknv commented Aug 20, 2026

Copy link
Copy Markdown
Member

@groeneai In result.py, instead of just 'Failures: N/M,' generate a line of failed step and trim the line if too long. drop your change in cidb.py

@maxknv
maxknv self-requested a review August 20, 2026 13:20
@maxknv maxknv self-assigned this Aug 20, 2026
…ures

A job's summary line carried only "Failures: N/M". When a job died in a step
outside the node named by result_name_for_cidb - Install ClickHouse, Start
ClickHouse Server, Checkout Submodules - that count was the only text anywhere
in the job's own info, so the cause reached neither CIDB's job-level row, nor
the report page, nor the GitHub issue body. It survived only inside job.log.

Each failing direct child is now named after the count line, so the summary
identifies what broke. The count line stays first and keeps its exact old
text, so readers and queries written against it keep matching.

Move the fix here from ci/praktika/cidb.py as requested in review: this is the
one site that produces the deficient string, and fixing it lifts every surface
that renders a job summary rather than CIDB alone.

The summary is written only while info is empty, which is precisely the
affected class: functional_tests.py lifts the Tests node's text into the job
info at the end of its test stage, and that stage is gated on the earlier
stages succeeding, so a job that died before it leaves info empty. That same
guard keeps the two shapes that copy a child's info onto the root
(fast_test.py, performance_tests.py) from doubling their own text.

from_commands_run already caps a step's info at 300 lines, and it puts the
cause near the front in its error-centered branch but at the very tail in its
default branch. A one-ended trim would drop the cause in one of the two, so
_trim_step_info keeps both ends, and its bound sits above the widest shape
that function emits so an ordinary step log is named whole.

Tests: 16 items covering the affected shape, both real payload branches, both
trim directions, the count-line prefix, and the SKIPPED and empty-info
boundaries. Ten mutations, one per property, each reddens the suite.
A job whose direct children are test cases (a pytest job with no CIDB selector)
publishes a row per case already, so naming every failure repeated those
payloads in the job row and grew it with the failure count: 40 failing cases
produced a 120 KB job row. Name at most the first few, which is enough to
identify a job that died in one of its steps - the case that has no other
carrier - and leaves the row bounded. Measured 120405 -> 9042 bytes.

Also strengthen two test properties that were satisfiable while broken: the
large-payload arms now assert exact equality with the named step rather than
marker presence, so lowering the trim bound reddens them, and a new arm drives
the real publisher so losing the summary's wiring into the job row cannot stay
green.
The end-to-end arm pre-applied the private formatter, so deleting the
production call from complete_job left the suite green. It now calls
complete_job itself, and a mutation removing that call reddens.
from_commands_run bounds a step's line count but not its line length, so its
error-centered excerpt can put 50 long context lines ahead of the cause. With
406-character lines the cause began at character 20449, inside the span the
two-ended trim removes, so the summary dropped the very error it publishes.
Anchor the kept tail on the first marker when there is one.

Also name a failing selected node's own info: CIDB publishes that node's
children, never the node itself, so its command log otherwise reaches no row.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in result.py, cidb.py reverted: d0b4356. Each failing direct child is now named as <name>: <info> after the count line, so the report page and issue body gain the cause too.

Two things I measured while doing it:

  • from_commands_run bounds line count but not line length, so its error-centered excerpt can put the cause past a plain head or tail cut (measured at char 20449). The trim keeps both ends and anchors on the first : error:.
  • A job whose direct children are test cases already publishes a row per case, so naming all of them grew this row with the failure count (40 cases gave 120 KB). At most the first few are named.

One boundary for you to rule on: when the job info is already non-empty this site does nothing, so a later failing Collect logs still publishes no cause. That predates this PR and is unchanged by it; covering it needs the final tree at serialization time, which is the cidb.py direction you asked me to drop. Fine to leave, or I can follow up separately.

Comment thread ci/praktika/result.py Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026
Comment thread ci/praktika/result.py Resolved
alexey-milovidov and others added 2 commits September 20, 2026 08:13
The job summary that gets published to CIDB is built by
`Result.complete_job` in `ci/praktika/result.py` — this pull request moves
the failing-step cause into exactly that summary. `find_tests.py` already
lists `ci/praktika/cidb.py` in `_STATELESS_HARNESS_PATHS` so that a change
to the reporting path reruns the deterministic smoke tests, but it did not
list `result.py`, which now carries the behavior. Add it, so a change to
what a functional-test run reports is treated as a harness change rather
than being ignored by test selection.

Addresses the AI review's second required action.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread ci/praktika/result.py Resolved
groeneai and others added 2 commits September 20, 2026 15:34
`Result.from_commands_run` centers its excerpt on the first line matching
`: error:` or `: warning:`, but `_trim_step_info` re-anchored the kept tail on
`: error:` only. A warning-centered payload whose context lines are long enough
to push the marker past the retained head therefore lost the only diagnostic
the summary was trying to preserve.

Measured on the pre-fix tree through the real chain (`from_commands_run` into
`_add_job_summary_to_info`): with a 400-line payload of 880-character lines and
the marker on line 100, the `: error:` shape keeps its cause in the job summary
and the `: warning:` shape, otherwise identical, does not. Both keep it now.

Blast radius, 15 `_trim_step_info` shapes compared by sha256 before and after:
only the four whose earliest marker at or after the midpoint is a `: warning:`
in the dropped span change. Short lines, unmarked lines and every `: error:`
placement stay byte-identical.

Reported by clickhouse-gh[bot] on ClickHouse#115526.
`2d058e2e200f` added `ci/praktika/result.py` to `_STATELESS_HARNESS_PATHS`
in `ci/jobs/scripts/find_tests.py`, but that list is read inside the job,
while the decision to run the job at all is made earlier from the job
digest. `common_ft_job_config.digest_config.include_paths` named neither
`ci/praktika/result.py` nor `ci/jobs/scripts/find_tests.py`, so
`_filter_unaffected_jobs` skipped the stateless lanes as "not affected"
before `find_tests.py` was ever imported, and the new entry could not
fire on exactly the change it was added for.

Replaying `Job.Config.is_affected_by` on `common_ft_job_config` with the
changed-file sets confirms it: `['ci/praktika/result.py']` and
`['ci/jobs/scripts/find_tests.py']` both returned `False` before this
commit and both return `True` after it.

`find_tests.py` selects which tests the job runs and `Result.complete_job`
builds the summary the job publishes, so both are genuine runner inputs
of this job.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread ci/defs/job_configs.py Resolved

@leshikus leshikus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR adds more information to a summary and is generally good;

  1. changes like this should be merged to public;
  2. better to have common utility for log trimming and reuse it (add to a helper); maybe as a separate pr;
  3. while usability matters, it is better to leave usability to human, there are plenty of developer requests which are not yet answered, and implementing a random improvement is not a top priority - and your pr description does not mention particular stakeholders;

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks for the review.

1) Agreed, and that is where it is: this PR is on master of ClickHouse/ClickHouse. ci/praktika lives in this tree, and clickhouse-private receives the change through the automatic sync-upstream/pr/115526 PR.

2) You are right, and it is wider than my diff. result.py already has two trimmers: from_commands_run (MAX_LINES_IN_INFO = 300, centered on the first : error:/: warning: line, else the last 300) and get_info_truncated (line cap from either end plus a per-line cut), plus an ad-hoc tail read at result.py:703; native_jobs.py:1471 cuts an exception line at 500 characters. The ~~~~~ truncated ... ~~~~~ banner is written out in five separate f-strings, and mine adds a sixth wording.

They differ on every axis a shared helper needs: unit (lines vs characters), which end survives (one vs both), anchor (first marker vs none). get_info_truncated also has five call sites outside the class (four in check_ci.py, one in native_jobs.py) that render the report page and stdout, so extending it means re-measuring those.

So: a separate PR, as you suggest. I have not opened one, for your point 3: nobody asked for it. If you want it, say which shape should win and I will do it. The one cheap piece that touches nothing shared is reusing the existing banner wording instead of adding a sixth, which I can push here.

3) Fixed in the description, which now names the requesters: @ maxknv specified this shape on this thread ("in result.py ... generate a line of failed step and trim the line if too long"), @ alexey-milovidov approved it and pushed 2d058e2e200f and 2dc83d2d117e to this branch himself, and the consumer is master-CI triage off CIDB, where 152 failing job instances over 30 days publish no cause to any query.

`Targeting._STATELESS_HARNESS_PATHS` lists `ci/praktika/cidb.py`, but
`common_ft_job_config.digest_config.include_paths` did not, so
`common_ft_job_config.is_affected_by(['ci/praktika/cidb.py'])` was `False`
and `_filter_unaffected_jobs` skipped the job before `find_tests.py` could
add the deterministic smoke tests — the same unreachable-entry problem that
`2dc83d2d117e` fixed for `result.py` and `find_tests.py`.

Settled in favour of adding rather than removing the harness-list entry:
`find_tests.py` imports both `CIDB` and `Info`, and
`get_all_relevant_tests_with_info` — called from `functional_tests.py` for
the targeted and selected arms — runs its selection queries through
`CIDB.query`, so a change to either module can change which tests the job
runs. That is the criterion that already put `find_tests.py` in the digest,
so `ci/praktika/info.py` is added alongside `ci/praktika/cidb.py`.

The five remaining entries of `_STATELESS_HARNESS_PATHS` that the digest
still does not cover (`.github/workflows/pull_request.yml`,
`ci/defs/job_configs.py`, the two workflow hooks and
`ci/workflows/pull_request.py`) are deliberately left out: they drive job
orchestration and the job itself never reads them.

Replaying `Job.Config.is_affected_by` on `common_ft_job_config` now returns
`True` for `ci/praktika/cidb.py` and `ci/praktika/info.py`, and still
`False` for `ci/workflows/pull_request.py` and for ordinary sources.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh
clickhouse-gh Bot requested a review from leshikus September 21, 2026 10:41
Comment thread ci/praktika/result.py Resolved
`_trim_step_info` re-anchored its kept tail with `line.find(marker, half)`.
`str.find` only reports occurrences that start at or after its start index,
so a marker that begins in the last characters of the head was never found:
the tail then came from the end of the line, and the message the marker
introduces, the only diagnostic a job-level row carries, fell in the span
the helper drops.

Measured on a4c88b4, a `: error:` starting 3 characters before the
midpoint leaves no cause text in the output at all; a marker that ends
exactly at the boundary loses its message whole. Both markers, and the same
through `_add_job_summary_to_info`.

The search now starts `MARKER_CONTEXT` characters before the boundary, and
the head stops where the kept tail begins, so a marker the boundary splits
is kept in one piece instead of being cut across the inserted notice. Of a
28-shape battery against a4c88b4, 19 shapes are byte-identical, the 4
marker-at-the-boundary shapes gain their cause, and 5 shift the kept window
because the first marker now anchors it. The reported trimmed count stays
exact: the kept head and tail never overlap.
Comment thread ci/defs/job_configs.py
# belong here for the same reason. The other CI-level entries of
# `_STATELESS_HARNESS_PATHS` stay out: they drive job orchestration
# and the job itself never reads them.
"./ci/praktika/cidb.py",

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.

integration_test_targeted_pr_jobs still has the same unreachable-entry gap this hunk fixes for the stateless lanes. ci/jobs/integration_test_job.py:1756-1757 calls Targeting.get_all_relevant_tests_with_info(), but common_integration_test_job_config (ci/defs/job_configs.py:257-268) still omits ci/jobs/scripts/find_tests.py, ci/praktika/cidb.py, and ci/praktika/info.py. On the current head:

JobConfigs.integration_test_targeted_pr_jobs[0].is_affected_by(['ci/jobs/scripts/find_tests.py']) == False
JobConfigs.integration_test_targeted_pr_jobs[0].is_affected_by(['ci/praktika/cidb.py']) == False
JobConfigs.integration_test_targeted_pr_jobs[0].is_affected_by(['ci/praktika/info.py']) == False

So a PR that changes targeted integration-test selection can still be filtered out in _filter_unaffected_jobs before the targeted lane imports those modules. Please give the targeted integration jobs a digest that tracks the same selection inputs, either by extending common_integration_test_job_config or by splitting out a targeted-only digest.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the live head 5c52c5e4246b5. The three booleans reproduce exactly as reported, and the stateless counterpart confirms the asymmetry:

Integration tests (amd_asan_ubsan, targeted):  find_tests.py=False  cidb.py=False  info.py=False
Stateless tests (arm_asan_ubsan, targeted):    find_tests.py=True   cidb.py=True   info.py=True

Two corrections to the scope, both widening it.

The gap is not targeted-only, so the split-out targeted digest would under-cover. ci/jobs/integration_test_job.py imports both modules at file scope (find_tests.Targeting at :12, praktika.info.Info at :20), and the regular sharded arm, explicitly not the targeted one (total_batches > 1 and not is_flaky_check and not is_targeted_check and not is_bugfix_validation, :1821), calls Targeting.is_functional_test_file / is_integration_test_file / is_ci_job_script at :1830-1838 to decide whether to exit SKIPPED (:1843). So find_tests.py and info.py are inputs to every integration job, not only to targeted. Of the two options, only extending common_integration_test_job_config covers that; a targeted-only digest would leave the shards' own skip decision untracked.

Price, since the shared config is then the one that has to move. 37 of the 168 jobs in the PR workflow share this digest. Over the last 6 months of master (41,854 non-merge commits), 194 of them would newly wake those 37 jobs. For comparison, the stateless entries already on this branch cost 181 commits across 33 jobs, so this is the same order of magnitude rather than a new class of cost.

Against that, the measured frequency of the harm is low: of the 210 commits touching the three paths, 2 edited integration-only selection code and 1 of those woke no integration job, and 1 edited the skip classifiers above while touching covered paths anyway. Roughly one occurrence in 6 months.

I have not pushed it. common_integration_test_job_config is untouched by this pull request (its only ci/defs/job_configs.py change is the stateless block), so the omission is pre-existing master rather than something this diff introduces, and the call is a capacity decision on the 37 integration jobs. The patch is the three entries plus the matching comment, the same shape as the stateless block. I will push it here if that is wanted, or leave it out of an approved diff.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 21, 2026
Merged via the queue into ClickHouse:master with commit 0471cc7 Sep 21, 2026
177 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 21, 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-oranjeai PR origin: delegated from the OranjeAI sibling fleet 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.

5 participants