PostgreSQL SKIP LOCKED
TIL about a specific clause introduced in PostgreSQL 9.5: SKIP LOCKED
It extends the SQL FOR UPDATE clause. While FOR UPDATE creates an exclusive row lock, adding SKIP LOCKED instructs the query to simply skip over any rows that are currently locked by another transaction, rather than waiting for them to be released.
This is the key mechanism that makes database-backed job queues viable at scale.
SolidQueue uses this to act as a robust alternative to Redis. By running SELECT ... FOR UPDATE SKIP LOCKED, multiple workers can query the table simultaneously and claim unique jobs without running into lock contention or blocking one another.