Skip to content

Scale the lldb stacktrace budget by build flavor, keep timed-out dumps - #114565

Merged
alexey-milovidov merged 14 commits into
ClickHouse:masterfrom
groeneai:groeneai/lldb-stacktrace-budget-by-build-flavor
Sep 3, 2026
Merged

alexey-milovidov merged 14 commits into
ClickHouse:masterfrom
groeneai:groeneai/lldb-stacktrace-budget-by-build-flavor

Conversation

@groeneai

@groeneai groeneai commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #109455

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

clickhouse-test collects C-side backtraces with lldb -o 'thread backtrace all'
under a hard 30s timeout. On a debug server the attach needs longer, the timeout
fires, and the partial dump was discarded too, leaving no C stacks for the wedged
process. CIDB, 90 days: 181 suspiciously small stacktraces rows over 118 PRs, 80
timed out after 30 seconds over 59 PRs, 78 carrying both. Two causes:

  1. The 30s budget assumed the backtrace "should finish in seconds even on a debug
    build". Measured on a 174-thread debug server in the CI stress image, a healthy
    attach takes 44-118s and returns a complete dump: the cost is symbolization.
  2. shell_get_output honoured keep_output_on_error only for
    CalledProcessError; TimeoutExpired is not a subclass, so a timeout returned
    "", discarding what lldb wrote.

The per-PID budget now scales with the build flavor, reusing the slow_build
predicate (debug, TSan/ASan/UBSan/MSan, coverage) that MergeTreeSettingsRandomizer
uses: 120s on a slow build, 30s unchanged on release (Stress test (arm_debug) is 51
of those 80 rows, so the driver is debug). The
flavor comes from args.build_flags, not the module globals a spawned worker
resets; the startup-failure caller runs before those flags exist, so there it is
read from the binary via clickhouse local, like is_asan_build. A
separate aggregate ceiling bounds the pid loop and reports skipped pids. The
per-test timeout handler keeps 30s, running inside its own fired alarm. A
timed-out dump is now kept, decoded and marked truncated.

Validated against a live debug server with real lldb: before, 30.8s and a 0-byte
dump called suspiciously small; after, 63.6s and 834KB with 348 headers.
Forcing the budget below the attach cost keeps 48.7KB where master keeps 0. Reverting
each change reddened one of twelve arms, run as a throwaway script since master
no longer carries the ci/tests file that held them.


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

Version info

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

get_stacktraces_from_lldb ran `lldb --batch -p <pid> -o 'thread backtrace all'`
under a hard 30s timeout, justified by a comment asserting the backtrace "should
finish in seconds even on a debug build with many threads; anything beyond that
means lldb itself is wedged". That premise does not hold. Measured against a live
174-thread debug server inside clickhouse/stress-test (the CI image, 8 CPUs, no
debuginfod), a healthy attach takes 44-118s, exits 0, and returns a complete
symbolized dump: the cost is the debug binary's unwind and symbol work, not a
wedge. The same measurement on the fleet host reported 474s, but the 6-thread
watchdog took 467s there too, which exposed it as network symbol fetching
(DEBUGINFOD_URLS set); with external lookup off the same attach took 21s. Any
budget derived from the host figure would be about 10x too large, so every number
here comes from the CI image.

A second, independent defect turned each timeout into total data loss.
shell_get_output honoured keep_output_on_error only inside
`except subprocess.CalledProcessError`, and subprocess.TimeoutExpired is not a
subclass of it, so a timeout reached the generic handler and returned "".
print_c_stacktraces then saw len(bt) < 1000 and printed "Got suspiciously small
stacktraces from <pid>:" with nothing after it. In 90 days CIDB carries 181
`suspiciously small stacktraces` rows over 118 PRs and 80 `timed out after 30
seconds` rows over 59 PRs, 78 rows carrying both, so the reports of a wedged
server routinely have no C stacks at all.

The per-PID budget now depends on the build flavor, reusing the slow_build
predicate (debug, any sanitizer, coverage) that
MergeTreeSettingsRandomizer.get_random_settings already uses for the same reason:
120s on a slow build, 30s unchanged on release. It is not sanitizer-specific;
Stress test (arm_debug) accounts for 51 of those 80 timeout rows, against 8 for
all tsan/msan checks combined. The flavor is derived from args.build_flags and
passed explicitly rather than read from the module-level RELEASE_NON_SANITIZED /
SANITIZED globals, because clickhouse-test selects the "spawn" start method when
CHECK_NAME contains "aarch" and a spawned worker re-imports the module with those
globals back at False while args is transferred intact. A globals-based budget
would therefore apply the release value on exactly the platform this fixes, while
passing locally under fork. args.build_flags is absent on the startup-failure
path, which calls print_c_stacktraces before collect_build_flags runs, so a
missing flag set keeps the 30s budget instead of guessing or paying for a binary
probe on an abort path.

The pid loop can span up to 20 server processes, so a per-PID budget alone does
not bound it. An aggregate ceiling now does, and it reports how many pids were
skipped rather than truncating silently. The two call-site groups get different
pairs. The per-test timeout handler runs from a fired one-shot signal.alarm, which
cannot bound work inside its own handler, and what remains of the job's outer
timeout has to cover print_sql_stacktraces and stop_tests as well: with the
default --timeout 600 the alarm is int(600*1.1)+60 = 720s inside a 900s outer
margin, and print_sql_stacktraces can cost 40s, leaving about 140s. That site
therefore keeps today's 30s per PID with a new 60s aggregate ceiling, so it can
only get safer. The abort paths (server died, hung check, startup failure) have no
alarm pending and are additionally bounded outside the harness by the stress
runner's own 600s wait, so they take the flavor budget with a 120s ceiling. No
change to ci/jobs/functional_tests.py.

On timeout the collected output is now kept. TimeoutExpired.output is bytes even
when subprocess.run is given text=True, so it is decoded with the same
errors="replace" policy as the call; returning it raw would violate
shell_get_output's -> str contract, render the b'...' form with escaped newlines,
and inflate len(bt) enough for an unreadable blob to pass the size guard. A
truncation marker is appended and print_c_stacktraces no longer announces such a
dump as the full backtrace. Killing a live attach at 10s and 20s leaves 48.7KB and
175 thread headers of usable real-server backtrace, all of which master discards.
The len(bt) >= 1000 guard is unchanged: it still rejects the 93-byte "attach
failed: No such process" output, and a rescued dump passes it on merit.

Seven tests in ci/tests/test_print_stacktraces.py cover the budget per flavor, the
post-spawn globals state, the missing-flags fallback, the aggregate deadline and
its skip report, the tight pair at the timeout handler, the rescued dump with a
matched control on the CalledProcessError path, and the partial-versus-full label.
Each of the seven changes, reverted individually, reddens at least one of them.
End to end against a live debug server: before, 30.8s and a 0-byte dump reported
as suspiciously small; after, 63.6s and 834KB with 348 thread headers and 448 DB::
frames.

The 30s cap was introduced in d45aa25 ("cap gdb stacktrace dump at 30s");
this corrects its premise rather than its intent, since a wedged debugger is still
bounded.
Each block now states only the local invariant, within three lines: what the
budget bounds, why the timeout branch is separate, why the flavor comes from args
rather than the globals, and that the skipped pids are named. The measurements,
the CIDB counts and the derivation of the numbers live in the previous commit
message, where a reader who wants them can find them without carrying them past
every future read of these lines.
… budget

The aggregate ceiling promises to bound the whole pid loop, so it has to be
read from a clock that only moves forward. time.time() is settable: a backward
step inflates what is left and lets the loop run past the ceiling across up to
20 processes, a forward step skips processes that still had budget. The file
already names this defect class where args.stop_time is computed.

The second half is test-only. No test failed if print_c_stacktraces stopped
honouring an explicitly passed per_pid_timeout: three of the new arms pass None,
one reads the call site's source text, and the aggregate arm's own 2s ceiling
clamps both candidate values to the same observable number. So the per-test
timeout handler could silently take the 120s flavor budget where 30s was
deliberately budgeted, since that handler runs inside its own fired alarm and
only the job's outer timeout is left to bound it. The new arm passes a
total_timeout larger than the per-PID value so the clamp cannot mask it.
@groeneai

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

