ClickhouseQian LiTutorial
Durable and auditable workflows with DBOS and ClickHouse Managed Postgres
Summary
DBOS is an open-source, Postgres-native durable execution library that stores workflow state, step checkpoints, queues, schedules, and messages directly in Postgres, enabling failure recovery from the last completed step without restarting. ClickHouse Managed Postgres provides the operational database for running DBOS workflows with fast NVMe performance. To manage storage growth while retaining history for auditing, WalShadow replicates workflow data from Postgres to ClickHouse by reading the Postgres Write-Ahead Log, with soft deletes that keep tombstoned rows via metadata columns _is_deleted and _commit_ts. This retains execution history for years in ClickHouse, such as three years for compliance, while removing it from Postgres after a shorter retention like seven days, recording deletion timestamps. Developers can then query historical and deleted workflows in ClickHouse to analyze failures and build dashboards without a custom data export pipeline.
Context
Building reliable applications is hard because failures can happen at any step, such as timeouts or crashes. Production systems also need to retain and analyze workflow history for auditing without overwhelming the operational database with storage and maintenance overhead.
Approach / What changed
Set up DBOS with ClickHouse Managed Postgres as the operational database. Use WalShadow to automatically replicate workflow data from Postgres to ClickHouse by reading the Postgres Write-Ahead Log. Enable soft deletes on WalShadow to keep tombstoned rows in ClickHouse after deletion from Postgres, allowing long-term auditing and analytics.
Takeaways
DBOS stores workflow execution state in Postgres, allowing workflows to recover from failures from their last completed step rather than restarting.
WalShadow replicates Postgres data to ClickHouse via the WAL with soft deletes, preserving deleted workflow records as tombstoned rows with commit timestamps for auditing.
This combination provides durable execution and scalable analytics without requiring a separate orchestration server or a custom data export pipeline, using ClickHouse for long-term history.
FAQ
How does DBOS recover from failures?
If an application process fails or restarts, DBOS recovers workflows from their last completed step because execution state is stored in Postgres. This avoids restarting work from the beginning.
How can I retain workflow history for years without overloading Postgres?
Use WalShadow to replicate workflow data to ClickHouse with soft deletes. Tombstoned rows are kept in ClickHouse after deletion from Postgres, allowing long-term retention for compliance while Postgres only keeps recent data.
What metadata does WalShadow add to replicated rows?
WalShadow appends four metadata columns: _lsn, _xid, _commit_ts, and _is_deleted. A deleted row in Postgres arrives as a new version with _is_deleted=1 and _commit_ts set to the delete transaction's commit time.
Source and freshness
- Source
- clickhouse.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.