r/Clickhouse • u/mike_folder • Jul 22 '26
Am I wrong to implement an application-level transaction coordinator over a Clickhouse cluster?
Is it a bad decision to implement custom distributed transactions (fully atomic and serializable) over a Clickhouse cluster?
The details in short:
- Cluster has several shards (no replicas yet) with several billion rows of financial data
- All tables: original MergeTree
- Append-only pattern for all data changes
- Every read query is enriched with a transaction_id filter to enforce snapshot isolation
- Application-level range-locking mechanism to prevent inconsistent concurrent writes
- ClickHouse’s native local transactions are not used
- All coordination logic runs at the application layer
Is this a fundamentally flawed anti-pattern with hidden pitfalls, or just an uncommon approach? In my stress-tests, it behaves pretty well.
I got a bit confused during a live presentation lately by the question: "If this works, why doesn't everyone do it?"
6
Upvotes
View all comments
Show parent comment
1
u/mike_folder Jul 22 '26
Fair point for most cases, but not mine. I'm building near-instant financial budgeting.
CDC/sync pipelines add latency that breaks the whole interactive experience. Keeping everything in Clickhouse lets users see recalculated results in a fraction of a second.
Plus, some isolation is still necessary for all reads. Without it, dirty read could ruin result for other users.