Skip to content

Stress test: report a server abort collected into fatal.log - #113608

Merged
PedroTadim merged 4 commits into
ClickHouse:masterfrom
groeneai:stress-report-collected-fatal
Aug 7, 2026
Merged

PedroTadim merged 4 commits into
ClickHouse:masterfrom
groeneai:stress-report-collected-fatal

Conversation

@groeneai

@groeneai groeneai commented Aug 6, 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):

Stress test (*) and Upgrade check (*) now report the assertion, stack trace and stack-trace id of a server abort that is collected into fatal.log, instead of only the job's own exit code.

Description

run_stress_test greps the server logs for <Fatal> into fatal.log on every run and uploads it, but nothing read it. The only trigger for crash attribution was a test result literally named Server died, written in one place: stress.py's except ServerDied handler, whose sole raise site is a single early kill -0 liveness probe. That probe cannot observe a dying server, because BaseDaemon writes the symbolized stack frame by frame and the child stays live throughout (measured at 27-34 s), and it runs once, before the death. An abort it missed therefore never unlocked the parser, and the job reported a 20-byte Test script failed / script exit code: 1 while every durability gate passed. This scan was unconditional before 85deff3297117e6c; ClickHouseProc.check_fatal_messages_in_logs never regressed and is the shape followed here.

This keeps that grep's result and widens the one condition already gating the parser. server_died stays a separate signal: it is the only one for a silent death, which fatal evidence cannot see. Both triggers share that single gate, so the parser still runs at most once per job by construction. The predicate is the collected content, not the grep's exit code, because rg also exits non-zero when it did match but could not read some file of the glob.

Across seven observed shas, master included, fatal.log was 41-117 KB and named seven real aborts that never reached the CI database; a green run's is 0 bytes. Driven against one carrier's real uploaded log, the job now reports Logical error: '… typeid(*this) == typeid(rhs)' (STID: 2508-2e0c) with the stack.

upgrade_job.py calls run_stress_test, so the Upgrade check inherits this. Deliberately unchanged: the new row is unlabelled, matching the existing parser path; the is_oom override still lets an OOM pass; and a sanitizer report only in stderr.log still cannot reach the parser.

Verification

ci/tests/test_stress_job.py is byte-identical to master, at @PedroTadim's request; its 17
pre-existing arms are untouched. Nothing in-tree pins the change, so the evidence below is the
record of how it was verified rather than something CI re-checks.

Six arms drove run_stress_test end to end with the docker run replaced by a real shell command
writing the artifacts it would have produced, A/B'd against pristine master. Four failed before
and passed after: a collected fatal parsed into a named failure, the OOM override still winning
over one, a fatal only in a replica log, and benign <Fatal> lines not fabricating a name. Two
were controls that held both sides: a realistic clean log staying green, and Server died without
a fatal behaving exactly as before. The first asserts the parsed name; a bare "some result
failed" would hold before the change too, because Test script failed is itself a failure.
Shell.run was deliberately not stubbed, since Shell.check delegates to it and faking it would
have stopped the rg from running and made every assertion vacuous.

Five mutants, each applied once and verified to perturb no other line: reverting the gate to
if server_died: reddened the four witnesses; triggering on the log file existing rather than its
content, and gating on the fatal evidence alone, each reddened exactly one arm, which is what
showed the predicate is the content and that server_died is still load-bearing; inverting the
captured evidence reddened five; making the stack-trace id unavailable reddened one.

The whole ci/tests/ suite is 4 failed / 619 passed on this head, the same four pre-existing
failures as on master, all needing a live server or process control.

Version info

  • Merged into: 26.8.1.962 (included in 26.8 and later)

groeneai and others added 2 commits August 6, 2026 00:38
`Stress test (*)` and `Upgrade check (*)` could exit 1 while every named
durability gate on the same job passed, reporting a single content-free row
`Test script failed` / ` script exit code: 1` and nothing else: no assertion
text, no stack trace, no stack-trace id. The abort was not lost by the
harness - it was collected and then discarded.

`run_stress_test` greps the server logs for `<Fatal>` into `fatal.log` on
every run and uploads it, but nothing read it. The only trigger for crash
attribution was a test result literally named `Server died`, written in one
place: the `except ServerDied` handler in `stress.py`, whose sole raise site
is a single early `kill -0` liveness probe. That probe cannot observe a
*dying* server - `BaseDaemon` writes the symbolized stack frame by frame and
the child stays a live process throughout, measured at 27-34 s - and it is
evaluated once, before the death. So an abort it misses never unlocks the
parser, and the job reports only its own exit code.

The unconditional scan used to be the behaviour: 85deff3 deleted the
`<Fatal>` bash scans from `stress_tests.lib` and replaced them with this
row-gated Python parser. The sibling job never regressed -
`ClickHouseProc.check_fatal_messages_in_logs` greps `<Fatal>`, runs the same
`FuzzerLogParser.parse_failure` and reports, with no dependency on any other
row; `functional_tests.py` calls it on every run.

Keep the result of the grep that already runs and widen the one condition
that already gates the parser, so collected fatal evidence triggers it too.
`server_died` stays a separate signal: it is the only one for a silent death
(SIGKILL/OOM with nothing logged), which fatal evidence cannot see. Because
both triggers share that single gate, the parser still runs at most once per
job by construction.

The predicate is the collected content rather than the grep's exit code:
`rg` also exits non-zero when it did match but could not read some file of
the glob, which would drop exactly the crash being reported.

Measured on the seven observed shas, master included: `fatal.log` was
41-117 KB and named seven distinct real aborts, two of them recurrences of a
separately tracked logical error, while CIDB recorded none of them. A green
run's `fatal.log` is 0 bytes. Driven end-to-end against the real uploaded
log of one carrier, the job now reports
`Logical error: '... typeid(*this) == typeid(rhs)' (STID: 2508-2e0c)` with
the symbolized stack instead of `Test script failed`.

`upgrade_job.py` calls `run_stress_test`, so the Upgrade check inherits this.
The witness arm asserted the parsed row's name and info but nothing about the
stack-trace id, while FuzzerLogParser appends it by interpolation and
get_stack_trace_id has two reachable None paths (an empty stack trace, and no
DB:: frame surviving the DB::Exception strip). A None therefore becomes the
literal text "STID: None" in the row name with the arm still green, even though
the changelog entry promises the id.

Assert the shape rather than the value: a literal would couple the test to the
id's hash function and to ST_MAX_DEPTH, so an unrelated refactor of the id
scheme would redden the arm for the wrong reason. The id is satisfiable on this
fixture (2508-1573, from its two surviving frames), so this tightens a live
assertion rather than adding a new expectation.

Verified by patching get_stack_trace_id to return None: the arm fails on this
line alone and the other five arms stay green, and with the line removed that
same mutation passes, so nothing else in the suite was covering it. The four
pre-existing mutants keep their recorded reddening pattern.

Not added to the benign-fatal arm, which ends in the parser's Unknown error
path and carries no id by design.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: 1 major agreed and fixed, 3 nits noted, final gate clean

An independent cold review plus a second model reviewed this change against the ClickHouse review
skill, over two rounds. The final gate returned no findings. Every disposition below is backed by a
measurement I ran, not by prose.

❌ Agreed and fixed

The witness test did not pin the stack-trace id that the changelog entry promises.
FuzzerLogParser appends the id to the row name unconditionally by interpolation, and
get_stack_trace_id has two reachable None returns (an empty stack trace, or no DB:: frames
surviving the DB::Exception strip). Patching get_stack_trace_id to return None in memory made
the row name the literal Logical error: 'Digest does not match' (STID: None) while all three of
the arm's existing assertions still passed. The arm now also asserts a well-formed
(STID: ####-####).

Verified against the generator rather than assumed: get_stack_trace_id formats
f"{func_hash:04d}" and f"{st_hash:04x}", so every value it can produce matches the new pattern
(checked 0000-0000, 9999-ffff, 0001-00ff), while (STID: None), an empty id, a missing id and
a malformed id are all rejected. The shape is asserted rather than a literal value, so an unrelated
change to the id scheme cannot redden it for the wrong reason. A mutant pins it: forcing
get_stack_trace_id to None reddens only that arm while the other five stay green, and with that
mutant applied and the new assertion removed the arm passes again, so no pre-existing assertion
was quietly doing the work.

⚠️ Noted, not changed

The <Fatal> trigger is computed over clickhouse-server*.log while the parser then reads only
.err. logs.
A <Fatal> present only in a rotated or renamed non-.err. log could therefore
yield the parser's generic Unknown error rather than the assertion. Left as is: before this change
the outcome was total silence, and afterwards the worst case is a named failure row plus the
uploaded fatal.log, which is strictly better on every path. On the carriers checked, the abort is
present in clickhouse-server.err.log itself. ClickHouseProc.check_fatal_messages_in_logs closes
this by selecting the log that contains the hit; matching that is outside this change's scope.

The new row is not labelled as a merge blocker, while the equivalent rows on the functional-test
path are.
Pre-existing asymmetry, deliberately untouched here: this diff adds no label anywhere.
Changing merge-blocking semantics for every Stress test (*) job is a separate concern.

💡 Checked, no change needed

Blast radius of widening the trigger to any collected <Fatal>. Measured two ways independent
of the change's own evidence. First, an existing check runs the same predicate on the same job type:
No fatal messages in clickhouse-server.log greps <Fatal> in the stress server logs and, over the
last 30 days of Stress test (*) runs, is OK on 279 of 279 rows with no failures, 277 of them on
jobs that passed. Second, the one benign <Fatal> that is genuinely reachable on a healthy run is
the watchdog's Child process was terminated by signal 9 (KILL) banner, emitted because
clickhouse stop --force sends SIGKILL; every occurrence of that row in the same window sits on a
job that passed, because is_oom is set from that exact substring and the existing override flips
the job back to OK. That override is what the new OOM arm pins.

Session id: cron:clickhouse-review-slot-9:20260806-022400

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, on demand and not probabilistic. run_stress_test is driven with the docker run replaced by a real shell command writing the artifacts a failing job produces; the collected abort is discarded 100% of the time before the change.
b Root cause explained? Yes. fatal.log is written on every run and never read; crash attribution was gated on a test row named Server died, whose only writer is one early kill -0 probe that cannot see a dying server (the stack is written frame by frame over 27-34 s while the child stays live) and runs once, before the death.
c Fix matches root cause? Yes. It reads the evidence the job already collects and widens the single condition already gating the parser. No widened bound, no bumped timeout, no no-random-* tag, no defensive check masking anything upstream.
d Test intent preserved / new tests added? Six arms added to ci/tests/test_stress_job.py; all 17 pre-existing arms are untouched and still pass. Nothing was weakened or removed.
e Both directions demonstrated? Yes. Four of the six arms fail on pristine master and pass after; two are controls that are unchanged. Additionally the shipped code was driven against the real uploaded clickhouse-server.err.log of one carrier: before, only Test script failed; after, Logical error: '… typeid(*this) == typeid(rhs)' (STID: 2508-2e0c) with the stack.
f Fix is general across code paths? Yes. git grep '== "Server died"' returns exactly one hit, so this was the only row-name-gated crash parser in the tree. The other two FuzzerLogParser call sites are already unconditional: clickhouse_proc.py gates on log content, ast_fuzzer_job.py on its own liveness state. Nothing else to fix.
g Fix generalizes across inputs (params/datatypes/wrappers)? Arms cover the main server log, an sc1 replica log, a log whose only <Fatal> lines are benign, a clean log, and the OOM interaction; with no server-log directory the evidence defaults to false via the pre-existing exists() guard. The Upgrade check's different log naming (clickhouse-server.upgrade.log) was measured to match the shipped glob.
h Backward compatible? (maintainer-approved exception only) Not applicable: no setting, no serialization format, no user-visible behaviour, so no SettingsChangesHistory entry. Changelog category is CI Fix or Improvement.
i Invariants and contracts preserved? Yes. server_died keeps its meaning and remains the only signal for a silent death (pinned by an arm and by a mutant that gates on the new evidence alone). The parser block is not moved, re-indented or extracted; because both triggers share one gate it still runs at most once per job by construction. The is_oom override at the end of the job is unchanged and pinned by an arm.

Session id: cron:clickhouse-impl-slot-44:20260806-000900

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? The stress job already greps the server logs for into fatal.log but nothing read it: the abort parser was gated on a test row named Server died, written only by a single early liveness probe that cannot observe a dying server, so an abort it missed was reported as a bare Test script failed with no assertion or stack trace.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 6, 2026
@PedroTadim PedroTadim self-assigned this Aug 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d5c842e]

Summary: ❌

job_name test_name status info comment
Stress test (amd_msan) FAIL
Logical error: Sizes of nested column and null map of Nullable column are not equal after deserialization (null map size = A, nested column size = B) (STID: 6726-4d8b) FAIL cidb IGNORED

AI Review

Summary

This PR widens run_stress_test so the failure parser runs when fatal.log contains collected <Fatal> lines, not only when the runner synthesized Server died. After checking the current diff, the stress and upgrade runners, the logger configuration, the completed Praktika results on d5c842ea, and the prior review threads, I did not find a remaining correctness issue in the shipped change.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 6, 2026
Comment thread ci/jobs/stress_job.py Resolved
Comment thread ci/tests/test_stress_job.py Outdated
`process_results` must turn that malformed-row metadata into a
visible `Result` so investigators notice the file is corrupt.

The `run_stress_test` tests at the bottom cover a third flavour: a

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@groeneai you can remove this test addition altogether

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.

Done, removed in cb380a1. ci/tests/test_stress_job.py is now byte-identical to master and its 17 pre-existing arms are untouched; the PR is a single-file +5/-1 change to ci/jobs/stress_job.py. I moved the verification record into the PR description so nothing is lost.

One thing worth flagging so the decision is yours rather than mine: the widened condition now ships unpinned. I checked rather than assumed it, by reverting the gate to if server_died: and running the remaining suite, and all 17 tests stay green, so a later refactor can drop the crash_evidence branch without anything going red.

If you would like that covered, the smallest version I can offer is one arm plus one control, roughly 40 lines: a collected fatal log must be reported as a named failure, and a realistic clean log must stay green. Happy to leave it out entirely if you would rather keep this PR to the one condition.

@PedroTadim asked for this test addition to be removed
(ClickHouse#113608 (comment)).

Reverts ci/tests/test_stress_job.py to its state on master; the file is now
byte-identical to master and its 17 pre-existing arms are untouched. The
one-condition widening in ci/jobs/stress_job.py is unchanged.
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 6, 2026
@PedroTadim
PedroTadim enabled auto-merge August 6, 2026 13:42
Comment thread ci/jobs/stress_job.py Resolved
@PedroTadim
PedroTadim disabled auto-merge August 6, 2026 13:52
@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — cb380a1

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link I will post here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_tsan) / Logical error: Sizes of nested column and null map of Nullable column are not equal after deserialization (null map size = 1, nested column size = 0) (STID 6726-6444) not PR-caused: pre-existing trunk abort on the set-skip-index read path. Stack is SerializationNullable.cpp:178 <- MergeTreeIndexSet.cpp:129 <- MergeTreeIndices.cpp:138 <- MergeTreeIndexReader.cpp:143/167 <- MergeTreeDataSelectExecutor.cpp:2751 (filterMarksUsingIndex), reached here through optimizeUseAggregateProjection under EXPLAIN. This STID spans 7 distinct unrelated PRs across 4 stress flavours in 30 days (arm_tsan 3, amd_tsan 2, arm_asan_ubsan 1, arm_asan_ubsan+s3 1, 0 on master); the wider same-message family is 42 rows over 10 STIDs since 2026-06-15. This PR's whole diff is +5/-1 in ci/jobs/stress_job.py and touches no serialization or index code #112484 (mine, open) — it gates a skip index whose on-disk type is stale so the granule is never deserialized under the new type, rewriting the MergeTreeIndices.cpp frame this abort passes through
Build (arm_release) / Post Hooks not a test result, and the Build (arm_release) check itself is success (the hook is non-gating). build_profile_hook.py could not upload build-profile telemetry: Code: 241 ... would use 507.11 GiB ..., maximum: 29.80 GiB. OvercommitTracker decision: Query was selected to stop, surfaced as LogCluster query failed with code 500. The 8 warning lines come from select(), whose retries=8 default predates the fix below #113409 (external, merged 2026-08-06T00:05Z) — absent from the build that failed, so I merged master to pick it up

#113409 presence was probed per build rather than inferred from commit distance:
ci/jobs/scripts/log_cluster.py at cb380a12cacf7c7 is 11915 bytes with retries x4 and no
seek(0), while at that PR's merge commit and at current master it is 12697 bytes with
retries x7 and seek(0) present — the fix adds retries=8 to the INSERT calls, which this
build did not carry.

Merged master and pushed cb380a12cacf7c7 -> d5c842ea18181 (fast-forward, no force;
origin/master untouched, our diff still exactly +5/-1 in ci/jobs/stress_job.py). Fresh CI
is running on the new head and I will post its ledger separately.

Session id: cron:our-pr-ci-monitor:20260807-040000

@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d5c842ea1 with master 31081d9f0 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 16bd8e494; 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 690.17 MiB 687.14 MiB -3.03 MiB (-0.44%)

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

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

Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +8.5 s (+14%) in total before that adjustment.

Job report

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - d5c842e

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link I will post here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_msan) / Logical error: Sizes of nested column and null map of Nullable column are not equal after deserialization (STID 6726-4d8b) not PR-caused: pre-existing trunk abort on the skip-index read path. Frames are SerializationNullable.cpp:178 <- MergeTreeIndexSet.cpp:196 <- MergeTreeIndexReader.cpp:184 <- MergeTreeDataSelectExecutor.cpp:2696 (filterMarksUsingIndex), i.e. a granule deserialized under a type that does not match its bytes. This message spans 37 rows / 34 distinct unrelated PRs / 6 STIDs / 10 stress flavours in 30 days, and 0 on master, with 36 of the 37 carrying the filterMarksUsingIndex frame, so the frame rather than the STID is the family key. This PR's entire diff is +5/-1 in ci/jobs/stress_job.py and touches no serialization, index or MergeTree code #112484 (mine, open): it stops a skip index whose on-disk type is stale from being deserialized under the new type, rewriting the MergeTreeIndices.cpp layer this abort passes through

The Build (arm_release) / Post Hooks row from the previous head is resolved on this head:
after merging master to pick up #113409
(external, merged 2026-08-06T00:05Z), Build (arm_release) and its Post Hooks are both
success here, so the build-profile telemetry upload no longer fails. No owner row is owed for it.

Everything else on this head is green: Finish Workflow, Config Workflow, Mergeable Check,
Style check, CI Tests, Code Review, all 13 Build (*), Upgrade check (amd_release)
and the other 9 Stress test (*) flavours.

Session id: cron:our-pr-ci-monitor:20260807-103000

Blargian pushed a commit to Blargian/ClickHouse that referenced this pull request Aug 13, 2026
On ASan builds the server's forced-shutdown branch calls safeExit(0), which
calls __lsan_do_leak_check(). That branch is taken precisely because connection
handlers and refresh tasks missed the drain timeout, so LSan stops the world and
classifies chunks those threads are still using. The reports are unattributable
by construction.

Two were reported on 2026-08-08 as a uniqExact hash-table "direct leak" (2 MiB
on ClickHouse#112846, 4 MiB on ClickHouse#101264). Both are a single allocation with zero indirect
leaks, and the two green asan_ubsan jobs on the same commit of ClickHouse#112846 also
force-shutdown with connections live while reporting nothing, so neither is an
aggregation bug. Since ClickHouse#113608 made previously unattributed sanitizer reports
nameable, these compete with real leaks in every stress report.

safeExit gets a defaulted run_leak_check parameter, so every existing caller
keeps today's behavior, and the two force-exit branches reached while handler
threads are still running pass false. A stderr line records that coverage was
skipped rather than passed; its wording avoids "<Name>Sanitizer:" so that CI log
parsing does not read it as a failure.

Keeper's identical-looking branch is left alone on purpose: it calls
server_pool.joinAll() first, so no handler is still running there and this
report class cannot arise. The client's SIGINT/SIGQUIT handler keeps the
default. Clean shutdowns never reach safeExit, so they keep full leak coverage
through the ordinary at-exit check.

Two mechanisms that look plausible were measured and rejected. __lsan_disable()
does not suppress the check: it is an allocation-time per-thread flag, and a
probe still reported the leak. Omitting the call does not re-arm the at-exit
check either: that check is installed with Atexit(), which _exit() bypasses, so
omission can only remove reports, never add any.

Co-Authored-By: Claude Fable 5 <[email protected]>
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 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