15
you are viewing a single comment's thread
view the rest of the comments
[-] TehPers@beehaw.org 3 points 2 days ago

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 (FOR UPDATE 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.

You also don't want to poll. Use LISTEN instead.

[-] HelloRoot@lemy.lol 2 points 2 days ago

Don't forget NOTIFY

I think this is a decent explanation: https://www.mgaillard.fr/2024/12/01/job-queue-postgresql.html

this post was submitted on 19 Nov 2026
15 points (94.1% liked)

Programming

29342 readers
344 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS