r/Supabase • u/fervent7 • 3d ago
database PostgreSQL persistent task queue: concurrency, idempotency and restart recovery
/r/codereview/comments/1y6b5t7/postgresql_persistent_task_queue_concurrency/For those using Supabase, would you recommend Supabase Queues (pgmq) or a dedicated PostgreSQL queue table for this use case? I'm particularly interested in concurrency, stale worker protection and reliable restart recovery.
1
Upvotes
View all comments
Show parent comment
1
u/fervent7 2d ago
Thank you for this detailed and practical recommendation.
Keeping the conditional completion, ownership validation and observation/event inserts within one atomic PostgreSQL transaction makes sense for our existing architecture.
The two failure scenarios you highlighted are particularly important: reassignment while the original worker is paused, and a crash after commit but before acknowledgement.
We'll include both in our regression verification, alongside unique logical result identifiers and restart recovery.
Would you recommend implementing the completion operation as a dedicated PostgreSQL function with restricted execution privileges, or handling it through an application-managed transaction using a least-privilege database role?
I appreciate the PostgreSQL documentation reference and your technical guidance.