fix(hosting): disable ClickHouse system-log telemetry tables and apply profile settings via users.d - #4546
Conversation
…y profile settings via users.d ClickHouse's system log tables ship unbounded (no TTL); on the recommended webapp machine size their background merges eventually exceed the memory cap and are retried forever, pinning the CPU and failing the webapp's own inserts. Port the dev stack's disable list (PR triggerdotdev#3565) to hosting/docker, keep query_log/error_log with a config-level TTL, and move the profile settings to users.d where they actually take effect. fixes triggerdotdev#4343 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
WalkthroughClickHouse now disables fifteen system telemetry log tables and retains 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b241327b-92c1-4cb0-9f5b-f4f07d2ef9a1
📒 Files selected for processing (4)
.server-changes/hosting-clickhouse-system-logs.mdhosting/docker/clickhouse/override.xmlhosting/docker/clickhouse/users-override.xmlhosting/docker/webapp/docker-compose.yml
📜 Review details
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-05-14T14:54:39.095Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3545
File: .server-changes/agent-view-sessions.md:10-10
Timestamp: 2026-05-14T14:54:39.095Z
Learning: In the `trigger.dev` repository, do not flag inconsistent dot vs slash notation in route/path strings inside `.server-changes/*.md` files. These markdown files are consumed verbatim into the changelog, so the mixed notation (e.g., `resources.orgs.../runs.$runParam/...`) is intentional and should be preserved as-is.
Applied to files:
.server-changes/hosting-clickhouse-system-logs.md
📚 Learning: 2026-07-26T13:14:02.968Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 4378
File: .server-changes/realtime-run-reads-from-primary.md:0-0
Timestamp: 2026-07-26T13:14:02.968Z
Learning: For files in the .server-changes directory, the body text is published verbatim as dashboard-facing user release notes. Write entries in terms of user-visible behavior (what users can do/see), and avoid implementation-oriented details such as environment-variable names, internal mechanisms, or configuration knobs. If you need to include operational/configuration specifics, put those details in the PR description instead of the .server-changes entry.
Applied to files:
.server-changes/hosting-clickhouse-system-logs.md
🔇 Additional comments (5)
hosting/docker/clickhouse/override.xml (2)
32-32: 🗄️ Data Integrity & IntegrationVerify
latency_logagainst the target ClickHouse image.The supplied context does not include the ClickHouse image tag. The upstream ClickHouse configuration I checked does not define
latency_log. (github.com) Confirm that the image used byhosting/docker/webapp/docker-compose.ymlsupports this key. Also verify the full disable list againstsystem.tablesafter startup.Source: MCP tools
13-20: LGTM!Also applies to: 37-46, 48-50
hosting/docker/clickhouse/users-override.xml (2)
11-18: 🚀 Performance & ScalabilityDisable the server-wide memory profiler, or verify it is already disabled.
This file disables the per-query profiler settings only. The ClickHouse 26.2 stock configuration sets the server-level
total_memory_profiler_stepto4194304; this setting is not controlled by theusers.dprofile. (raw.githubusercontent.com)If
hosting/docker/clickhouse/override.xmlnear Lines 48-50 does not settotal_memory_profiler_stepto0, the server-wide profiler can continue collecting discarded trace samples. Add that setting tohosting/docker/clickhouse/override.xml, or verify the effective merged value.
1-10: LGTM!Also applies to: 19-21
hosting/docker/webapp/docker-compose.yml (1)
180-180: LGTM!
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fixes #4343
Problem
The self-hosting ClickHouse ships with every system log table enabled and unbounded (no TTL by default). On the recommended webapp machine (3+ vCPU / 6+ GB), the wide telemetry tables (
metric_log~1200 columns,text_log,asynchronous_metric_log) grow until their background merges no longer fit under the memory cap (max_server_memory_usage_to_ram_ratio0.9 ≈ 5.2 GiB on a 6 GB box — ClickHouse measured a defaultmetric_logmerge peaking around 6 GB in ClickHouse/ClickHouse#89811). Failed non-replicated merges have no retry backoff, so ClickHouse retries them forever: in our production this burned ~270% CPU at ~350kMEMORY_LIMIT_EXCEEDED/day, each failure logging a stack trace intotext_logand feeding the loop — and eventually the webapp's own inserts intotrigger_dev.task_runs_v2/metrics_v1started failing with the same error, so runs went missing from the dashboard. 14 days after a fresh data dir, 5.96 GiB of the 6.0 GiB of MergeTree data on the box was ClickHouse telemetry; actual Trigger data was ~40 MiB.The dev stack fixed exactly this in #3565 (
docker/config/clickhouse-disable-system-logs.xml); it was never ported tohosting/docker. The ClickHouse low-RAM guide prescribes disabling these tables on <16 GB machines: https://clickhouse.com/docs/operations/tipsSeparately, the
<profiles>block inhosting/docker/clickhouse/override.xmlis silently ignored: profile settings only apply from the users config tree (users.d), never fromconfig.d— so the advertised low-memory settings (max_block_size8192, etc.) have never applied.Changes
hosting/docker/clickhouse/override.xml: disable the same system log tables as the dev stack, extended with the newer ones (latency_log,query_metric_log,opentelemetry_span_log,query_views_log). Keepquery_loganderror_log, bounded with a config-level<ttl>(7/30 days) — config-level TTL survives table recreation, unlikeALTER … MODIFY TTL. The ineffective<profiles>block is removed.hosting/docker/clickhouse/users-override.xml, mounted at/etc/clickhouse-server/users.d/override.xml: carries those profile settings so they actually apply, plus explicit zeros for the memory/query profilers (their samples were the maintrace_logfirehose).hosting/docker/webapp/docker-compose.yml: add theusers.dmount.Validation
Deployed on our production for 7 days (see #4343 for the full soak log): ClickHouse CPU 275% → ~2%,
MEMORY_LIMIT_EXCEEDEDfrom ~350k/day to zero for 7 straight days, webapp insert failures from ~40/day to zero — including a 79-database backup fleet run (~470 task runs) — and 6 GiB of disk reclaimed.Note for existing deployments: disabling a log table stops new writes but doesn't delete existing data. To reclaim disk:
DROP TABLE system.<name> SYNCfor each disabled table (plus any*_log_<N>leftovers from config-change renames). Happy to add that to the self-hosting docs if useful.