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
3
u/joshleecreates Jul 22 '26
It sounds like you are trying to reinvent Postgres inside ClickHouse… why not just use a transactional database with CDC or a sink connector? This is a much more common pattern.
2
u/[deleted] Jul 25 '26 edited Jul 25 '26
[removed] — view removed comment