r/codereview • u/fervent7 • 17h ago
PostgreSQL persistent task queue: concurrency, idempotency and restart recovery
Hello everyone,
I'm extending an existing Python application that uses PostgreSQL and Supabase for multichain blockchain research.
We have implemented an offline candidate queue with duplicate prevention, retry limits, expiration and restart recovery.
During testing, we identified a potential issue where a stale processing result could affect a newly queued instance of the same candidate.
I would appreciate technical guidance on:
- Using FOR UPDATE SKIP LOCKED for concurrent processing.
- Preventing stale worker results through unique claim identifiers.
- Maintaining idempotency and reliable restart recovery.
- Choosing appropriate indexes and expiration strategies.
Would a dedicated PostgreSQL queue table be the recommended approach?
Any technical feedback or suggestions would be appreciated. Thank you.
View all comments
1
u/Ordinary_Hall_6638 16h ago
Maybe pgmq will be enough for your tasks?