Skip to content

Add optional DUCKDB_MEMORY_LIMIT applied at connect - #130

Merged
jghoman merged 1 commit into
mainfrom
jakob/duckdb-memory-limit
Aug 26, 2026
Merged

jghoman merged 1 commit into
mainfrom
jakob/duckdb-memory-limit

Conversation

@jghoman

@jghoman jghoman commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Uncapped, DuckDB budgets ~80% of the cgroup limit and competes with the Arrow pending buffer for RSS during the partitioned INSERT — the charts#14038 OOM shape (1GB Arrow buffers OOMKilled the events consumers at 5940Mi). When DUCKDB_MEMORY_LIMIT is set (e.g. "6GB"), connect() applies SET memory_limit through the existing _sanitize_setting_value guard, so DuckDB spills to the temp dir beside the on-disk database file (the /tmp emptyDir in k8s) instead of growing RSS. Spilling requires a file-backed DUCKLAKE_CONNECTION — the chart uses /tmp/duck.db; the code comment documents the :memory: caveat.

Unset or empty leaves behavior unchanged (a chart rendering value: "" is treated as unset — tested). Older images ignore the env var harmlessly.

Companion to the pending charts change raising events-nrt FLUSH_SIZE to 1.5GiB with a 12Gi limit; the chart will set duckdbMemoryLimit: "6GB" per-consumer there. Follows #129 (both were flagged by the adversarial review of that charts change).

Verification

just lint / just fmt-check clean; 692 unit, 65 integration, 4 e2e pass locally (cherry-picked from the reviewed branch; unit suite re-run post-pick).

Uncapped, DuckDB budgets ~80% of the cgroup limit and competes with
the Arrow pending buffer for RSS during the partitioned INSERT — at
large FLUSH_SIZE the sum can OOM the pod (charts#14038 saw exactly
this shape at 1GB Arrow buffers). With a cap, DuckDB spills to the
temp dir beside the on-disk database file (the /tmp emptyDir in k8s)
instead of growing RSS.

Opt-in via DUCKDB_MEMORY_LIMIT (e.g. "6GB"); unset or empty leaves
the default behavior. The value passes through the existing
_sanitize_setting_value guard. Companion to the events-nrt FLUSH_SIZE
increase in charts; the chart sets it per-consumer.
@jghoman
jghoman merged commit 9df39b1 into main Aug 26, 2026
17 checks passed
@jghoman
jghoman deleted the jakob/duckdb-memory-limit branch August 26, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant