Skip to content

Commit 14fde64

Browse files
Leafgardclaude
andcommitted
fix(hosting): disable ClickHouse system-log telemetry tables and apply 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 #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 #4343 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 90e8bd5 commit 14fde64

4 files changed

Lines changed: 67 additions & 9 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: hosting
3+
type: fix
4+
---
5+
6+
Self-hosted ClickHouse no longer accumulates unbounded system-log telemetry (metric_log, text_log, asynchronous_metric_log, ...) that eventually pins the CPU in a background merge-retry loop on the recommended machine size; query_log and error_log are kept with a TTL, and the low-memory profile settings now actually apply (moved from config.d to users.d).

hosting/docker/clickhouse/override.xml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,42 @@
99
<!-- Official recommendations for systems with <16GB RAM -->
1010
<mark_cache_size>524288000</mark_cache_size> <!-- 500MB -->
1111
<concurrent_threads_soft_limit_num>1</concurrent_threads_soft_limit_num>
12-
<profiles>
13-
<default>
14-
<max_block_size>8192</max_block_size>
15-
<max_download_threads>1</max_download_threads>
16-
<input_format_parallel_parsing>0</input_format_parallel_parsing>
17-
<output_format_parallel_formatting>0</output_format_parallel_formatting>
18-
</default>
19-
</profiles>
20-
</clickhouse>
12+
13+
<!-- ClickHouse's own telemetry tables have no TTL and grow without bound; on the
14+
recommended webapp machine size their background merges eventually stop fitting
15+
in memory and are retried forever (there is no backoff for failed merges),
16+
pinning the CPU and ultimately failing the webapp's own inserts (#4343).
17+
The ClickHouse low-RAM guide recommends disabling exactly these tables:
18+
https://clickhouse.com/docs/operations/tips
19+
Same list as the dev stack (docker/config/clickhouse-disable-system-logs.xml),
20+
extended with the newer log tables. -->
21+
<metric_log remove="1"/>
22+
<asynchronous_metric_log remove="1"/>
23+
<part_log remove="1"/>
24+
<trace_log remove="1"/>
25+
<query_thread_log remove="1"/>
26+
<session_log remove="1"/>
27+
<text_log remove="1"/>
28+
<zookeeper_log remove="1"/>
29+
<processors_profile_log remove="1"/>
30+
<asynchronous_insert_log remove="1"/>
31+
<backup_log remove="1"/>
32+
<latency_log remove="1"/>
33+
<query_metric_log remove="1"/>
34+
<opentelemetry_span_log remove="1"/>
35+
<query_views_log remove="1"/>
36+
37+
<!-- Keep query_log and error_log (small and useful for debugging), but bounded.
38+
A config-level TTL survives log-table recreation, unlike ALTER ... MODIFY TTL.
39+
Note: ClickHouse renames the existing table to *_log_<N> when this changes;
40+
drop those leftovers to reclaim disk. -->
41+
<query_log>
42+
<ttl>event_date + INTERVAL 7 DAY DELETE</ttl>
43+
</query_log>
44+
<error_log>
45+
<ttl>event_date + INTERVAL 30 DAY DELETE</ttl>
46+
</error_log>
47+
48+
<!-- Profile settings do NOT live here: config.d is silently ignored for them.
49+
See users-override.xml, mounted under users.d. -->
50+
</clickhouse>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<clickhouse>
2+
<profiles>
3+
<default>
4+
<!-- Low-memory settings for the recommended webapp machine size. These were
5+
previously in config.d/override.xml where profile settings are silently
6+
ignored — they only take effect from the users config tree (#4343). -->
7+
<max_block_size>8192</max_block_size>
8+
<max_download_threads>1</max_download_threads>
9+
<input_format_parallel_parsing>0</input_format_parallel_parsing>
10+
<output_format_parallel_formatting>0</output_format_parallel_formatting>
11+
<!-- The memory/query profilers sample stacks into system.trace_log
12+
(a Memory/MemoryPeak sample every 4 MB allocated, by default) — the main
13+
firehose that fills it. trace_log is disabled in override.xml; turn the
14+
samplers off too so they don't burn CPU producing discarded rows. -->
15+
<memory_profiler_step>0</memory_profiler_step>
16+
<memory_profiler_sample_probability>0</memory_profiler_sample_probability>
17+
<query_profiler_real_time_period_ns>0</query_profiler_real_time_period_ns>
18+
<query_profiler_cpu_time_period_ns>0</query_profiler_cpu_time_period_ns>
19+
</default>
20+
</profiles>
21+
</clickhouse>

hosting/docker/webapp/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ services:
177177
- clickhouse:/var/lib/clickhouse
178178
- ../clickhouse/data-paths.xml:/etc/clickhouse-server/config.d/data-paths.xml:ro
179179
- ../clickhouse/override.xml:/etc/clickhouse-server/config.d/override.xml:ro
180+
- ../clickhouse/users-override.xml:/etc/clickhouse-server/users.d/override.xml:ro
180181
networks:
181182
- webapp
182183
healthcheck:

0 commit comments

Comments
 (0)