Skip to content

Do not report the stress harness's own server kill as an allowed OOM - #128778

Open
groeneai wants to merge 3 commits into
ClickHouse:masterfrom
groeneai:ci-stress-harness-kill-not-oom
Open

groeneai wants to merge 3 commits into
ClickHouse:masterfrom
groeneai:ci-stress-harness-kill-not-oom

Conversation

@groeneai

@groeneai groeneai commented Nov 2, 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

Stress test (*) and Upgrade check (*) go green with OOM error (allowed in stress tests) whenever the harness itself has to SIGKILL a server that would not stop, and that clears every other failure of the run. Over 30 days, 32 of the 36 runs with a shutdown deadlock or a stateful-prep timeout were green, 18 of them with a ThreadSanitizer report. Two master jobs:

clickhouse stop --force kills the server, and the watchdog logs it with the same <Fatal> record as a kernel OOM kill. stress_job.py reads that record as OOM.

kill_server in stress_tests.lib kills the watchdog instead. The server dies with it (PR_SET_PDEATHSIG), nothing is logged, and clickhouse stop --force still runs afterwards. It also writes a Server killed by the harness OK row. All four kill sites use it. For a killed server, stress_job.py now runs the log parser and keeps only the defects it names (not a query's (total) memory limit exceeded), so a TSan report keeps its row. Genuine OOM kills are handled as before.

Validation, in the CI image with the script as PID 1, on master and 26.10.2.103 binaries: the server and watchdog are gone, with no zombie and no record, and the restart works. Master's harness and a direct server kill do log the record. I replayed run_stress_test on both jobs above: they now fail with those findings named. A tolerated slow stop stays green, and the genuine memcg OOM of #127014 is unchanged.

Not changed here: the AST fuzzer reads a clickhouse stop SIGKILL as a sanitizer OOM too (1 of 16 such runs in 30 days).


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

groeneai and others added 2 commits November 2, 2026 22:09
`clickhouse stop --force` SIGKILLs the server, the child of the watchdog,
and the watchdog logs it with the same `<Fatal> ... Child process was
terminated by signal 9 (KILL) ... the possible cause is OOM Killer` record
as a kernel OOM kill. `stress_job.py` sets `is_oom` on that record and
turns any failed result into `OK` + `OOM error (allowed in stress tests)`.
The harness force-kills exactly when something hung, so the hung checks,
shutdown deadlocks and sanitizer reports of those runs went green: 32 of
the 36 runs with a shutdown deadlock or stateful-prep timeout in 30 days,
e.g. master f5b8c2c `Stress test (arm_tsan)` and 175f851
`Stress test (azure, amd_tsan)` (TSan heap-use-after-free, STID 1938-332e).
The few red ones ran with `logger.async=1`, which can lose the record
because the watchdog `_exit`s right after logging it.

`kill_server` kills the watchdog instead (a fork of the same binary, the
server's parent). The server dies with it through `PR_SET_PDEATHSIG` and
nothing logs the record. `clickhouse stop --force` still runs afterwards,
as the fallback when there is no watchdog and to wait until the pid is
gone; the runner script is PID 1 of the container and reaps the orphan.
The helper writes a `Server killed by the harness` OK row, the same
pattern as `Warning: server did not stop yet`. All four forced stops
(both branches of `stop_server`, `run_prep_statement`, the upgrade
check's tables-count block) use it.

The watchdog's record was also what made `stress_job.py` run the log
parser for these runs, which is how their sanitizer reports got a row.
A killed server now runs the parser too, keeping only the failures the
logs name, so a tolerated kill with nothing else wrong stays green.
Genuine OOM kills (the kernel kills the server, the watchdog logs it)
and the crashed path are unchanged.

Validated in `clickhouse/stress-test` with the script as PID 1, on
master and 26.10.2.103 binaries, and by replaying `run_stress_test` on
the uploaded artifacts of the two master jobs above and of the genuine
memcg OOM in ClickHouse#127014.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erver

A killed server now runs the log parser, whose last class names any
`(total) memory limit exceeded` line in the err log. Before, the watchdog
record pre-empted it, and `clickhouse-test` retries that line as noise, so a
tolerated slow stop must not go red on it. Drop it on the killed path only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Nov 2, 2026

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

Pre-publication review by an independent model (engine: codex; 3 findings, 0 on the re-review of the fix) plus my own review (2 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ A killed server's err log with a (total) memory limit exceeded line is named Server unresponsive: memory limit exceeded, so a tolerated slow stop can go red (ci/jobs/stress_job.py) AGREE, fixed @ f1f29b3 that class is dropped on the killed-not-crashed path; clickhouse-test already retries the line
2 ❌ If the watchdog is not found or not killed, clickhouse stop --force brings the OOM-like record back (stress_tests.lib) DISAGREE the watchdog is the server's direct parent (fork without exec); a parent that is not a same-binary fork means no watchdog, so nothing writes the record. Measured in the CI image: 0 records on master and 26.10 binaries, both logger modes
3 ⚠️ A marker-only kill with missing or failed log parsing passes without failing the job DISAGREE every killed path except the tolerated slow stop already writes its own FAIL row (Possible deadlock on shutdown, Stateful data preparation statement exceeded); the tolerated stop is a release build whose verdict for that state was OK before as well
4 💡 The tables-count block names no hang noted not changed by this PR; the observed runs had an already-dead server, where kill_server is a no-op
5 💡 When a killed server's logs name a defect, Test script failed and Check failed are dropped as on the crashed path noted the job stays red on the named defect

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261102-224400

@groeneai

groeneai commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. In the CI image (clickhouse/stress-test:fae424a450c67f81e646_amd, the script as PID 1, sync logger), a hung stop through stop_server 5 false with master's stress_tests.lib logs the watchdog's Child process was terminated by signal 9 ... OOM Killer record every time; replaying run_stress_test on the uploaded artifacts of master f5b8c2c15a58 and 175f851476e1 gives OK + OOM error (allowed in stress tests) every time.
b Root cause explained? clickhouse stop --force SIGKILLs the server, the child of the watchdog. The watchdog logs the same <Fatal> record as for a kernel OOM kill, and stress_job.py sets is_oom on it and turns any failed result into OK. The harness force-kills exactly when something hung, so hung checks, shutdown deadlocks and sanitizer reports of those runs go green.
c Fix matches root cause? Yes. kill_server kills the watchdog instead: the server dies with it (PR_SET_PDEATHSIG), nothing logs the record, and a Server killed by the harness OK row says what happened. For a killed server the job keeps only the defects the log parser names, not a query's (total) memory limit exceeded. Genuine OOM detection (the record when the kernel kills the server, the dmesg arm) is unchanged.
d Test intent preserved / new tests added? Test-infrastructure change, so no self-test. It was validated locally: 20 runs in the CI image (2 binaries x 5 cases x 2 logger arms) plus a verdict replay of run_stress_test (16 runs, and 8 more for the memory-limit case).
e Both directions demonstrated? Yes. Master's lib or a direct server kill: 2 records. kill_server: 0 records, 1 marker row, on master and 26.10.2.103. Replays: 175f851476e1 goes from OK to FAIL with the hung check, the shutdown deadlock and ThreadSanitizer (STID: 1938-332e), and f5b8c2c15a58 from OK to FAIL. A tolerated kill whose err log also has a query's (total) memory limit exceeded line stays OK. Four mutations (no watchdog kill; no parser run for a killed server; no Unknown error filter; no memory-limit filter) each redden one scenario.
f Fix is general across code paths? All four clickhouse stop --force sites in tests/docker_scripts use kill_server, and nothing else in the harness kills the server. A sibling is not changed: the AST fuzzer reads a clickhouse stop SIGKILL as a sanitizer OOM too (1 of 16 runs in 30 days). It is a separate job.
g Fix generalizes across inputs (params/datatypes/wrappers)? Covered: both binaries, both logger arms, check_hang true and false, the explicit pid and the pid-file form, an already dead server (no marker, plain clickhouse stop --force), and no watchdog (falls back to clickhouse stop --force).
h Backward compatible? (maintainer-approved exception only) Yes. No settings and no formats change. Release branches keep their own harness. Runs that hid a hang now report it.
i Invariants and contracts preserved? The server is dead and reaped when kill_server returns: clickhouse stop --force waits for the pid, and the runner (PID 1) reaps it. The probe saw 0 zombies, and the restart worked. The watchdog cannot log after its SIGKILL is pending. Every new probe command is set -e safe. The crashed path of run_stress_test is unchanged.

Session id: cron:clickhouse-impl-slot-7:20261102-213000

@groeneai

groeneai commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this and add the can be tested label so CI runs? When the stress harness has to SIGKILL a server that would not stop, the watchdog logs the same record as a kernel OOM kill and stress_job.py turns the whole job green; kill_server now kills the watchdog instead, so hung checks, shutdown deadlocks and TSan reports from those runs stay red.

@clickhouse-gh

clickhouse-gh Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [78e4a07]

Summary: ✅


AI Review

Summary

The PR distinguishes server termination by the stress harness from a kernel OOM kill and parses server logs after harness kills to preserve hang and sanitizer failures. No actionable findings at 78e4a07a6444ea4ba34a65b50020bdb7e5a5459d. Validation passed 24 verdict replays and five existing parser tests, invoked directly because pytest is unavailable.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 2, 2026
@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - f1f29b3

Every failure below has an owner: a fixing PR (mine 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
La Casa Del Dolor (amd_msan) / dolor.py exception harness: the randomized Azure disk config drew strict_upload_part_size 100.00 MiB above max_upload_part_size 16.00 MiB, so node0 refused to start (INVALID_SETTING_VALUE in server.err.log); the same failure hits other PRs, and this diff does not touch the check #128857 (mine, open)
Mergeable Check, PR praktika rollups of the row above #128857 (the owner of the row above)

Session id: cron:our-pr-ci-monitor:20261103-023003

…ill-not-oom

Resolve the conflict in tests/docker_scripts/stress_tests.lib: keep kill_server and take
master's removal of wait_server_port_free (replaced by wait_server_ports_free).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Nov 17, 2026

This branch has not been deployed

No deployments
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). manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant