Skip to content

Testing: verify server stacktrace log attachment with an artificial hung test (on top of brew lldb fix) - #111213

Closed
leshikus wants to merge 6 commits into
ClickHouse:masterfrom
leshikus:darwin-test-timeout-log-attach
Closed

leshikus wants to merge 6 commits into
ClickHouse:masterfrom
leshikus:darwin-test-timeout-log-attach

Conversation

@leshikus

@leshikus leshikus commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Testing PR — do not merge. Rebased onto the brew-based lldb install fix (#112058) to verify, on a real Fast test run, that a hung query's server stacktraces are written to files and attached to the report.

It carries two things:

  • The _ensure_lldb_installed change from darwin fast test: install lldb on demand via brew on macOS only #112058: install lldb on demand via Homebrew instead of apt-get (which fails unprivileged in the fast-test container), plus the keg-only PATH fix so shutil.which("lldb") resolves.
  • A throwaway stateless test, 04612_artificial_timeout_stacktrace_dump.sh, that never finishes. It detaches a long-running server-side query (SELECT sleepEachRow(1) FROM numbers(100000) with max_execution_time = 0 so the server does not self-kill it) into its own session via os.setsid, so it lingers in system.processes past the end of the run. The end-of-run hung check then fires and calls print_sql_stacktraces / print_c_stacktraces, which write sql_stacktraces.log / c_stacktraces.log for fast_test.py to attach. Its foreground also hangs past --timeout so the test is reported as a timeout too.

Expected result: the CI report carries sql_stacktraces.log (and, where lldb is available, c_stacktraces.log) as attached artifacts, and job.log keeps only a trimmed preview.

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):

@leshikus leshikus added the can be tested Allows running workflows for external contributors label Jul 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3b38486]

Summary: ❌

job_name test_name status info comment
Fast test (arm_darwin) FAIL
04612_artificial_timeout_stacktrace_dump FAIL cidb
Some queries hung FAIL cidb

AI Review

Summary

This draft PR tries to verify macOS stacktrace-log attachment by making _ensure_lldb_installed use Homebrew on Darwin and by adding a deliberately hung stateless test. I found one shared-diagnostics regression in tests/clickhouse-test and one problem in the artificial test itself that makes the reproduction noisier and less deterministic than it needs to be, so I would not merge it as-is.

Missing context / blind spots
  • ⚠️ The workflow run for the current head 3b38486c9f7e75b91fdeab964032874cb34e8120 is still queued (30331778960), so I could not verify the claimed Fast test (arm_darwin) artifact attachment end-to-end on the current revision.
Findings

❌ Blockers

  • [tests/clickhouse-test:1034] Returning early on every non-Darwin platform removes the only path that currently puts lldb on Linux. The in-tree Linux images this script runs in still install gdb / llvm-*, not lldb, so Linux timeout / hung-check / server-died diagnostics fall back to lldb: command not found instead of collecting C backtraces. Suggested fix: either add lldb to the Linux test images in the same PR or keep a working Linux fallback here until the image change lands.

⚠️ Majors

  • [tests/queries/0_stateless/04612_artificial_timeout_stacktrace_dump.sh:42] The detached clickhouse-client inherits the script's redirected stdout / stderr, and the query still produces rows. After the shell times out, run_single_test rewrites and reads those files while the detached client is still appending to them, which makes the reproduction nondeterministic for no benefit. Suggested fix: make the query FORMAT Null and redirect the detached client's stdout / stderr away from the test files.
Final Verdict

Request changes before merge.

`_ensure_lldb_installed` installs `lldb` at runtime so `print_c_stacktraces`
can attach and dump C++ backtraces. On Linux it used `apt-get`, which requires
root; the fast-test container runs unprivileged, so `apt-get update` fails with
"List directory /var/lib/apt/lists/partial is missing. - Acquire (13:
Permission denied)", lldb never lands, and `print_c_stacktraces` only logs
`lldb: command not found` (no c_stacktraces.log is written or attached).

