Build a safe job queue with SKIP LOCKED
FOR UPDATE SKIP LOCKED lets multiple workers pull from the same queue table without stepping on each other, worker two grabs the next batch instead of stalling on the rows worker one already holds.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
Multiple workers polling a queue with plain SELECT ... FOR UPDATE all try to lock the same top rows, so they serialize and stall. SKIP LOCKED tells each worker to ignore rows another worker already locked and take the next available ones.
Two Meridian dispatch workers pull from dispatch_jobs. Worker one holds jobs 1-5; worker two should immediately take 6-10, not wait behind worker one.
Simple terms
When several workers pull jobs from the same table with a plain SELECT ... FOR UPDATE, they all reach for the same top rows and end up waiting in line for each other. Adding SKIP LOCKED tells each worker to ignore any row another worker has already locked and just take the next free ones. That turns a queue that serializes into one where every worker keeps moving.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other Locking & concurrency runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.