Explaining the concept of a Postgres-backed durable execution system like DBOS and comparing it to external workflow orchestration systems like Temporal.
The article fails to actually explain how to do durable workflows in Postgres:
In a Postgres-backed durable workflows system, application servers directly communicate with Postgres to execute workflows instead of going through a central orchestrator. A client submits a workflow for execution by creating an entry for it in a Postgres workflows table. Application servers poll the table for workflows to dequeue and execute. As a server executes a workflow, it checkpoints the output of each step to Postgres. If a server executing workflows crashes or fails, another server can recover its workflows from their checkpoints.
What you want are a locking clause (FORUPDATE for example) to “acquire” an item from your queue and SKIP LOCKED to skip over rows that are being processed. Contrary to what you’d normally do, you’d hold a long-running transaction which maintains a lock on the row you’re processing, then on completion either commits (success) or rolls back (failure) its changes to that row.
The article fails to actually explain how to do durable workflows in Postgres:
What you want are a locking clause (
FOR UPDATEfor example) to “acquire” an item from your queue andSKIP LOCKEDto skip over rows that are being processed. Contrary to what you’d normally do, you’d hold a long-running transaction which maintains a lock on the row you’re processing, then on completion either commits (success) or rolls back (failure) its changes to that row.You also don’t want to poll. Use
LISTENinstead.Don’t forget
NOTIFYI think this is a decent explanation: https://www.mgaillard.fr/2024/12/01/job-queue-postgresql.html