Two review rounds by a reviewer that does not author, each preceded by an
independent cold read of the resulting code, then an independent second-model
gate. Round 1: 2 agreed majors, both fixed below. Round 2 on the fix delta:
gate findings 0, own findings 1 nit.

Round 1: agreed and fixed

❌ The aggregate lldb ceiling was built on a settable clock. print_c_stacktraces
computed deadline = time() + total_timeout, so it bounded wall-clock rather than
elapsed time: a backward step inflates what is left and the pid loop can run past
the ceiling across up to 20 processes, a forward step skips processes that still
had budget. This is the change's own contract (its docstring states the ceiling
bounds the whole loop), and tests/clickhouse-test already names this defect class
where args.stop_time is computed. Fixed: the deadline and the remaining budget are
read from monotonic(). The nine other wall-clock deadlines in the file are
pre-existing and deliberately untouched.

❌ No test pinned an explicitly passed per-PID budget. Dropping the
if per_pid_timeout is None guard, so the flavor value is always used, left all
five budget tests green: three pass None, one asserts on the call site's source
text, and the aggregate test's own 2s ceiling clamps both candidate values to the
same observable number. So the per-test timeout handler could silently take the
120s flavor budget where 30s was deliberately budgeted. Fixed with one arm whose
total_timeout is the larger constant, so the clamp cannot mask it. Test-only: the
code was correct, the oracle was blind.

Round 1: disagreed, with evidence

⚠️ A real-lldb transcript was requested. It exists; the gate reviews cold and
cannot read the internal evidence file. All three requested arms were recorded
against real lldb 21.1.8 in the CI stress image: healthy attaches at 43.2s and
63.6s returning complete dumps, against 30.8s and 31.2s pre-fix with a 0-byte dump
reported as suspiciously small, plus forced 10s and 20s kill points with a matched
control keeping 48.7KB and 175 thread headers where master keeps nothing. Every arm
asserts the server is alive afterwards. The suggested remedy was also rejected:
ci/tests/ runs on a small ARM runner against a release server, so a real-lldb
assertion there would be unavailable and flaky, which is why the pre-existing
live-server test deliberately does not assert attach success.

Noted, not blocking

💡 The remaining budget is only tested for <= 0, so a process reached with a
fraction of a second left is still attached and reports "suspiciously small"
rather than the clearer out-of-budget message. The ceiling is still respected and
the server is untouched; a floor constant would cost more than the one line of
wording it buys.

💡 Truncation is detected by substring match, so a dump that itself contained the
marker text would be labelled partial. The failure direction is conservative: a
complete dump can be called partial, never the reverse.

Session id: cron:clickhouse-review-self-slot-58:20260813-004300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. print_c_stacktraces against a live 174-thread debug server with real lldb 21.1.8 inside clickhouse/stress-test:7d477b530f3420941a87_amd (the CI image; no debuginfod, so no host symbol-fetch inflation). Pre-fix it printed Got suspiciously small stacktraces from 27: with a 0-byte c_stacktraces.log on every run.
b Root cause explained? Yes, two independent causes. (1) The 30s budget was justified by a comment asserting the backtrace finishes "in seconds even on a debug build"; measured, a healthy attach takes 44-118s (rc=0, complete symbolized dump), so the cost is unwind and symbol work, not a wedged debugger. (2) shell_get_output honoured keep_output_on_error only inside except CalledProcessError, and TimeoutExpired is not a subclass of it (issubclass(...) is False), so a timeout fell to the generic handler and returned "".
c Fix matches root cause? Yes, each half in the layer that owns it: the budget in the lldb collector, the output rescue in shell_get_output. Not a band-aid: the cap still fires (at a budget the healthy case can meet), and the len(bt) >= 1000 guard is unchanged so a genuine attach failure (error: attach failed: No such process, 93 bytes) is still rejected.
d Test intent preserved / new tests added? 9 new tests in ci/tests/test_print_stacktraces.py. No existing test weakened; the only edit to existing test code is an opt-out parameter on the live-server precondition helper, whose default is unchanged.
e Both directions demonstrated? Yes. End to end, same server and lldb: pre-fix 30.8s / 0 bytes / 0 thread headers; post-fix 63.6s / 834361 bytes / 348 thread headers / 448 DB:: frames. For cause (2) in isolation, with a matched control at an identical 10s and 20s kill point: master keeps 0 bytes, this change keeps 48700 bytes and 175 thread headers. Plus a 9-arm mutation matrix: each of the nine changes, reverted individually, reddens at least one test.
f Fix is general across code paths? Carriers enumerated. get_stacktraces_from_lldb fixed; the single keep_output_on_error=True caller fixed (grepped: exactly one); the Darwin sudo branch takes the same timeout kwarg with no Darwin-only assumption; the replica loop (1-20 pids in CIDB) is bounded by the new aggregate deadline; the ASan early-return is untouched. get_stacktraces_from_clickhouse(args, timeout=30) is deliberately unchanged: it runs only when the server answers (print_sql_stacktraces gates on check_server_liveness), it does not pass keep_output_on_error, and it queries system.stack_trace instead of unwinding a debug binary, so neither cause applies.
g Fix generalizes across inputs (params/datatypes/wrappers)? Budget derivation asserted for every flavor individually: release, debug, tsan, msan, ubsan, coverage; plus the missing-build_flags shape (the startup-failure caller runs before collect_build_flags), plus the post-spawn globals state (clickhouse-test selects spawn when CHECK_NAME contains aarch, which resets module globals while args survives, and arm_debug is the dominant source of these timeouts). Loop breadth covered at 1 and 4 pids with the deadline exhausted mid-loop.
h Backward compatible? (maintainer-approved exception only) Yes. Test harness only: no server code, no setting, no SettingsChangesHistory entry, no serialization format, nothing user-visible. Both new parameters are keyword-with-default, so every existing caller is unchanged, and release-build behaviour is byte-identical at 30s.
i Invariants and contracts preserved? shell_get_output's -> str annotation now holds on the timeout path too: TimeoutExpired.output is bytes even under text=True, so it is decoded with the call's own errors="replace" policy rather than returned raw (asserted by isinstance(out, str) and by the absence of the b'...' rendering, which would also have inflated len(bt) past the size guard with an unreadable blob). Its no-flag contract is unchanged (still "", reason still to stderr). print_c_stacktraces still returns None, still short-circuits under ASan, still writes one headed block per pid, and now states truncation instead of announcing a partial dump as full. The aggregate deadline bounds elapsed time (read from monotonic(), so a settable-clock step cannot make the loop overrun the ceiling it advertises) and reports how many pids were skipped rather than truncating silently.

Session id: cron:clickhouse-impl-self-slot-57:20260812-181300

@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ff43a26]

Summary: ✅


AI Review

Summary

This PR makes clickhouse-test keep partial lldb output on timeout and raises the per-process lldb budget on slow builds, which addresses the original 30 s truncation problem. The timeout-rescue path looks sound, but two diagnostic regressions are still present in print_c_stacktraces: the startup-failure/no-process path still burns a pointless 60 s binary probe before printing the only useful message, and the new default aggregate ceiling can spend the entire slow-build budget on the first server process and skip later replicas.

Missing context / blind spots
  • ⚠️ The current ff43a266 CI run was still in progress on 2026-08-30 while I reviewed this: Fast test and Style check had finished, but the debug/sanitizer build matrix was still queued. Final results from those jobs would close that gap.
Findings

