Skip to content

Install lldb in CI Docker images alongside gdb - #104815

Merged
leshikus merged 4 commits into
ClickHouse:masterfrom
leshikus:lldb-in-ci-images
Aug 5, 2026
Merged

leshikus merged 4 commits into
ClickHouse:masterfrom
leshikus:lldb-in-ci-images

Conversation

@leshikus

@leshikus leshikus commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator

clickhouse-test's print_c_stacktraces uses lldb to attach to a running (or hung) ClickHouse server and dump C++ backtraces into c_stacktraces.log on a test timeout or the end-of-run hung check. For that to work, lldb has to be present on the machine running the tests. How it gets there differs by platform.

How lldb is provisioned per platform

  • Linux (CI docker images) — this PR. lldb is baked into clickhouse/fasttest and clickhouse/test-base. The LLVM apt repo is already configured for the matching LLVM_VERSION in both Dockerfiles, so this is a single apt-get install --yes lldb-${LLVM_VERSION}, a /usr/bin/lldb symlink, and chmod u+s, mirroring the existing gdb setup. The suid bit is the point: the Fast test job runs its container unprivileged (docker run --user $(id -u):$(id -g)), so a runtime apt-get install lldb cannot work there (no root), and attaching to the server with ptrace needs the elevated privilege that the setuid lldb provides. Every test image ultimately depends on one of these two — stateless-test, integration/runner, integration/base, and performance-comparison inherit from test-base; cctools from fasttest.
  • macOS (Darwin fast test) — unchanged, for contrast. The Darwin runner is a bare host, not a container, so there is no image to bake into. There lldb is provided at runtime by _ensure_lldb_installed in tests/clickhouse-test, which runs brew install llvm and prepends the keg-only opt/llvm/bin to PATH. That helper is macOS-only and stays.

So print_c_stacktraces gets its debugger from the image on Linux and from Homebrew on macOS, and produces c_stacktraces.log on both.

gdb is intentionally left in place. It is still driven directly by the fuzzer (ci/jobs/scripts/fuzzer/run-fuzzer.sh), perf comparison (ci/jobs/scripts/perf/compare.sh), unit tests (ci/jobs/unit_tests_job.py), stress (ci/jobs/scripts/stress/stress.py), the upgrade runner (tests/docker_scripts/upgrade_runner.sh), and the integration test harness. Migrating those to lldb is out of scope.

Related: #112058

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

`clickhouse-test`'s `print_c_stacktraces` now drives `lldb` instead of
`gdb` (ClickHouse#104771). To keep the helper from doing on-the-fly
`apt-get install lldb` from inside an error path, install `lldb` at
image build time.

`lldb` is added to `clickhouse/fasttest` and `clickhouse/test-base` —
the two base images on which every test image ultimately depends
(`stateless-test`, `integration/runner`, `integration/base`,
`performance-comparison` all inherit from `test-base`; `cctools` from
`fasttest`). The LLVM apt repo is already configured for the matching
`LLVM_VERSION` in both Dockerfiles, so the install is a single
`apt-get install --yes lldb-${LLVM_VERSION}` plus a `/usr/bin/lldb`
symlink and `chmod u+s` mirroring the existing `gdb` setup.

`gdb` is kept as-is. It is still driven directly by the fuzzer
(`ci/jobs/scripts/fuzzer/run-fuzzer.sh`), perf comparison
(`ci/jobs/scripts/perf/compare.sh`), unit tests
(`ci/jobs/unit_tests_job.py`), stress
(`ci/jobs/scripts/stress/stress.py`), the upgrade runner
(`tests/docker_scripts/upgrade_runner.sh`), and the integration test
harness (`tests/integration/integration-tests-entrypoint.sh`,
`tests/integration/helpers/cluster.py`, several tests under
`tests/integration/`). Migrating those tools to `lldb` is out of scope
for this PR.

Follow-up: once this image lands, the `_ensure_lldb_installed`
scaffolding in `tests/clickhouse-test` (added in ClickHouse#104771) can be
deleted in a small cleanup PR.
@leshikus
leshikus marked this pull request as ready for review May 13, 2026 10:06
@leshikus
leshikus requested a review from maxknv May 13, 2026 10:07
@clickhouse-gh

clickhouse-gh Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5923014]

Summary: ✅


AI Review

Summary

This PR installs lldb into the Linux CI base images, adds an unversioned lldb entrypoint, and mirrors the existing debugger setup closely enough for clickhouse-test's print_c_stacktraces flow. I reviewed the current diff, the affected clickhouse-test call path, the image inheritance, prior review threads, and the PR's green CI reports, and I did not find any blocking or major issues in the current state of the change.

Final Verdict

✅ No blocking or major issues found in the current diff.

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

@maxknv maxknv left a comment

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.

why do we need to migrate? what is the size added to the image?

@leshikus

leshikus commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

@maxknv It is recommended to use lldb on Darwin; supporting both gdb and lldb is harder than just gdb; I believe I will be able to remove gdb at some point.

@leshikus

leshikus commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

@maxknv Adding lldb to test-base costs ~120 MB per image (lldb-21 ~4 MB + liblldb-21 ~18 MB + libclang-cpp21 ~57 MB + python3-lldb-21 + a few smaller deps). But some images like fastest already contain libclang-cpp21 - thus we got only +50 MB for them.

@maxknv

maxknv commented May 13, 2026

Copy link
Copy Markdown
Member

@maxknv It is recommended to use lldb on Darwin; supporting both gdb and lldb is harder than just gdb; I believe I will be able to remove gdb at some point.

I think it's relatively easy. And we can avoid adding a new package to many Docker images (it's the base image you're updating), at least until it's confirmed that lldb works for us

@maxknv
maxknv self-requested a review May 13, 2026 16:09
@clickhouse-gh

clickhouse-gh Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Dear @maxknv, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@clickhouse-gh clickhouse-gh Bot assigned maxknv and unassigned maxknv Jun 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Dear @maxknv, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

leshikus added a commit to leshikus/ClickHouse that referenced this pull request Jul 28, 2026
`_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
leshikus added a commit to leshikus/ClickHouse that referenced this pull request Jul 28, 2026
`_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
@leshikus
leshikus added this pull request to the merge queue Jul 28, 2026
Comment thread ci/docker/fasttest/Dockerfile Resolved
Comment thread ci/docker/test-base/Dockerfile Resolved
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 28, 2026
Reviewer feedback on ci/docker/fasttest/Dockerfile and
ci/docker/test-base/Dockerfile asked to treat `lldb` as part of `llvm`
(same apt repo, same version) and drop the dedicated
`apt-get update`/install/cleanup block for it:

> This block should be with the block installing clang. It's the same repo, same version, etc
> Same here. Please treat lldb as part of llvm (because it is). No need to fetch the repo, install and track the version and clean up

Add `lldb-${LLVM_VERSION}` to the existing `clang`/`llvm` install list in
each image so it is fetched in the same layer that already configures the
LLVM apt repo, and keep only the `/usr/bin/lldb` symlink and suid steps in
the follow-up RUN.
@leshikus leshikus added the can be tested Allows running workflows for external contributors label Aug 4, 2026
@leshikus
leshikus added this pull request to the merge queue Aug 5, 2026
Merged via the queue into ClickHouse:master with commit 2d245a6 Aug 5, 2026
180 checks passed
@leshikus
leshikus deleted the lldb-in-ci-images branch August 5, 2026 17:13
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

Couldn't load assignees.

Labels

can be tested Allows running workflows for external contributors 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.

4 participants