Repository navigation
Conversation
`_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]>
|
Workflow [PR], commit [fdf1087] AI ReviewSummaryThis PR narrows Tests
Final VerdictChanges requested: add focused automated coverage for the new |
… 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]>
`_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. Related: ClickHouse#104815
…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).
|
The fix succcessfully makes |
Algunenano
left a comment
There was a problem hiding this comment.
The PR description is confusing. The code is only installing it on Darwin, but the PR says Install lldb on demand via Homebrew on every platform instead of apt-get on Linux.
Also, the AI reviewer seems right saying that lldb isn't installed in the Linux fast test image, so it will fail there. Can we add it? We are already installing clang, lld and so on
|
@Algunenano there is a separate PR regarding installing lldb on Linux, I've just merged it. I'll take a look if the same test provides logs on Linux correctly. |
|
@Algunenano addressed both points:
|
Review feedback on `_ensure_lldb_installed`:
> here we unconditionally do a `brew install llvm` with a 600-second ceiling before trying the deterministic Homebrew `opt/llvm/bin` path. On the Darwin runners `runner-init.py` already provisions `llvm`, so the common failure mode is "installed but not on `PATH`" [...] Please prepend the known keg-only path and re-check `shutil.which("lldb")` first, then fall back to `brew install llvm` only if it is still absent.
The helper is reached only from the timeout / hung-check cleanup path, so a
networked `brew install` there delays `stop_tests`. `llvm` is already
provisioned on the runner but keg-only, so `lldb` is present yet not on
`PATH`. Prepend the stable `opt/llvm/bin` dir and re-check `shutil.which`
before attempting the install; `brew install llvm` now runs only as a
genuine package-missing fallback. This also fixes an offline case: the old
order returned without prepending the path when `brew` failed, so an
already-present `lldb` was never found.
| attempt already failed. | ||
| """ | ||
| global _LLDB_INSTALL_ATTEMPTED | ||
| if platform.system() != "Darwin": |
There was a problem hiding this comment.
This changes _ensure_lldb_installed's contract in two subtle ways that are easy to regress but still unproven by automation: Linux must short-circuit before any shell-out, and Darwin must re-check the deterministic Homebrew opt/llvm/bin path before falling back to brew install.
The existing ci/tests/test_print_stacktraces.py coverage exercises the live-server collectors, but it never stubs _ensure_lldb_installed, so a future reordering or removal of either branch would only be caught again on a real timed-out macOS run. Please add a small unit test that monkeypatches platform.system, platform.machine, shutil.which, and subprocess.run to assert both behaviors.
|
A followup PR is created with alternate solution |
Motivation
_ensure_lldb_installedintests/clickhouse-testputslldbonPATHsoprint_c_stacktracescan attach to the server and dump C++ backtraces on a timeout or the end-of-run hung check. The Darwin fast test runs on a bare macOS host (not a container), wherelldbis not guaranteed to be on the defaultPATH.The previous Linux branch used
apt-get, which cannot work in the fast test: that job runs unprivileged in theclickhouse/fasttestcontainer (docker run --user $(id -u):$(id -g), seeci/praktika/runner.py), soapt-get updatefails with a permission error andlldbnever lands — noc_stacktraces.logis written or attached.Change
Scope the on-demand install to macOS only. On macOS
lldbis installed via Homebrew (brew install llvm), matching how the runner already provisions it; becausebrew install llvmis keg-only and does not symlinklldbsystem-wide, the formula'sopt/llvm/bindirectory is prepended toPATHsoshutil.which("lldb")inget_stacktraces_from_lldbresolves the binary. On Linux the helper is a no-op —lldbis baked into the CI images (clickhouse/fasttest,clickhouse/test-base) instead, which landed in#104815. So this is not an "install on every platform" change: macOS installs on demand, Linux relies on the image.Verified on a real macOS runner: the Darwin fast test produced a symbolicated C++ backtrace via
lldband wrotec_stacktraces.log.Related: #107173
Related: #104815
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):