Repository navigation
Conversation
Internal second-model review - adjudicated (click to expand)An independent reviewer pass (own cold review + a second-model gate) ran against this change before publication, over 12 review rounds. Every finding was adjudicated with recorded evidence; blocker/major findings that held up were fixed before this PR was opened. The final round returned zero findings from both the cold review and the gate.
Two further findings were DISAGREEd with recorded evidence rather than fixed. First, that the parser's |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20260726-045900 |
|
cc @leshikus - could you review this? It bounds the three unbounded post-budget stages in |
|
Workflow [PR], commit [4a26d98] AI ReviewSummaryThis PR bounds the post-fuzz AST/BuzzHouse cleanup stages, adds memory-stuck and watchdog classification, and tries to preserve artifacts on abnormal exits. The remaining issue is in the early-abort witness: it still treats any watchdog as proof that the harness already stopped the server, which can hide a genuine server signal when the shutdown witness write fails before Findings
Final VerdictChanges required before merge: the early-abort shutdown witness is still too broad and can suppress a real server signal. |
d2deba8 to
79a0be3
Compare
|
Pushed
The mechanism, from the job log rather than inference: it prints The cleanup itself has to stay (praktika reuses worktrees and Two more defects came out of reviewing that change, both folded into the same commit:
The extracted shell blocks also now run under run-fuzzer.sh's own
One finding I did not act on: the reviewer flagged the unbounded |
The in-container `chmod -R a+r` that makes sanitizer.log.* and the logs host-readable ran inline at the end of `fuzz`, after the marker write. The script runs under `set -e`, so any non-zero command in between skips it: a failing `zstd core.*` on a nearly-full box and a failing `status.tsv` write both abort there, and both were reproduced. On that path the Python side saw a marker and skipped its own host-side ownership repair, so the run uploaded nothing readable - exactly the evidence this change exists to preserve. The chmod now runs from the EXIT trap (after collect_sanitizer_reports, which appends the reports into stderr.log/server.log, so ordering matters), and each trap handler is `||:`-guarded because the trap body itself runs under `set -e`. The Python side no longer treats "a marker exists" as proof that the chmod ran: a container SIGKILLed by the kernel OOM killer never reaches its trap, so the files can still be root-owned 0640. The ownership repair is now skipped only when the artifacts are actually readable. Reported by clickhouse-gh[bot] on ClickHouse#111934. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Pushed 1.
The 2. The Python side did use the marker as a proxy for the chmod having run. Both of your suggested shapes are now in place, because they cover different
One defect found while implementing this that is worth naming: the trap body Five mutation tests, each killing its intended assertion: unguarded trap handlers, Also corrected a now-false line in the PR description: it still said the artifact Not addressed, and not a regression of this change: the unbounded |
|
Pushed All three legs confirmed. The consequence is worse than losing the core. AST-walking Reachability is real, and it is a shape this PR deliberately keeps reportable. Cores are on by default ( Also: this is mine, not pre-existing. At the merge-base the repair ran unconditionally and chowned the whole workspace, cores included; the skip introduced in this PR is what opened the gap. Fixed on both halves you offered, because they cover different failures -- the same split this PR already used for
One constraint worth naming: the cores are passed to the readability check only and are deliberately not appended to
Six new tests; the readability trap is exercised with a real 0640 I also narrowed the description, which said "bound every post-budget stage": the |
…k server The `old_compatibility` AST fuzzer job was cancelled by the workflow before it could upload anything, so the offending query was unattributable: the server kept growing past its memory limit after the fuzz run, and every stage after the budget could block indefinitely. Bound those stages (the fuzzer-client reap, the graceful-stop probe and the teardown watchdog), SIGKILL a memory-stuck server so the teardown is bounded and still carries its artifacts, and report the memory-stuck condition as its own result instead of letting it masquerade as a test failure. Persist the result BEFORE collecting cores, so the worst case is a report without its core rather than the artifact-less cancellation this change exists to remove, and keep the raw sanitizer logs readable on abnormal runs. Exemplar: AST fuzzer (amd_debug, targeted, old_compatibility) on ClickHouse#110074 head 99589a8, https://github.com/ClickHouse/ClickHouse/actions/runs/30084913668/job/89472316051 Co-Authored-By: Claude Fable 5 <[email protected]>
The aggregate probe-stage budget could be exceeded by the very last call it was meant to bound. With one second of budget left, reserving the one second kill grace leaves zero, and a `< 1` clamp restored it to a one second TERM timeout, so `timeout -k 1 1` spent two seconds (measured 2.013s against a TERM-ignoring client) plus a one second cool-down, all past expiry. Clamping a too-small budget up to a launchable value is what exceeds the bound instead of enforcing it. A schedule shorter than TERM plus the kill grace cannot be expressed, so the stage now ends rather than launching such a call. It is a zero-answer exit, so it fails closed exactly like the existing deadline break. The same hazard on the diagnostic was worse: clamping there produced `timeout -k 1 0`, and `timeout 0` means no limit at all (measured: a four second child ran to completion, rc=0), which would have made the call this change wraps to bound unbounded again. It is only a diagnostic, so it is skipped with a log line. Reachability confirmed by sweeping deadlines 2-7 against probe costs 0-4s: the budget seen at the diagnostic takes every value from 1 upward, so the one second case is reachable rather than hypothetical. The one second cool-down is also charged against the budget now, and skipped once it is spent, since the loop head breaks on the next iteration anyway. Two of the existing structural guards matched only the old inline spelling of the recompute and the cool-down; both keep their invariant and additionally pin that the new helpers really derive from the deadline, so neither can be satisfied by a helper returning a constant. Verified by mutation. The boundary and refusal tests were first written with a loose slack that let the pre-fix clamp pass, i.e. vacuously: the two forms only diverge when exactly one second remains (measured 0.00s fixed vs 2.01s clamped at deadline 1, and byte-identical 2.01/3.01/4.01s at deadlines 2/3/4), so the assertion is tight by necessity. The cool-down guard cannot be measured behaviorally at all, because `sleep` is mocked to a no-op in these tests, so it is pinned structurally.
The test drove the probe with a 0.9s sleep to leave the diagnostic exactly one second of stage budget. But `SECONDS` counts whole seconds from an arbitrary tick phase, so that sub-second probe reads as either zero or one elapsed second; when it reads zero, two seconds still remain and production correctly launches the bounded diagnostic, so the skip assertion fails on correct behavior. Measured 1 failure in 20 runs. Wait for the tick to turn instead: the probe now burns two whole seconds of a three second budget regardless of phase, so the diagnostic always sees exactly one second. 30 consecutive runs pass, and the mutant that removes the guard still fails all 6 of 6, so the test stays live rather than merely quiet.
The status.tsv early-abort path ran the log parser only when a memory-stuck marker or a harness watchdog was present. But a server can log a sanitizer report or a logical error and die during STARTUP, before the probe loop that writes a marker is ever reached and long before status.tsv exists; `set -e` then aborts at the PID read or the `kill -0` right after the startup wait. That class had neither marker nor watchdog, so it skipped the parser entirely and was reported as a generic harness error, discarding the stable finding name and its reproduction files -- the same misattribution this change exists to remove, one branch over. Parse unconditionally. With a marker present the parser still outranks it, and `_select_failure_result` keeps the marker as the floor, so a no-match still reports it; with no marker, a genuine finding is all there is, and it now sets the top-level status instead of being buried under the harness error. A FAULTY status.tsv (malformed, unreadable, undecodable) still reports ERROR, since that is a harness bug rather than a run that aborted before reporting. `server_stopped_by_harness` becomes conditional on the run being classified. It tells the parser to treat the server's signal line as self-inflicted, which holds for a classified abort (status.tsv is written after the graceful stop) but not for a startup failure where no stop ever ran -- hardcoding it would suppress a genuine server signal, possibly the only evidence such a crash leaves. The existing guard that pinned the literal `True` keeps its invariant: it now also accepts a name, and additionally checks that the name is derived from marker/watchdog presence, so it cannot be satisfied by an unrelated truthy value. Verified by mutation: reinstating the marker gate is caught only by the structural pin (a behavioral test on the shared helper cannot see a caller-side `if`), and restoring the hardcoded `True` is caught by its own test.
Parsing every early abort introduced the mirror image of the bug it fixed. The runner stops the server BEFORE writing status.tsv, so an abort in that window leaves a run with no marker and no watchdog whose log already contains our own "Received signal 15" -- and with nothing to say the stop was ours, that routine SIGTERM became the failure row, turning a harness error into a misleading FAIL. Reproduced against the shared helper: the selected finding went from 'Unknown error' to 'Received signal 15 (STID: None)'. Inferring the shutdown from marker presence cannot separate the two cases: a startup crash and a post-stop abort both arrive unclassified. So record the fact directly. run-fuzzer.sh writes server_stopping.txt immediately before the graceful stop, and the classifier treats that as the witness alongside a marker or watchdog. It is not a failure marker and never sets a status by itself. The witness joins the pre-run stale-state cleanup: a leftover from an earlier run on a reused worktree would claim the next run's signal line is self-inflicted and suppress a real finding. A shell redirect creates it 0644, so unlike the sanitizer logs it needs no chmod to be host-readable, and the EXIT trap's marker-only gate stays as it is. Verified by mutation: dropping the witness from the decision, dropping it from the stale-state cleanup, and writing it after the stop instead of before are each caught.
A missing status.tsv means the runner aborted before reporting, which a marker, a watchdog or a genuine parser finding authoritatively classifies -- so the sub-results were allowed to set the top-level status there. The parser always yields a row, though. With nothing attributable in the logs it returns UNKNOWN_ERROR / "Lost connection to server", and with no marker to outrank it that row reaches the status decision as a plain FAIL. Deriving from it relabelled the commonest early abort of all, one whose logs say nothing, as "the test failed" rather than the harness fault it is. Key the decision on the row's name, not its status: a genuine finding carries the same FAIL, and a no-match standing beside a marker must not veto the marker. The shutdown-witness read moves into a helper so both polarities can be driven from the unit suite. run_fuzz_job drives docker and cannot run there, and while the read was inlined an inverted witness (not SERVER_STOPPING.exists()) passed the whole file while suppressing startup signals and exposing our own shutdown SIGTERM -- the two bugs the witness exists to prevent, swapped.
The witness pins were satisfiable without the witness working. A text search for the write could not see it being made unreachable, and a name-membership check on the call site accepted `not _early_abort_stopped_by_harness(...)` -- which inverts the verdict, so startup signals get suppressed and our own SIGTERM gets reported. Prove the write by RUNNING the extracted teardown block and checking the file exists afterwards, and require the call site to bind the helper's value directly. Order stays a text pin, deliberately: `stop_server &` is asynchronous, so an observer inside it races the parent and loses -- measured, it reported the witness present in 5 of 5 runs with the write moved below the stop. Execution proves the write happens, the text proves where; neither can cover the other's half.
383ea5f to
bbaf9cb
Compare
|
Both findings AGREED and fixed; pushed as Finding 1 (early abort exits before Finding 2 ( One correction to my own previous round while I was here. The shutdown-witness pins were satisfiable without the witness working: a text search for the write could not see it being made unreachable, and a name-membership check on the call site accepted Verification: 196 focused tests pass. Each new assertion was mutation-tested and fails only for its own defect (no-match guard removed, guard keyed on status instead of name, witness inverted, witness write made unreachable via On the repeated request for fleet or replay distributions behind the 12- and 60-probe tiers: that evidence cannot be produced yet, and the PR body says so. The classifier does not exist on master, so CIDB has zero occurrences of its log line over 45 days. What is checkable is checked: both tiers are bracketed from both sides by tests (11 and 59 consecutive rejections stay healthy, 12 and 60 trip), the loop runs only after the fuzz budget is spent and probes an idle server, only the server-global |
The only conflict was the import block in ci/jobs/ast_fuzzer_job.py: master added `import re` for the benign-241 classifier while this branch added `select` and `signal` for the bounded post-fuzz stages. Kept all three. Master's benign-241 work (1efd8e1..11c387f) and this branch's memory-stuck detector both reason about a server that exceeded its memory limit, so the reconciliation was checked rather than assumed. They cannot double-handle the same evidence: `_is_benign_memory_limit` requires server_died=0, and both paths that write the memory-stuck marker set server_died=1 before breaking out of the probe loop. Where an escalation does leave server_died=0 (the teardown/probes watchdog), `_force_fail_for_markers` runs unconditionally after the classification chain and turns that OK back into FAIL, so the watchdog still reports. Verified with the merged suites: 221 tests pass, which is this branch's 196 plus the 18 benign-241 tests master brought in and the shared e2e rows.
| """ | ||
| return ( | ||
| marker_result is not None | ||
| or watchdog_result is not None |
There was a problem hiding this comment.
watchdog_result is not always evidence that the harness already stopped the server. The stage=reap watchdog is written before the probe loop, and the stage=probes watchdog is written before server_stopping.txt. If echo "phase=shutdown" > server_stopping.txt or another pre-stop step fails under set -e, we enter the early-abort path with a watchdog file but without ever sending clickhouse stop.
Returning True here makes _parse_and_select_failure suppress a genuine Received signal 15 / Received termination signal from the server or the orchestrator and misclassify that abort as self-inflicted. This helper needs to treat only witnesses that imply the stop already happened (marker_result, SERVER_STOPPING, and at most stage=teardown) as sufficient, and it needs a regression that forces a pre-shutdown watchdog plus a failing server_stopping.txt write.
_early_abort_stopped_by_harness accepted any harness_watchdog.txt as evidence that we had already stopped the server. The stage is what carries that meaning: run-fuzzer.sh writes the reap line while the server is untouched and healthy (it kills client-side processes only), and writes the probes and teardown lines only where it goes on to stop the server itself. So a reap-stage escalation whose run then aborted before the shutdown record was written reached the classifier claiming a harness stop. The parser was told to ignore the termination signal, and a genuine server abort was reported as "Unknown error" instead of "Received signal 15" -- the misattribution this change exists to prevent, with the real cause dropped. The window is reachable: the two `} > server_memory_stuck.txt` redirections in the probe loop are unguarded under `set -e` and run after the reap line, so a failing write there aborts before `echo "phase=shutdown" > server_stopping.txt`. Reuse the stage predicates the normal classification path already applies, so both paths now answer this question the same way. Narrowing to the bot's suggested set (marker, the shutdown record, teardown only) would have been wrong in the other direction: the probes stage does stop the server, so dropping it reintroduces false failures. Measured over stage x shutdown-record, the shipped predicate was wrong in 1 of 6 cells and that set in 1 of 6, the other one. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Thanks - this one is correct, and I measured every leg before changing anything. Fixed in f1b1261. Write order per stage (confirms the premise). In The window is reachable. Enumerating unguarded, Effect, measured. Driving One correction to the suggested witness set. I did not narrow to
The old predicate was wrong in one of six cells and the suggested one in a different one. The fix reuses Regression. 197 focused tests pass. Wider |
|
@groeneai is PR still relevant? |
|
No, and I am closing it. The mechanism it guards is still on master ( Three of the pieces I opened this for also landed separately since: #107676 (report runner aborts instead of an opaque What remains here is +5970/-78 across 6 files, 8721 commits behind master, with 0 check-runs on its head because the fork workflow was never approved. That is far too large to ask anyone to review for a defect with no current symptom. If you want the one real residual, I will send it standalone and small: bound the post-stop I am leaving #111892 open for the engine-side memory accumulation, which is the half I never fixed. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Requested by @ alexey-milovidov in #110074 (comment).
After an AST fuzzer run ends, the server can be stuck above its memory limit while idle: every post-fuzz
SELECT 1probe is rejected with(total) memory limit exceededand RSS keeps climbing with zero queries running. The liveness loop tolerated that as "alive, will reclaim" and looped; then a graceful stop with an unboundedwaithung on the saturated server. The job drifted into the external job-cancellation ceiling (~80-90 min) beforestatus.tsvwas written or any artifact uploaded, so the offending query history is destroyed and the growth is unattributable. Exemplar:AST fuzzer (amd_debug, targeted, old_compatibility)on #110074 head99589a86, GHA job 89472316051 ((total) memory limit exceeded: would use 55.80 GiB (attempt to allocate chunk of 0.00 B), current RSS: 57.11 GiB, maximum: 46.32 GiB, canceled at 78.3 min). CIDB: this vanished-job mode hits about 1 run/day per targeted twin and is variant-agnostic (the harness path is shared by all AST fuzzer and BuzzHouse variants), so it is notold_compatibility-specific.Fix: bound the three post-budget stages that produced the hang inside
run-fuzzer.sh(the container's PID1) - the client reap, the liveness probe window and the teardown wait - and make the stuck state a first-class, artifact-carrying FAIL. The pre-existingzstd core.*compression is left unbounded and out of scope (it is master's behaviour, byte-identical here, and the host-side collector it feeds is not part of this change). Fuzz budgets and the--kill-afterclient grace are unchanged.(total) memory limit exceededrejections and trip on two tiers - FAST (>=12 rejections AND hostMemAvailable< 4 GiB, so a grower is caught before it OOMs the box) / PATIENT (>=60 regardless). On trip: writeserver_memory_stuck.txt, SIGKILL the server,server_died=1. Per-query/user 241 andTOO_MANY_SIMULTANEOUS_QUERIESreset the counter; the in-loopSHOW PROCESSLISTdiagnostic is wall-clock-bounded (timeout 10); the whole probe stage carries a 300 s aggregate deadline; the transient-241 reclaim tolerance is preserved within the window. A window with zero answered probes fails closed.waits); a reap/teardown escalation writesharness_watchdog.txtand reports ERROR (never a silent OK).Server unresponsive: memory limit exceeded; a genuine earlier parser finding still wins; a zero-answer exhaustion that is not memory-dominated records a probes-stage watchdog (ERROR) instead of scraping the graceful-stop signal line (the persistent-probe-timeout exit records the same watchdog); all sanitized-build OOM leniency is disabled when a marker/watchdog is present (a self-inflicted SIGKILL and the recoverableallocator_may_return_nullwarning must not be forgiven).The engine-side memory accumulation is not addressed here (no artifacts exist to attribute it yet - this fix creates them). Tracking issue for that follow-up: #111892. Related: #109590 fixes a distinct sub-mode (client exits 241 while the server stays healthy - classification only).
Tests: unit only (no server/docker). The probe loop, the reap/teardown polls and the memory-stuck server kill are exercised verbatim via marker extraction with real child processes (
kill/waitstay real; onlysleepis PATH-mocked), so the wall-clock magnitude of each bound is pinned separately against the block text (poll cadence, counter step, probe-stage deadline, reap slack, teardown deadline). The Python classification is covered via the production helpers, whose call sites inrun_fuzz_jobare pinned by name. The artifactchmodis exercised through its real EXIT trap (normal failed exit, aset -eabort after the marker write, a failing earlier trap handler, a healthy run that must not chmod, and a root-ownedcore.*). The ownership-repair decision also inspects the coresClickHouseService.collect_coreswill read - an unreadable core makes it raise after classification and would discard the whole Result - and those cores are deliberately kept out of the upload list, since a core may only leave the runner compressed and encrypted. Outside the markers, and so onlybash -n-checked: the two gdb tracer PID captures.ci/tests/test_fuzzer_liveness_loop.py(extended) +ci/tests/test_ast_fuzzer_memory_stuck.py(new).