r/Supabase • • 8d 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

11 comments sorted by

View all comments

Show parent comment

1

u/fervent7 7d ago

That's a fair point. We already have a candidate queue implementation, and the intention is to extend the existing architecture rather than replace it.

The focus should be on lease management, fencing tokens and preventing expired or superseded workers from committing results.

Would you recommend a monotonically increasing fencing token alongside a unique claim ID, or would an atomic claim ID check with appropriate lease validation be sufficient when all writes are contained within PostgreSQL?