Skip to content

Follow the kernel log for the whole integration test run instead of snapshotting a wrapped buffer - #117199

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-integration-dmesg-whole-run-record
Aug 31, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-integration-dmesg-whole-run-record

Conversation

@groeneai

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

Related: #117104, the diagnostics half.

The integration test job clears the kernel ring buffer at the start and reads it back at the end.
Nothing bounds it in between: the job's container churn logs several kernel lines per veth
pair, wrapping it every few minutes while the job runs for over an hour.

Measured on three red Integration tests (amd_asan_ubsan, db disk, old analyzer, 6/6) runs on
2026-08-30 (report):
the uploaded dmesg.log held 7m47s of a 103-minute run, 4017 of 4017 lines were veth churn, and
the OOM kill happened 42 minutes before its earliest retained line. All three printed No kernel memory kill in dmesg and reported no leaf breach: false-cleans on runs where a server was killed.

The code that interprets the record is unchanged; it was never fed a buffer holding the kill.

This starts dmesg -T --follow after the clear and feeds every detector follow + snapshot. The
union is a strict superset of today's input, so no detector can lose a signal it has now. Coverage
is derived from the follower still being alive, and a negative says so when the record does not
cover the run. A missing or dead follower counts as uncovered, so this fails closed, and
dind_unreportable_ooms now takes coverage rather than "the dump succeeded", which a wrapped
buffer also satisfies. Runs whose kill fell outside the retained window now show the red row
they should have.

Container limits, worker sizing and test_s3_plain_rewritable are unchanged: naming the breaching
cgroup is what was missing; capacity is a separate question. The other clear-then-read sites in
ci/ lack this job's container churn.

Verified on the real wrapped artifact: the existing detector names Container memory budget exceeded (/docker) once the kill is in the union.


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

Version info

  • Merged into: 26.9.1.408 (included in 26.9 and later)

The integration test job clears the kernel ring buffer at the start and reads
it back at the end. Nothing bounds the buffer in between, and the job's own
container churn logs several kernel lines per veth pair, so it wraps every few
minutes while the job runs for over an hour.

Measured on three red `Integration tests (amd_asan_ubsan, db disk, old
analyzer, 6/6)` runs on 2026-08-30: the uploaded `dmesg.log` covered 7m47s of a
103-minute run, 4017 of its 4017 retained lines were veth or bridge churn, and
the memcg OOM kill that ended the run was logged 42 minutes before the earliest
retained line. All three runs printed `No kernel memory kill in dmesg`, and
reported neither a leaf breach nor an unattributable one, on runs where the
kernel had killed a ClickHouse server.

So every dmesg-derived verdict in this job was being evaluated on the last few
minutes of the run while `dmesg_cleared` reported the buffer as authoritative,
and the negative was structurally unreachable rather than merely unlucky.

The code that interprets the kernel record is unchanged. `MEMCG_OOM_OWNER`,
`dind_leaf_oom_in_dmesg`, `job_cgroup_oom` and `leaf_oom_report` already know
how to name the breaching cgroup; they were never fed a buffer containing the
kill.

This starts `dmesg -T --follow` immediately after the clear and gives every
detector `follow + snapshot`. The union is a strict superset of the previous
input, so no detector can lose a signal it had before. `--follow` prints the
buffer it starts with before following, so the sub-second window between the
clear and the start needs no marker, and the follower's own tail is covered by
the terminal snapshot.

Whether the record covers the run is derived from the follower still being
alive, deliberately not from a timestamp or from the log file existing: a
follower that died early leaves a file beginning exactly where a healthy one
would, so either of those would reproduce this same defect one layer up. A
dmesg-derived negative now says the record is partial when coverage is absent,
and a missing or dead follower counts as uncovered, so the reporting fails
closed.

`dind_unreportable_ooms` takes that coverage instead of "the dump command
succeeded". Its argument is renamed accordingly: the whole defect was a
predicate promising something weaker than its consumer assumed, and a dump of
an already-wrapped buffer satisfies the old one while holding none of the
window a kill would be in.

The two caveats ride opposite branches, because a buffer is unsound in opposite
directions. An uncleared buffer holds a superset, so a kill it shows may be
another job's while its silence still covers this run. A wrapped buffer holds a
subset, so a kill it shows is this run's while its silence proves nothing.

The follow log gets its own path because the hard-timeout `on_error_hook`
truncates `./ci/tmp/dmesg.log`, and it is added to `set_files` so a hard-killed
run uploads it too. One follower is started and stopped once, after the late
scan; every run that starts one reaches that stop, since the only
`complete_job` after the start is the final one. A run the runner hard-kills
leaves it to die with the job's container.

Container memory limits, worker sizing and `test_s3_plain_rewritable` itself
are deliberately untouched: naming the breaching cgroup is what was missing,
and choosing a capacity remedy is a separate question. The other
clear-then-read sites under `ci/` share the pattern but were not measured to
wrap, and no claim is made about them.
… start