Observed on a testing PR that leaves a query hung until the end-of-run hung
check: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111213&sha=84b4363107f7eb2319eacaafa3e1adb18bae0e36&name_0=PR&name_1=Fast%20test
(PR ClickHouse#111213). There `sql_stacktraces.log`
was attached but `c_stacktraces.log` was missing for the reason above.

Unify the on-demand install on Homebrew, which needs no root and matches how
the macOS runner already provisions lldb (`brew install ... llvm` plus
`{prefix}/opt/llvm/bin` on the job PATH in runner-init.py). `brew install llvm`
is keg-only and does not symlink `lldb` system-wide, so also prepend the
formula bin dir to PATH so `shutil.which("lldb")` resolves the freshly
installed binary.

Related: ClickHouse#107173

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… log attachment

Throwaway testing change (do NOT merge) on top of the brew-based lldb install
fix (ClickHouse#112058). Adds a stateless
test that never finishes: it detaches a long-running server-side query (with
max_execution_time = 0 so the server does not self-kill it) into its own
session via os.setsid, so it lingers in system.processes past the end of the
run and the end-of-run hung check dumps and attaches the full server
stacktraces (sql_stacktraces.log / c_stacktraces.log). Its foreground also
hangs past --timeout so it is reported as a timeout.

Related: ClickHouse#107173
Related: ClickHouse#112058

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@leshikus
leshikus force-pushed the darwin-test-timeout-log-attach branch from 84b4363 to 2b6a6ee Compare July 27, 2026 10:09
@leshikus leshikus changed the title darwin fast test: verify server stacktrace log attachment with an artificial timing-out test Testing: verify server stacktrace log attachment with an artificial hung test (on top of brew lldb fix) Jul 27, 2026
leshikus and others added 4 commits July 28, 2026 02:56
`_ensure_lldb_installed` had unified the on-demand install on Homebrew,
but `brew` is not present in the Linux `clickhouse-test` containers, so
that path failed with `ENOENT` on exactly the jobs it was meant to fix.

Use the native package manager per platform: `brew install llvm` on
macOS (keeping the keg-only PATH fix so `shutil.which("lldb")` resolves
the freshly installed binary), `apt-get install -y lldb` on Linux.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`_ensure_lldb_installed` split the install across two package managers:
Homebrew on macOS and `apt-get` on Linux. The Linux branch can never
work where it matters: the Fast test job runs in the unprivileged
`clickhouse/fasttest` container (`docker run --user $(id -u):$(id -g)`,
see `ci/praktika/runner.py`), so `apt-get install lldb` fails with a
permission error and `c_stacktraces.log` is never written. Installing
`lldb` on Linux belongs in the image, not at runtime -- see PR ClickHouse#104815
(`Install lldb in CI Docker images alongside gdb`).

Drop the dead Linux branch and keep only the macOS Homebrew path (the
Darwin runner is a bare host, not a container, so an on-the-fly install
is the right tool there). On Linux the helper is now a no-op.

Touching `tests/clickhouse-test` also changes the `Fast test (arm_darwin)`
cache digest, so the job is a cache miss and actually re-runs on a real
macOS host -- the previous run reused a cached result and reported
`skipped`:
https://github.com/ClickHouse/ClickHouse/actions/runs/30324617319

Related: ClickHouse#104815
The test is a plain stateless test, so it ran (and hung) in the Linux
`Fast test` and in every `Stateless tests` job, not just the macOS
`Fast test (arm_darwin)` run it is meant for. Those Linux jobs are
transitive `needs` of `Fast test (arm_darwin)` (via the `arm_darwin`
build and `CORE_BLOCKING_JOB_NAMES`), so their timeout failure tripped
the per-job GitHub Actions `if:` guard
(`!contains(needs.*.outputs.pipeline_status, 'failure')`,
ci/praktika/yaml_generator.py) and the macOS job was skipped before it
could run — the previous run never produced `c_stacktraces.log`:
https://github.com/ClickHouse/ClickHouse/actions/runs/30329003808

Exit cleanly on non-Darwin (the reference is empty, so it passes) and
hang only on macOS, keeping the dependency chain green so the macOS job
runs the hang and dumps the server stacktraces.
…call

`_ensure_lldb_installed` made two `brew` calls: `brew install llvm` and
`brew --prefix llvm` to locate the keg-only `lldb`. The second call is
redundant: `llvm` is keg-only, so its bin dir is the version-stable
`opt/llvm` path under the Homebrew prefix
(`/opt/homebrew` on Apple Silicon, `/usr/local` on Intel). `runner-init.py`'s
`macos_job_path` already hardcodes exactly this path when assembling the
job PATH, so derive it the same way and drop the extra subprocess (and its
failure branch).
Comment thread tests/clickhouse-test
# (the same way `runner-init.py`'s `macos_job_path` assembles the job PATH)
# rather than spending a second `brew --prefix llvm` subprocess on it.
brew_prefix = "/opt/homebrew" if platform.machine() == "arm64" else "/usr/local"
os.environ["PATH"] = f"{brew_prefix}/opt/llvm/bin:{os.environ.get('PATH', '')}"

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.

Returning early on every non-Darwin platform drops the only working path that currently puts lldb on Linux. The in-tree Linux images this script runs in still copy /opt/gdb and install llvm-*, but I do not see them installing lldb itself in ci/docker/fasttest/Dockerfile or ci/docker/test-base/Dockerfile. print_c_stacktraces is still used from the Linux timeout / hung-check / server-died paths, so after this change those flows fall through to shutil.which("lldb") or "lldb" and produce command not found instead of a C backtrace. If we want to stop installing on the fly, the Linux images need to gain lldb in the same change; otherwise we should keep a working Linux fallback here until that lands.

# execution time is too long`) after a few minutes — before the end-of-run hung
# check runs — so `system.processes` would be empty and nothing would be dumped.
python3 -c 'import os, sys, subprocess; os.setsid(); subprocess.Popen(sys.argv[1:])' \
$CLICKHOUSE_CLIENT --query "SELECT sleepEachRow(1) FROM numbers(100000) SETTINGS max_block_size = 1, max_execution_time = 0, max_estimated_execution_time = 0" &

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.

The detached clickhouse-client inherits the script's redirected stdout / stderr, and this query still produces rows. After the foreground shell times out, run_single_test immediately rewrites and reads those files, but the detached client is still appending to them in the background, so the timeout result becomes nondeterministic for no benefit. The hung-check only needs a live query in system.processes, so it would be safer to make this FORMAT Null and launch the detached client with its own stdout / stderr redirected away from the test files (for example via subprocess.DEVNULL inside the Python helper).

@leshikus

Copy link
Copy Markdown
Collaborator Author

Testing PR

@leshikus leshikus closed this Aug 31, 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 pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant