Self-hosted ClickHouse disk fills up — lightweight-deleted rows never reclaimed #13969
Describe your questionTL;DRWe self-host Langfuse. The We'd like to know whether this is expected, and what the recommended way to keep disk usage bounded is on a self-hosted setup. Our setup
What happensWhen the retention window passes, Langfuse runs: DELETE FROM observations WHERE project_id = '…' AND start_time < …ClickHouse handles that as a lightweight delete — it marks the rows invisible but does not remove their bytes from disk. The space is supposed to come back later when ClickHouse merges the affected data parts in the background. In practice that doesn't happen for us:
So the deleted rows just sit there, forever, taking up disk. Concrete numbers from todayAmong the parts that contain lightweight-deleted rows on our cluster right now:
The April partitions are interesting: every row in them is well past the 14-day cutoff, they are 100% logically deleted, but they still occupy full disk space because nothing ever drops them. How we currently keep the disk from filling upWe manually run, against the cluster, whenever disk usage gets uncomfortable: ALTER TABLE observations ON CLUSTER '<cluster>'
APPLY DELETED MASK IN PARTITION '<yyyymm>';This rewrites only the affected parts and physically drops the deleted rows. The last run reclaimed about 360 GiB per replica in ~17 minutes. It works, but:
Questions
Langfuse Cloud or Self-Hosted?Self-Hosted If Self-HostedNo response If Langfuse CloudNo response SDK and integration versionsNo response Pre-Submission Checklist
|
Replies: 5 comments 4 replies
|
This is a known challenge with self-hosted ClickHouse deployments at scale. Here's what the documentation covers and some gaps: What Langfuse DocumentsFor ClickHouse disk management, the recommended approach is to use ClickHouse's TTL feature to automatically remove data from the For slow or timing-out deletions, you can increase On ClickHouse 25.7 and above, you can reduce mutation pressure by opting into lightweight deletes and updates: (1)
Both reduce the amount of background merge work ClickHouse performs on deletion-heavy workloads. (1) For larger deployments where ClickHouse disk growth becomes an operational bottleneck, consider ClickHouse Cloud or BYOC. These deployments separate storage from compute, so storage can grow independently of the compute that serves Langfuse queries. (1) What's Not DocumentedYour specific scenario—where lightweight-deleted rows never get physically reclaimed due to parts exceeding
Recommendations Based on Available Info1. Your manual 2. For fully-aged-out partitions (like your April data at 100% deleted), 3. You might consider raising 4. The questions about daily partitioning and official self-hosted maintenance playbooks would be good feature requests for the Langfuse team—these aren't covered in current documentation. 📚 Sources: Have another question? Just tag @inkeep. |
|
@KarolisKont Thank you for sharing detailed findings. I think the easiest way is run CRON Job ( Doc: https://clickhouse.com/docs/sql-reference/statements/alter/apply-deleted-mask Let me check if we have any plans to change the partition scheme for ClickHouse tables. |
|
Hi @KarolisKont I will explore adding an internal
This should also be acceptable provided you don't have tenants with retention longer than 14 days. |
|
@KarolisKont Please let us know if your ask has been answered. |
|
FWIW, I ran into this as well. The data retention job was running, but disk space was not getting reclaimed. Running |
Hi @KarolisKont I will explore adding an internal
APPLY DELETED MASKroutine. Meanwhile running it on cron is the way to go.This should also be acceptable provided you don't have tenants with retention longer than 14 days.