Review of the previous commit found three edges of the new capture lifecycle.

Coverage was derived from the follower being alive alone. The follow log is read
before that poll and with no drain barrier, so the records the follower has not
consumed yet are not proven to be in it; the terminal snapshot is what covers
that tail. Normally both are present, but when the snapshot fails the union
collapses to the followed bytes while coverage still reported the record as
spanning the run, and the honest `WARNING: no dmesg available` this path used to
print became a bare `No kernel memory kill in dmesg`. Coverage is now a live
follower and a successful snapshot, on all three paths that compute it. The
weaker reading, "a successful snapshot instead", is not adopted: that is exactly
the predicate the previous commit removed from `dind_unreportable_ooms`, since a
dump of an already-wrapped buffer satisfies it.

`ci/tmp` is git-ignored, so `_pre_run`'s `git clean -ffd` leaves its contents
for the next job on the same runner. `start_dmesg_follow` truncates the follow
log, but it is not called when the clear fails, and the readers, the two
attaches and the `on_error_hook`'s `set_files` could then take a previous job's
kernel record for this run's. The `dmesg_cleared` gates keep it out of every
result row, so no verdict was wrong, but the hard-timeout diagnostics printed
its kill lines and the artifact was attributed outright. The file already
carries `clear_rabbitmq_recreation_scan_inputs` for this exact class, whose
docstring states the rule: anything left in `temp_path` by an earlier job counts
as an event of this one. The log is unlinked at job start instead of in that
helper, which runs after the follower is started and would delete a live file.

`print_timeout_diagnostics` claimed its only caller ran when the clear had
succeeded. It does not: the hard-timeout path calls it whatever the clear did.
That inference is deleted and the clear state is passed in, so the positive
branch on the one path that never qualified it now carries the same caveat the
end-of-run path has. An empty snapshot is read as a failed one there, because
`Shell.get_output` returns an empty string for a failure and for a genuinely
empty buffer alike; the conflation over-warns, which is the safe direction.

`stop_dmesg_follow` no longer waits a second time after `SIGKILL`. It runs one
statement before `report_rabbitmq_recreations` and two before `complete_job`,
and `Result.update_sub_result` matches by name and silently keeps the
placeholder, so a `TimeoutExpired` there would cost the run every row this
change exists to produce. `SIGKILL` needs no confirmation. The first wait stays:
it is what makes an ordinary stop observable and what reaps the child.

The `Popen` in `start_dmesg_follow` only reports that the fork happened, so a
`sudo` or `dmesg` that exits immediately was reported as a healthy follower. It
now waits before polling, as `start_docker_in_docker` does before trusting its
daemon. A refusal slower than that is still caught, because coverage polls the
process again where the record is read.

The comment justifying the overlapping lines in the union claimed every consumer
returns a set or a boolean. `print_oom_lines` is a consumer and renders one line
per match, so a kill still inside the snapshot's window is printed twice in the
job log. That is the accepted cost of not deduping, not an absent effect: `-T`
has one-second resolution, so deduping by line would merge two genuine kills in
the same second. No result row can be duplicated, because the rows are built
from the set-valued and boolean detectors.
@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 30, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 rounds, 4 findings) plus my own
cold review of the resulting code (5 findings). One fix round was bounced and executed before this.

# Sev Finding Verdict Evidence / action
1 ⚠️ Coverage now needs both halves, but show that an evicted kill actually reaches the detectors and that every degraded-capture path refuses coverage (raised in both rounds) AGREE, satisfied @ e4853aa Throwaway suite, 39 arms green, 14 mutation controls. Kill placed only in the follow half of the union on the real wrapped artifact from run 117161: leaf_oom_report yields Container memory budget exceeded (/docker). Dead follower, missing follower, failed snapshot and empty snapshot each yield only a caveated negative. Removing the follower bytes reddens 7 arms; weakening either coverage conjunction reddens 6. Not committed, per .claude/CLAUDE.md ("you can write and run a throwaway test, but you don't need to commit it, because we don't have automated CI tests") and ci/tests/ was deleted in 5e8bf203b1409d2.
2 ⚠️ The description claimed the other clear-then-read sites in ci/ "was measured to wrap"; no such measurement was taken AGREE, corrected in the description Two sites share the shape (ast_fuzzer_job.py:540 after run-fuzzer.sh:6, clickhouse_proc.py:978 after :349). Reworded to the structural reason: they lack this job's per-module container churn.
3 💡 stop_dmesg_follow docstring cites a sibling helper's waiting pattern; that belongs in the commit message AGREE, not blocking Intra-file pointer, and the sentence before it carries the invariant. Left as is.
4 💡 The late-block follow-log attach is guarded by the breach and the file's existence but not by "not a local run", unlike its sibling AGREE, not blocking Unreachable in CI: a local run never starts a follower, so the file can only exist there if a CI job ran in the same checkout, and a local run uploads nothing.
5 💡 Possible formatter violation on two added lines DROPPED Withdrawn on measurement: black is not part of the style job (no reference in ci/jobs/check_style.py, which registers only ruff and pylint), and both configured line limits are 200 against a longest added line of 100.

Recorded limitation rather than a claim: four arms assert on the source text instead of running
end to end, because the statements they cover are inline in a 700-line main that a harness cannot
invoke. Each is paired with a source mutation that reddens it.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-9:20260830-211000

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, and input-driven rather than timing-driven. Feeding the real dmesg.log artifact from the red run to the job module's own detectors prints No kernel memory kill in dmesg every time, on a run whose kernel record shows a memcg OOM kill 42 minutes before the artifact's earliest line.
b Root cause explained? The job clears the kernel ring buffer at the start and snapshots it ~100 minutes later. Nothing bounds the buffer in between, and the job's own container churn logs several kernel lines per veth pair, so it wraps every ~8 minutes. Every dmesg-derived verdict is therefore evaluated on the last ~8 minutes of the run while dmesg_cleared reports the buffer as authoritative. Measured: 4017 of 4017 retained lines were veth churn, 0 OOM markers.
c Fix matches root cause? Yes. The record is captured for the whole run rather than snapshotted after it wrapped, and a negative derived from a non-covering record is made non-committal. No detector pattern is widened, no threshold moved, no capacity changed. The code that interprets the record is untouched; it was never fed a buffer holding the kill.
d Test intent preserved / new tests added? No test file changed. Coverage is a throwaway harness (39 arms, 14 mutation controls, each reddening the arms it targets), which is what .claude/CLAUDE.md prescribes for CI-script changes; ci/tests/ is gone from master and was not resurrected.
e Both directions demonstrated? Yes, on the same fixture. Snapshot alone: no leaf named, no job breach, no host OOM, No kernel memory kill in dmesg. Union with the lost kill: dind_leaf_oom_in_dmesg names docker and leaf_oom_report yields Container memory budget exceeded (/docker).
f Fix is general across code paths? All seven dmesg consumers checked: leaf_oom_report, host_oom_in_dmesg, print_oom_lines, report_late_leaf_ooms, print_timeout_diagnostics (which also takes the clear state now, so its positive branch is qualified on the one path that never qualified it), dind_unreportable_ooms (now gated on coverage, not on "the dump succeeded"), and prefetch_failure_result, which runs before the clear and is deliberately unchanged. The hard-timeout on_error_hook truncates dmesg.log, so the follow log is a separate path and is added to set_files.
g Fix generalizes across inputs? The input matrix here is (buffer cleared, follower state, snapshot state). An uncleared run reaches byte-identical verdicts, and the follow log is removed at job start so a record left in the git-ignored ci/tmp by an earlier job on the same runner is neither read nor uploaded. A follower that refuses to start or dies mid-run yields the partial-record wording and names both unreportable gaps. A failed snapshot keeps the followed bytes, where today the buffer would be empty, and still reports the gap, because coverage requires both halves. Boundary cases covered: empty follow log, absent follow log, an empty snapshot read as a failed one, and a final line torn mid-write.
h Backward compatible? Yes. No server code, no settings, no SettingsChangesHistory entry, and no result row added or renamed, so no CIDB history keyed on a row name is reset. The union is a strict superset of today's input, so the change is monotone: no detector can lose a signal it has today.
i Invariants and contracts preserved? The invariant added is that a dmesg-derived verdict is admissible only on a record covering the run; the file already enforced the "cleared" half and this adds the "covers" half. Coverage is a live follower and a successful terminal snapshot: the follower proves the earlier window, and only the snapshot proves the tail it has not consumed yet. It is not derived from a timestamp or from file existence, because a follower that died early leaves a file beginning exactly where a healthy one would. One follower, one stop site, and every run that starts one reaches it: the only complete_job after the start is the final one and main has no earlier return in between. A missing follower or a failed snapshot is treated as uncovered, so the reporting fails closed.

Session id: cron:clickhouse-impl-slot-6:20260830-204100

@clickhouse-gh

clickhouse-gh Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e4853aa]

Summary: ✅


AI Review

Summary

This PR replaces the single end-of-run dmesg snapshot with a long-lived dmesg --follow capture plus terminal snapshots, and threads the new coverage and uncleared-buffer caveats through the timeout, main-report, and late-coverage paths. I traced the changed lifecycle and the surrounding helper semantics on the current PR head and did not find a correctness or operational regression that warrants an inline review comment.

Final Verdict

✅ No actionable findings on the current PR head.

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

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this? The integration test job clears the kernel ring buffer at job start and reads it back about 100 minutes later, but the job's own container churn wraps the buffer every few minutes, so a memcg OOM that killed a server was reported as No kernel memory kill in dmesg. This follows the buffer for the whole run and makes a dmesg negative non-committal when the record does not cover it.

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