⚠️ Majors

  • [tests/clickhouse-test:1380] print_c_stacktraces still probes the binary for ASan before it knows whether any clickhouse-server process exists. On the main -> check_server_started -> print_c_stacktraces startup-failure path, args.build_flags is still unset at [tests/clickhouse-test:6042], so is_asan_build shells out to clickhouse local with a 60 s timeout. If the server has already exited, the function then hits the not all_pids return at lines 1394-1406 and throws that ASan verdict away. The result is an extra 60 s delay before the only actionable Unable to locate any ClickHouse server process message on an already-failing startup job.
    Suggested fix: snapshot all_pids first and return on the empty case before calling is_asan_build; if at least one server PID exists, keep the ASan guard ahead of the actual lldb attach.

  • [tests/clickhouse-test:1361] The default total_timeout is now the same 120 s value that lldb_timeout_for_build gives each slow-build PID. In the multi-server paths that call print_c_stacktraces(args) with defaults, the first debug/TSan/coverage server can therefore consume the whole loop budget, leaving later replicas truncated or skipped at lines 1413-1422. That breaks the “collect every server process” contract of get_all_server_pids in exactly the clustered cases where the stuck replica is not guaranteed to be PID 0; the built-in test_cluster_database_replicated config already runs three server processes.
    Suggested fix: derive the abort-path aggregate budget from len(all_pids) after the process-table snapshot, or let those callers pass a ceiling that budgets at least one full slow-build attach per discovered server up to the surrounding job timeout.

Final Verdict

Changes requested.

LLVM Coverage Report

⚠️ No coverage measurement for commit ff43a26: no coverable C/C++ source files changed (contrib/ is excluded from coverage).

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

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this? The lldb attach in clickhouse-test ran under a hard 30s timeout, but a healthy attach to a debug server measures 44 to 118s in the CI stress image, and a timed-out dump was then discarded entirely because keep_output_on_error did not cover TimeoutExpired, so the report kept no C stacks at all.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 13, 2026
Comment thread tests/clickhouse-test Resolved
The startup-failure caller in main() runs print_c_stacktraces before
collect_build_flags assigns args.build_flags, so the flavor lookup had no
flags and kept the 30s release budget on exactly the startup-hung case
this change exists to improve.

CIDB confirms the path is live rather than theoretical: of the 7 rows in
90 days carrying both "timed out after 30 seconds" and "Cannot execute
'SELECT 1' query", three show the startup message immediately followed by
"Collecting C stacktraces", on Stress test (amd_debug) and (arm_debug) --
i.e. a debug server whose only preserved dump was cut off at 30s.

Read the flavor from the binary via clickhouse local instead, the same
server-independent route is_asan_build already takes when the flags are
missing, querying the same three signals collect_build_flags derives
(BUILD_TYPE=Debug, WITH_COVERAGE, -fsanitize=). An unreadable or
unparseable result keeps the tighter budget, so an already-failing run
cannot be made worse by the probe.

Measured on real binaries: debug snapshot -> 120s, official 26.7 release
-> 30s, unreadable path -> 30s without raising. Probe cost 0.16-0.17s.
The positive arm replaced is_slow_build_binary with a lambda, so the real
result parsing had no test: making it return False unconditionally left
every arm green while every debug startup failure kept the 30s budget.

Drive the real helper from what the query returns instead ("1"/"2" slow,
"0"/""/"x" not), and assert the query text names each signal
collect_build_flags derives, so the two cannot drift apart on what "slow"
means. Both mutations now redden: an unconditional False, and >0 becoming
>1.
…warding

Two defects in the binary fallback added in the previous commit.

The probe treated any -fsanitize= as slow, while collect_build_flags maps
only thread, address, undefined and memory. CFI adds
-fsanitize=cfi-vcall,cfi-derived-cast on top of RelWithDebInfo
(CMakeLists.txt:527-529) and has its own stress job
(ci/defs/job_configs.py:420), so an amd_cfi startup failure would have got
120s while the same binary, once started, got 30s. Name the same four
sanitizers instead.

Nothing proved get_stacktraces_from_lldb forwards the chosen budget to the
lldb invocation: every budget arm stubs that collector out, so restoring a
hardcoded timeout=30 inside it would have left all arms green with the
slow-build budget silently disabled. Assert the forwarded timeout for both
the explicit and default cases, and keep_output_on_error, without which a
timed-out attach is unrecoverable.

Mutations observed red: re-broadening to bare -fsanitize=, hardcoding
timeout=30, and dropping keep_output_on_error.
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8c472bcbb with master 350486ac6 (stripped binary size, per-symbol sizes and ThinLTO time; 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 704.51 MiB 701.49 MiB -3.02 MiB (-0.43%)

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

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

Job report

require_server=False only skips the precondition; the CI tests job still
runs a live release server, so nothing stopped the probe from being turned
into a live-server query or losing its bound, either of which puts the
startup-failure path back on 30s or blocks the abort it diagnoses.

Record the timeout alongside the command and assert the probe invokes
args.binary with `local` and passes timeout=60. Both mutations redden:
dropping the timeout, and swapping `local` for `client`.
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 13, 2026
Comment thread tests/clickhouse-test Resolved
print_c_stacktraces derived per_pid_timeout before the ASan guard and before
the no-pids guard, and both return without reading it. On the startup-failure
path (main -> check_server_started, which runs before collect_build_flags), the
derivation falls back to reading the binary via `clickhouse local`, so an ASan
job paid that 60s-bounded read and then paid is_asan_build's own 60s-bounded
read of the same binary before printing the skip message: 120s of worst-case
delay on an already-failing run, for no dump.

Moving the derivation below both guards leaves the non-ASan path unchanged.
Measured on the ASan startup-failure shape: 2 binary probes and 120s of
worst-case bound before, 1 and 60s after; the non-ASan control still runs the
flavor probe and still passes the 120s slow-build budget to lldb.

The new arm drives both helpers from what their query returns rather than
stubbing either, so the ordering cannot be hidden by a stub, and asserts the
ASan half (one probe, no lldb call) independently of the non-ASan control.
The arm only supplied a live PID, so it pinned the ASan return ahead of the
flavor derivation but not the no-process one. Moving the derivation between the
two guards left all twelve tests green while an exited startup process would
still pay the 60s binary read before the abort; with the no-PID arm that
placement reddens.

Test-only: the source already derives below both returns.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 1895127

CI is fully finished at this head. 177 checks: 80 success, 97 skipped, 0 failures, 0 dropped
(praktika top-level OK). Every skip carries a reason ("Not affected by the changed files and not
required" x74, "not labeled with 'pr-performance'" x6, "no tests to run" x5, "not a bug-fix PR" x5,
"reused from cache" x3, and 4 others), so the run has real coverage and nothing was silently
dropped. CIDB reports no FAIL/ERROR rows at this SHA.

No failures, so there is nothing to assign an owner to.

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

Master deleted `ci/tests/test_print_stacktraces.py` along with most of
`ci/tests/` in ClickHouse#114675, and `.claude/CLAUDE.md` now states the rule the
deletion follows: a throwaway test for CI scripts need not be committed,
because that suite is not run automatically. The 39 files restored after
that PR did not include this one, so the deletion is the intended state
and the merge takes master's side.

The harness change is unaffected: the budget derivation, the binary-flavor
fallback and the timed-out-dump retention are the same code that was
reviewed, and master's own additions to `tests/clickhouse-test` are kept.
Re-ran the deleted arms as a throwaway script against the merged tree and
against the pre-merge head: 12 passed and the same 5 live-server arms
skipped for want of a server in both, so the merge changes no behavior.
Comment thread tests/clickhouse-test
for pid in all_pids:
# Costs a `clickhouse local` read of the binary when the flags are missing,
# and neither return above consumes it.
if per_pid_timeout is None:

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.

print_c_stacktraces still does one discarded binary probe on the no-process startup-failure path. When check_server_started fails before collect_build_flags(args), args.build_flags is unset, so is_asan_build(args) shells out to clickhouse local here. If the server has already exited, we then hit the not all_pids return below and never use that ASan verdict for anything.

That leaves already-failing startup jobs paying an extra 60s-bounded probe before printing the only actionable message. Could we snapshot all_pids first and return on the empty case before probing the binary for ASan?

Comment thread tests/clickhouse-test
def print_c_stacktraces(
args,
per_pid_timeout: Optional[float] = None,
total_timeout: float = LLDB_SLOW_BUILD_TIMEOUT,

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.

total_timeout now defaults to the same LLDB_SLOW_BUILD_TIMEOUT that lldb_timeout_for_build(args) gives each slow-build PID. That means as soon as get_all_server_pids(args) returns more than one server, the first debug/sanitized process can consume the entire loop budget and every later replica is either truncated or skipped.

That breaks the multi-server case this helper is meant to cover. The built-in test_cluster_database_replicated cluster already has three server processes (tests/config/config.d/database_replicated.xml:89-106), and the replica holding the hang is not guaranteed to be the first PID. Could the abort-path ceiling scale with len(all_pids) (or at least budget one full slow-build attach per PID up to the outer job timeout) instead of reusing the per-PID constant as the whole-loop cap?

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 7c0edc0

Every failure below has an owner: a fixing PR (ours 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 (arm_tsan) / Logical error: 'Equal values are not contiguous within the range assumed to be sorted' (STID: 2508-32f8) pre-existing trunk bug, not this PR's diff. fatal.log gives the carrier: SELECT count() FROM (SELECT DISTINCT s FROM merge_distinct__fuzz_8 ORDER BY s ASC LIMIT 100) SETTINGS optimize_distinct_in_order = 1, log_comment = 04870_distinct_merge_over_distributed.sql, aborting in ColumnDecimal/ColumnNullable::getEqualRangeEndAssumeSorted under SortCursor.h equalRangeEndAcrossColumns - the DISTINCT-over-merge() shape where sorting is pushed into a Merge child across an order-breaking cast #113242 (ours, open)

Rule 3b, not 3d: conversionPreservesOrder greps 0 in src/Storages/StorageMerge.cpp at this
head, so the fix is genuinely absent from the tested tree rather than present and ineffective.

Session id: cron:our-pr-ci-monitor:20260817-200000

@groeneai groeneai added the groeneai-origin-self PR origin: self-found defect (impact-bar validated) label Aug 19, 2026
groeneai and others added 4 commits August 21, 2026 17:26
master added a fifth default-budget call site (the LIVENESS_CHECK_FAILED
abort) and reworded the docstring paragraph this branch also rewrote, so
the two edits collided on one paragraph.

Resolution keeps master's call-site enumeration, including "liveness
check", and drops its "pause is on the order of seconds" sentence, which
is the premise this branch replaces: a 172-thread debug server measured
44-118s in the CI stress image.

The new site sits outside the one-shot alarm, so it correctly takes the
default flavor budget; the timeout_handler site remains the only one
passing an explicit (30, 60) because a fired alarm cannot bound its own
handler.

Two comments master added state a "30s per server process" bound for the
same sweep. That constant is no longer the bound here (per-PID 30 or 120,
plus a 120s aggregate ceiling), so both now name the budget instead of a
number.
The source comments describing the sweep as bounded to 30s per server
process were reworded in the merge commit. Two comments in the hung-check
test file assert the same retired constant, so they say "the budget" now
as well.

Comment-only; the suite's outcome is unchanged (33 passed, the same 10
live-server arms failing as on master).
… budget fix

Master extended this comment to cover the SQL dump stub as well, which matches the
code below it (both `print_c_stacktraces` and `print_sql_stacktraces` are stubbed).
Kept that framing and this branch's correction that the lldb sweep is bounded by
the flavor-scaled budget rather than a flat 30 s per process.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Master removed the whole `ci/tests` directory in `5b3d66b1a66` ("Remove ci/tests
(attempt 2)", 51 files, no replacement location), so this branch's edits under
`ci/tests` arrive as modify/delete conflicts. Accepted the removal, and dropped
the files this branch adds there as well - keeping them would re-create a
directory master deliberately deleted.

The product change this pull request is about is unaffected; what is lost is its
CI-side unit coverage, which has nowhere to live upstream any more.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@alexey-milovidov alexey-milovidov self-assigned this Sep 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 3, 2026
Merged via the queue into ClickHouse:master with commit bda3c25 Sep 3, 2026
175 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 3, 2026
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-self PR origin: self-found defect (impact-bar validated) 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