Skip to content

Scan the stress run's own logs when the post-stress restart fails - #121125

Open
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:ci-stress-scan-logs-on-restart-failure
Open

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:ci-stress-scan-logs-on-restart-failure

Conversation

@groeneai

@groeneai groeneai commented Sep 20, 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

In 30 days 199 stress jobs (158 PRs, 22 on true master, 12 flavours) failed their post-stress
restart. stress_runner.sh:356 was start_server 10 600 || { echo ...; exit 1; }; that explicit
exit 1 precedes :368 check_logs_for_critical_errors, so on all 199 the S3_ERROR No such key thrown and Lost forever for SharedMergeTree detectors and dmesg -T > /test_output/dmesg.log
never ran. <Fatal> and signal-9 detection is unaffected: stress_job.py:379-393 greps the same
logs. What is lost is those two data-loss detectors and dmesg.log. Both greps read
clickhouse-server*.log (renamed there at :343), so neither needs a server.

It goes in this caller, not start_server: the function is an end-of-run step, and :356 is the
only such site.

One behavioural consequence, up front. dmesg.log is the kernel-side input to this job's OOM
classifier (stress_job.py:372-377), and :486-488 already turns an OOM-attributed failure into
OK. It is inoperative on this path today, so restoring it will make some currently-red stress jobs
read as OK; its grep matches any container process, not only the server. If they should stay red
instead, that is a small classifier change I can make here; your call.

collect_query_and_trace_logs stays out: it drives clickhouse-local through the same unreachable
object storage, so query_log/trace_log/metric_log stay missing. The three earlier
start_server sites (after 7 start attempts: 10 rows / 1 PR) and upgrade_runner.sh are unchanged.

Validated in the real CI image against the real stress_tests.lib: master emits only the
start-failure row and no dmesg.log; the patch adds both detector rows and the artifact, still
reporting the start failure; deleting the call reverts the result exactly. 3.7 s on a 5 GiB log. In
the reported run the scan would have found nothing; the defect is that it runs on none of the 199.

Related: #119808
Provenance: Stress test (arm_tsan) on PR #110105 @ 0da1b2081
(report).


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

stress_runner.sh:356 was `start_server 10 600 || { echo ...; exit 1; }`. That explicit exit
terminates the run, and every step that reads the stress phase's own logs comes after it:
:358 check_server_start, :368 check_logs_for_critical_errors, :372 collect_query_and_trace_logs.
The consequential one is check_logs_for_critical_errors (stress_tests.lib:404-430). It is the only
scan carrying the two data-loss detectors (`Code: 499 ... The specified key does not exist` over
clickhouse-server*.log, and `it is lost forever` with SharedMergeTreePartCheckThread) and
`dmesg -T > /test_output/dmesg.log`. Fatal-level detection is not affected: stress_job.py:379-393
greps the same glob from the Python side for `<Fatal>` and for signal 9, on this path too. Neither
restored grep needs a running server: both read /var/log/clickhouse-server/clickhouse-server*.log,
and the stress log was already renamed into that glob at :343. dmesg needs no server at all.

CIDB, 30 days, stress jobs, test_name = 'Cannot start clickhouse-server': the string
`after 11 start attempts` identifies this call site uniquely, because max_attempt=${1:-6} and only
this caller passes 10. It has 199 rows over 158 distinct pull_request_number values, 22 of them on
true master, spread across 12 stress flavours. All 199 discarded the scan, and with it dmesg.log:
a successful arm_tsan run publishes that file, a run that failed this way publishes no dmesg.log at
all. The server logs themselves are still uploaded on this path, because process_results attaches
every file in the mounted server-log directory (stress_job.py:213-216), so the stress phase's log
ships as clickhouse-server.stress.log; only the :369 rename to clickhouse-server.final.log is
skipped.

Losing dmesg.log also disables a policy the job already has. stress_job.py:372-377 computes is_oom
from that file and :486-488 turns an OOM-attributed failure into OK. Without the file the classifier
keeps only its server-log input, which fires exclusively when the server's own child was signal-9'd,
so a container-cgroup OOM that killed any other process is invisible and the job reads as a
ClickHouse failure.

Why `if ! ...; then` rather than `|| { ...; }`: the block now runs several statements and ends in
`exit 1`, and the `if` form keeps start_server's non-zero return from tripping errexit exactly as the
`||` form did. Why `||:` on the call: on the failure path a collection error must not replace the
failure the job is reporting, and it keeps errexit suspended for the whole function body, so one
failing collection step cannot skip the rest. Measured: with a failure injected before `dmesg -T` in
a copy of the lib, dmesg.log is still written with the `||:` and absent without it.

check_server_start is deliberately not added here, because on this path the server did not start and
it would emit a false `Server failed to start` duplicate of the row already reported.
collect_query_and_trace_logs is not added either, because it runs clickhouse-local through the same
config whose object-storage disk is unreachable in exactly this scenario, so it could hang and turn a
fast red into a job timeout. That leaves query_log, trace_log, metric_log and
aggregated_zookeeper_log missing on this path, deliberately. The three earlier start_server sites
report `after 7 start attempts`, 10 rows / 1 PR in the same 30 days, and are left alone.

Validated in the real clickhouse/stateless-test image against the real stress_tests.lib, with the
region executed verbatim out of the script and only the server faked: without the change only the
start-failure row appears and dmesg.log is absent; with it both detector rows and both artifacts
appear while the start failure is still reported; a clean log yields the `No lost s3 keys` and
`No SharedMergeTree lost forever` OK variants, so nothing is manufactured; deleting the restored call
reverts rows and artifacts exactly to master's; the success path is identical on both trees for a
server that comes up on attempt 1 and on attempt 3. The restored scan costs 3.7 s on a 5.0 GiB /
33.2 M-line log, of which 1.6 s is s3_key_lifecycle.py in its worst case.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 20, 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; 0 findings) plus two independent cold
reads of the diff, by two different reviewers. Five findings came from the cold reads, all agreed and
fixed before publication; none changed the code, which is byte-identical across both rounds. The
second round re-verified every fix in the current text instead of closing it on assertion.

# Sev Finding Verdict Evidence / action
1 ⚠️ "the only scan of the stress run's own log" is a false universal claim AGREE, fixed before publication stress_job.py:379-393 greps the same clickhouse-server*.log glob on this same failure path for <Fatal> and signal-9, both after Shell.run() at :364, so crash detection over the stress log is not lost. The text now claims only what is lost: the two data-loss detectors and dmesg.log
2 ⚠️ the "none of the six artifacts" control overstated the loss AGREE, fixed before publication One of the six is restored (dmesg.log); four stay missing because collect_query_and_trace_logs is deliberately not called here; clickhouse-server.final.log was never lost, since process_results:213-216 attaches every server log unconditionally, so the stress log ships as clickhouse-server.stress.log and only the :369 rename is skipped. Both texts now say this
3 💡 "exits under set -e" misattributed the termination AGREE, fixed before publication The pre-patch line ends in an explicit exit 1, which terminates with or without errexit; set -e is load-bearing for the ||:, not for the exit
4 💡 the layering rationale was unstated AGREE, fixed in the body The call sits in this caller because the function is an end-of-run step and :356 is the only start_server site that is the end of a run. Re-tested as a universal in round 2: :63/:94/:325 and upgrade_runner.sh:138 are pre-stress, and upgrade_runner.sh:334 does not discard its own scan, since check_allow_list returns 0 when its allow-listed error is absent and the script continues to :668
5 💡 the Related: precedent link did not render AGREE, fixed in the body It sat inside the template's HTML comment; #119808 is now linked visibly

Also checked and found sound, so not raised: the if ! form preserves start_server's errexit
semantics exactly as the || form did (both suspend errexit, and the suspension propagates into the
called function body); the ||: is load-bearing rather than decoration; dmesg availability is proven
by the unconditional dmesg --clear at :9 under set -e; s3_key_lifecycle.py reads files only, so
it is safe with no server running; the restored scan cannot hang, unlike collect_query_and_trace_logs,
which drives clickhouse-local through the same unreachable object-storage config; the added rows
cannot turn a green job red, since the path ends in an unconditional exit 1, and cannot suppress the
OOM-to-OK conversion either, since :486-488 tests the aggregate result; and the detectors see no
file the success path does not already show them, so no false-positive surface is added. The population
was re-measured independently from play.clickhouse.com in the second round and reproduced exactly:
199 rows, 158 distinct pull requests, 22 on true master, 12 flavours, one row per job run.

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

Session id: cron:clickhouse-review-slot-8:20260920-015700

@clickhouse-gh clickhouse-gh Bot closed this Sep 20, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 20, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d8d2fdd]

Summary: ❌

job_name test_name status info comment
Stress test (amd_debug) FAIL
Logical error: Pipeline stuck. Current state: (STID: 3833-2f1a) FAIL cidb

AI Review

Summary

This PR restores the post-stress log scan on the failed final-restart path by calling check_logs_for_critical_errors before exiting. The shell change itself is small, but it also changes job-level classification through dmesg.log, and in its current form it can silently flip a real restart failure to green.

Findings

⚠️ Majors

  • [tests/docker_scripts/stress_runner.sh:358] Restoring check_logs_for_critical_errors here also restores /test_output/dmesg.log. ci/jobs/stress_job.py:372-488 treats any OOM marker in that file as "allowed in stress tests" and force-sets the whole job to OK, even when test_results.tsv now contains Cannot start clickhouse-server, S3_ERROR No such key thrown, or Lost forever for SharedMergeTree. That means the diagnostics this PR is trying to recover can still disappear behind a green check if the same run also logged an unrelated kernel OOM.
    Suggested fix: either collect dmesg.log here via a path that does not participate in the OOM override, or tighten the override in stress_job.py so explicit restart/data-loss failures stay red.
Final Verdict

Changes requested: avoid turning failed post-stress restarts into OK merely because restoring dmesg.log re-enables the broad OOM override.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 20, 2026
start_server 10 600 || { echo "Failed to start server"; exit 1; }
if ! start_server 10 600; then
echo "Failed to start server"
check_logs_for_critical_errors ||:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Restoring check_logs_for_critical_errors here also restores /test_output/dmesg.log, and that is not a pure artifact change. In ci/jobs/stress_job.py:372-488, any OOM marker in dmesg.log sets is_oom = True and then force-sets the whole job to OK, even if test_results.tsv now contains Cannot start clickhouse-server, S3_ERROR No such key thrown, or Lost forever for SharedMergeTree.

That means this failed-restart path can still disappear behind a green check whenever the same run also logged an unrelated kernel OOM. If the goal is to recover these diagnostics, the dmesg.log collection here needs to be decoupled from the broad OOM override, or the override needs to be tightened so these explicit restart/data-loss failures stay red.

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.

Mechanism confirmed: stress_job.py:372-376 feeds dmesg.log into is_oom, and :486-488 then forces the whole job to OK. The description flags that consequence up front, and it is a fork rather than an oversight: the job's existing policy treats a kernel OOM as not a ClickHouse failure, while this finding says a run that produced no test signal must stay red. Three measurements (play.clickhouse.com, check_name LIKE 'Stress test%', 90 days):

  1. Restoring dmesg.log widens the input, it does not open the channel: :380-384 already sets is_oom from <Fatal> Application: Child process was terminated by signal 9 over /var/log/clickhouse-server/clickhouse-server*.log, mounted at :194 and populated here (stress_runner.sh:343 renames the stress log into that glob before the restart).
  2. That channel has never masked this row: test_name = 'Cannot start clickhouse-server' in stress jobs is 1249 rows over 1155 commits, every one with check_status = failure.
  3. The suggested tightening would have changed nothing observed: of the 169 runs the allowance converted to OK (0.055% of 308373), 0 carry Cannot start clickhouse-server, S3_ERROR No such key thrown or Lost forever for SharedMergeTree. What it masks is Possible deadlock on shutdown (104), Hung check failed (40), Server unresponsive: memory limit exceeded (32) and signal-9 rows, the family it was written for.

One caveat against my own numbers: 0.055% is not an independent rate on this path, since container memory pressure plausibly causes both the kernel OOM and the dead emulator that fails the restart, and that correlated case is the one worth ruling on. It is job-level classification for every stress flavour, so I would rather not decide it myself: the guard is two lines at :486 (skip the override when one of those rows is present), and I will add it here if that is the call.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - d8d2fdd

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
Stress test (amd_debug) / Logical error: Pipeline stuck. Current state: (STID: 3833-2f1a) Not from this PR, which only changes tests/docker_scripts/stress_runner.sh. The full 1793-node digraph from the job's clickhouse-server.err.log is a parallel full sorting merge join wedge: ScatterByPartitionTransform 18 in PortFull feeding PartialSortingTransform/MergeSortingTransform into MergeJoinTransform 16 PortFull and 32 NeedData, with 64 AggregatingTransform and 16 Concat stuck in NeedData. It carries 0 BufferedShardByHashTransform, 0 MergingSortedTransform, 0 UnmarshallBlocksTransform and 0 SortChunksBySequenceNumber nodes, so it is neither of the two shapes this STID has previously been attributed to. Both candidate fixes are merged ancestors of this head, 2741fd7987b4 of #113190 and the merge of #106251 (git merge-base --is-ancestor rc 0 for both), so neither can be named as the owner a fix task is created (investigating at full effort, fixing PR link to follow on this PR)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20260920-160237

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the STID 3833-2f1a Pipeline stuck row of the CI finish ledger for d8d2fdd31141bcfecd558d690da6d35f21c98c31: #121227

vanchaklar pushed a commit to vanchaklar/ClickHouse that referenced this pull request Oct 1, 2026
…f its outputs

narrowPipe glues independent streams behind a ConcatProcessor to keep the
number of open sources down. A ConcatProcessor demands its inputs strictly
one at a time: it calls setNeeded() on the current input only, and advances
when that input finishes. A ScatterByPartitionTransform has the opposite
requirement: pushOutputChunks() leaves all_outputs_processed false for any
non-finished output with a non-empty share whose canPush() is false, and
prepare() then returns PortFull, so the scatter cannot take its next chunk
until every output has accepted a share of the current one.

Put one above the other and they deadlock. The lanes feeding the Concat's
later inputs are never demanded, so their prepare() is never called at all
(state NotStarted); the scatter cannot push those shares and parks in
PortFull, where it can neither pull nor finish; so the lane the Concat is
waiting on never finishes either, and the Concat never advances to the next
input. PipelineExecutor::finalizeExecution then throws Pipeline stuck.

This is reachable without any unusual setting beyond the join algorithm:
ReadFromMerge::readFromMerge narrows the streams of the tables it reads, so
a Merge table or merge() over a view whose body contains a sharded merge
join hits it, and max_streams_for_union_step reaches it through UnionStep.
A window function with PARTITION BY builds the same fan-out, though the
Resize the window step places above it keeps that path awake in practice.

Decline to narrow such a pipe. narrowPipe returns early when any processor
in the pipe answers the new IProcessor::requiresAllOutputsPushable(),
overridden by the three processors carrying that contract:
ScatterByPartitionTransform, CopyTransform (the GROUPING SETS copier, with
byte-identical accounting in prepareGenerate) and ForkProcessor (identical
accounting, no users today, so the override states the contract).
ResizeProcessor moves data between any ready pair and has no such contract.

Narrowing is a memory and file-handle optimization, never a correctness
requirement, and both call sites already suppress it conditionally
(should_not_narrow in StorageMerge, allow_narrowing in UnionStep), so this
is a third reason in the shape the code already has; the pipeline simply
stays wide, which is what the same query already gets when either existing
suppression fires. Buffering the un-pushable shares inside the scatter was
rejected as unbounded memory, the design already refused for the
BufferedShardByHashTransform family; making Concat demand all of its inputs
would delete the optimization it exists for.

The comment in optimizeJoinByShards that excluded the full-sort path from
this deadlock class is corrected: the drain it relies on only helps a lane
that some consumer has already demanded.

Found by CI on ClickHouse#121125, Stress test (amd_debug) at commit
d8d2fdd.

Co-Authored-By: Claude Opus 5 <[email protected]>

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-testing Test content only (no production code). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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