From a669df08bd85d508f13b4cd52e9b0d8e963aec6c Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:54:43 +0200 Subject: [PATCH] fix(clickhouse): tune memory settings to prevent OOM on insert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ClickHouse 24.12 auto-sizes caches from the cgroup limit, leaving insufficient headroom for MV processing and background merges. Adds a custom config that shrinks mark/index/expression caches and caps per-query memory at 2 GiB. Bumps container limit 4Gi → 6Gi. Co-Authored-By: Claude Opus 4.6 (1M context) --- deploy/clickhouse.yaml | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/deploy/clickhouse.yaml b/deploy/clickhouse.yaml index 8af4fb06..4e1e3841 100644 --- a/deploy/clickhouse.yaml +++ b/deploy/clickhouse.yaml @@ -40,12 +40,16 @@ spec: mountPath: /var/lib/clickhouse - name: initdb mountPath: /docker-entrypoint-initdb.d + - name: config + mountPath: /etc/clickhouse-server/config.d/memory-tuning.xml + subPath: memory-tuning.xml + readOnly: true resources: requests: memory: "2Gi" cpu: "500m" limits: - memory: "4Gi" + memory: "6Gi" cpu: "2000m" livenessProbe: httpGet: @@ -67,6 +71,9 @@ spec: - name: initdb configMap: name: clickhouse-initdb + - name: config + configMap: + name: clickhouse-config volumeClaimTemplates: - metadata: name: data @@ -95,6 +102,36 @@ spec: --- apiVersion: v1 kind: ConfigMap +metadata: + name: clickhouse-config + namespace: cameleer +data: + memory-tuning.xml: | + + + + + + + + + 2147483648 + + + + + 134217728 + 67108864 + 0 + 67108864 + + + 536870912 + + +--- +apiVersion: v1 +kind: ConfigMap metadata: name: clickhouse-initdb namespace: cameleer