SKIP LOCKED

SKIP LOCKED is a locking-read option in MySQL 8.4 InnoDB that skips rows already locked by other transactions instead of waiting for them. When used with FOR UPDATE, it lets multiple outbox workers claim different available rows concurrently, reducing contention between workers.

Minimal example

sql
START TRANSACTION;

SELECT id, topic, key_, payload
FROM outbox
WHERE sent_at IS NULL
ORDER BY id
LIMIT 10
FOR UPDATE SKIP LOCKED;

-- Process the selected rows.
UPDATE outbox SET sent_at = NOW(3) WHERE id IN (...);

COMMIT;

Learn this concept

Lesson 3.21 · Refresh families, relay locking, login throttling

Used in exercises

Exercise 3.23 · Concurrent outbox relay
Prerequisite conceptsTransactionTransactional outbox