Repository navigation
Keep the kernel's memory-kill record when an integration test run fails - #117104
alexey-milovidov merged 5 commits into
Conversation
An integration run that loses a server node reports only `Code: 210 ... Connection refused`, with nothing anywhere saying what happened to the process. Six runs in five hours on 2026-08-29, two of them on plain master, lost `node1` that way in `test_s3_plain_rewritable` on the `amd_asan_ubsan, db disk, old analyzer, 6/6` shard, and on one of them the dead node dropped 103 downstream jobs. The job already dumps dmesg to `./ci/tmp/dmesg.log`, then attaches it only when a cgroup leaf's own counter fired or a host OOM pattern matched. The runners are cgroup v1, where a memcg OOM is charged to the KILLED TASK's cgroup, so a kill inside a test container moves none of those counters and matches neither host pattern. Measured on verbatim kernel text for such a kill (a real `oom-kill:constraint=CONSTRAINT_MEMCG` line whose `oom_memcg` equals its `task_memcg`), all four existing predicates return nothing: `leaf_oom_report` gives `([], False)`, `dind_leaf_oom_in_dmesg` gives an empty set, `job_cgroup_oom` is false, and `HOST_OOM_DMESG_PATTERNS` does not match, while the same code does fire on a real `CONSTRAINT_NONE` global kill. So the dump is written and discarded: the failing job's result carries `files: []` and its 448 KB log holds no kill text at all. Attach the dump on any failing run where it exists, and print the kernel's memory-kill lines there by reusing the printer that until now was reachable only from the timeout path. `attach_dmesg` stays a disjunct because a host OOM on an uncleared buffer sets it without producing any result row. Two details worth recording rather than commenting in place: - A missing path is no longer attached. Previously a leaf counter could set `attach_dmesg` while the dump command had failed, and `Result` upload turns an absent file into `WARNING: File [...] was not found` written into the job's own `info`. This narrows one cell of the old behaviour deliberately; the superset property over the failure classes is preserved. - `print_oom_lines` selects the `oom-kill:` line, which names the victim task and pid, but not the `Memory cgroup out of memory: Killed process ...` line that carries the RSS, because `OOM_DMESG_MARKERS` holds `Out of memory:` with a capital O and the cgroup variant is lower case. That line is in the attached dump. Widening the marker set would change the timeout path's output, so it is left alone here. No verdict changes: no new result row, no status change, no test or product code, no job scheduling and no cache key. This does not claim the deaths were out-of-memory kills; it makes the kernel's answer recoverable. Co-Authored-By: Claude Opus 5 <[email protected]>
…esults The attach trigger missed one reachable failure shape. A pytest ERROR sets `has_error` only when the check is neither targeted nor flaky, so on those two kinds a run that produced no test rows at all left `attach_dmesg`, `has_error` and the result-row scan all False, while the job was still reported ERROR through `empty_harness_failure`. The dump existed and was discarded, in the one shape where the kernel record is the only evidence available: zero pytest rows means the harness itself died, so a kill of the pytest process is a leading candidate and nothing else in the report can speak to it. The predicate is inlined at the gate rather than shared with the `empty_harness_failure` computed further down, which would have been the tidier arrangement. Sharing it requires moving `pytest_has_results` up as well, and that name is also read by `is_empty_best_effort_skip`, where it is deliberately captured after the synthetic `Timeout` row has been filtered out. Measured over nine arms, on two of them (a flaky or targeted check that timed out having produced only that row) the earlier capture flips `empty_best_effort` from True to False; `test_results` is empty by then and no status is forced, so `create_from` would default to ERROR and a best-effort SKIPPED run would turn red. This change must not move a verdict, so the predicate stays where it can only be read. It is asserted equal to `empty_harness_failure` on all nine arms. Co-Authored-By: Claude Opus 5 <[email protected]>
… an infrastructure error A bugfix-validation run whose only failing test matched an infrastructure pattern still discarded the kernel's memory-kill record, which is the one shape where that record is the only evidence available. Such a run reaches a non-OK status without ever satisfying the attach gate. A pytest session-level FAIL does not set has_error, because that assignment reacts to is_error() only. _mark_infrastructure_errors then sets the failing child to SKIPPED and labels it INFRA, and SKIPPED is is_ok(), so no row is left non-OK either. The run is neither flaky nor targeted, and a kill inside a test container moves no cgroup leaf counter on cgroup v1, so neither of the remaining disjuncts fires. had_infra_or_error is nevertheless true off the INFRA label alone, and the run is reported ERROR. That is exactly the client error a killed container produces, so the relabeled row cannot say whether the kernel killed the server or docker merely hiccuped. Add a fifth disjunct mirroring had_infra_or_error, and hoist the bugfix-label test, which was written out inline twice, into one local so the gate and the reporting site read a single definition. The local is defined at function scope rather than beside the gate: the gate sits inside "if not info.is_local_run", while the reporting site does not, so a local defined there would be unbound on every local run. The INFRA scan itself is not hoisted. The only two mutations of test_results between the two sites are the Timeout filter and the skipped-modules append, and neither synthetic row can carry INFRA: the Timeout row's info is the session-timeout string, which carries no docker context, and the skipped-module rows are built with no labels. Measured on an arm carrying an INFRA row, a Timeout row and a skipped-module row at once. No verdict moves. had_infra_or_error is byte-identical, the hoisted local is equal to the pre-change predicate on all ten label arms, and it reads info.pr_labels exactly as often as before, since the conjunction short-circuits in the same order. This run was reported ERROR before the change and is reported ERROR after it; only the kernel record now survives.
Internal second-model review (click to expand)Three rounds of independent cold review of the resulting code, each with a second-model gate pass, 19 findings over the three rounds: 8 agreed, 5 disagreed with evidence, 6 dropped. Agreed and fixed (both were real holes in the trigger this change adds)
Disagreed, with evidence
Noted, not blocking
Also verified independently rather than accepted: that the two added predicates cannot diverge Session id: cron:clickhouse-review-slot-8:20260829-231000 |
Pre-PR validation gate (click to expand)
Attach matrix. Twelve run shapes, each run twice (dump created / dump missing), by executing the
So the trigger is a strict superset over the failure classes, and the only narrowing is deliberate: Arms 11 and 12 are the negative controls for arm 10. Arm 11 keeps the Mutation controls, each removing one disjunct: dropping all three of round 1's added disjuncts Why the gate inlines the empty-harness predicate instead of reusing the Why the bugfix-validation label test is hoisted rather than inlined a second time: it was already Session id: cron:clickhouse-impl-slot-4:20260829-223900 |
|
Workflow [PR], commit [996726b] Summary: ✅ AI ReviewSummaryThis PR broadens Final Verdict
|
|
cc @maxknv, could you review this? On cgroup v1 a memcg OOM is charged to the killed task's cgroup, so a kill inside a test container moves none of the leaf counters this job checks and matches none of its host patterns, which means |
…ailure The widest term of the attach gate reads every result row, and on a graceful xdist session-timeout the row set carries the synthetic Timeout row that run_pytest_and_collect_results appends. Its status is FAIL, so the term fires even though main strips that row again a few lines further down for targeted, flaky and bugfix-validation checks, all three of which treat a session-timeout as an expected risk rather than a failure. Measured against the shipped gate: a flaky or targeted check that hit its soft time budget after some tests had passed is reported OK and still uploaded the kernel log and printed the kill summary, and one that produced no rows at all is reported best-effort SKIPPED and did the same. Neither is a run anyone will read a kernel log for, and the upload is an artifact on a green job. Excluding the synthetic row loses no evidence. A run that also broke leaves its own non-OK row, so the same term still fires. A check that keeps the row is by definition not one of the three above, and for those the batch site sets has_error on a pytest ERROR, which the second disjunct already covers. Both directions are pinned by the truth table in the regression test, which also derives the reported status from the module's own strip statement and is_empty_best_effort_skip rather than restating them, and carries a mutation control that removes the exclusion again and asserts the same shapes flip back. Two paths still keep the record on a run finally reported OK, deliberately: a coverage shard whose failures all passed on retry, and a labelled bugfix validation whose reproduction is a genuine test FAIL. Both are green by policy rather than because nothing failed, and this file already refuses to let a resource kill be laundered by either flip. finalize_llvm_coverage_status keeps has_error across the coverage set_success for exactly that reason, and the status inversion is skipped for the OOM row so it cannot turn the job green. Basing retention on the finalized status would undo both. Co-Authored-By: Claude Opus 5 <[email protected]>
Master no longer has a ci/tests suite. ClickHouse#115650 (6fbc634, merged 2026-08-29 22:03 UTC) deleted all 65 files under ci/tests, the ci/jobs/ci_tests_job.py runner that ran pytest over them, the JobConfigs.ci_tests job config, JobNames.CI_TESTS and the generated pull_request.yml entry. This branch forked before that merge, so the file I added would have landed in a tree with no suite and no job to run it, and since git tracks files rather than directories it would have brought ci/tests back holding that one file. .claude/CLAUDE.md:190 covers the case directly: a throwaway test for a CI-script change is fine to write and run, and does not need to be committed. The proof stays in that form. It still executes the real gate expression sliced out of the module instead of a transcription, still runs the truth table in both directions, still derives the reported status from the module's own strip statement and `is_empty_best_effort_skip` rather than restating them, and still carries the mutation control that puts the synthetic row back and asserts the same shapes flip. 310 assertions pass on this tree and none were lost against the previous run. Correcting the previous commit message, which pinned both directions "by the truth table in the regression test": that file is no longer in the tree, so that is the throwaway harness. Co-Authored-By: Claude Opus 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Integration test jobs now keep and print the kernel's
dmesgmemory-kill record when a run reports a failing test or a job error, not only when a cgroup counter fired.Description
Six integration runs in five hours on 2026-08-29, two on plain
master, lost a server node intest_s3_plain_rewritableon theamd_asan_ubsan, db disk, old analyzer, 6/6shard. The test onlysees
Code: 210 ... Connection refused, and one run's dead node dropped 103 downstream jobs. Icannot say what killed it: the run throws away the one record that could,
dmesg.The job already dumps
dmesgto./ci/tmp/dmesg.log, but attaches it only when a cgroup leaf'scounter fired or a host OOM matched. The runners are cgroup v1, where a memcg OOM is charged to the
KILLED TASK's cgroup, so a container kill moves none of those counters. Measured on real kernel text
for such a kill, all four predicates return nothing. The failing job's result carries
files: []and no kill text.
This attaches the dump, when it exists, on any run reporting a failing test, a job error, an empty
harness run, or a bugfix validation aborted by infrastructure, and prints the kernel's memory-kill
lines, reusing the timeout path's printer. A flaky or targeted run that only ran out of its time
budget keeps nothing: the synthetic session-timeout row does not count. No verdict changes: no new
result row, no status change, no product code. I do not claim these deaths were out-of-memory kills;
the kernel's answer is unrecoverable.
I did not reproduce the kill: it depends on co-tenancy inside a 40.78 GiB cgroup, and CI's retry of
the four tests passed in 103 s. Validation is a throwaway harness, as
.claude/CLAUDE.mdprescribesfor CI-script changes: it executes the real gate expression and pins it both ways. I proved
print_timeout_diagnosticsbyte-identical after the extraction and rerantest_memory_limit_observer(which tolerates a container OOM by design) andtest_s3_plain_rewritable.No related open issue. Provenance: failing job, report, master hit.
Workflow [PR]
Sync PR [sync-upstream/pr/117104]
Version info
26.9.1.385(included in26.9and later)