FOR UPDATE SKIP LOCKED is the whole queue
A job queue in Postgres needs one query. Workers select pending rows FOR UPDATE SKIP LOCKED, so a row another worker holds gets skipped instead of waited on. There are no advisory locks, no polling table and no second system.
SELECT id, payload FROM jobs
WHERE status = 'pending' AND run_at <= now()
ORDER BY id LIMIT 50
FOR UPDATE SKIP LOCKED;Run the workers at READ COMMITTED. Under REPEATABLE READ they spend all their time retrying serialization failures.
postgresqlqueues