MySQL error 3572: Lock couldn't be acquired with NOWAIT
A SELECT ... FOR UPDATE NOWAIT or FOR SHARE NOWAIT found a row locked by another transaction and failed at once instead of waiting.
- Error number
3572- Name
ER_LOCK_NOWAIT- SQLSTATE
HY000- Category
- Transactions and locking
What it means
NOWAIT (MySQL 8.0 and later) tells InnoDB not to wait for row locks. If any row the statement needs is locked, the statement fails immediately with 3572. It's the expected outcome of using NOWAIT, which applications use to try something else rather than block.
Common causes
- Another transaction holds a lock on one of the selected rows.
- Several workers trying to claim the same job rows.
How to fix it
-
Handle 3572 in code as a busy signal: retry later or pick other work.
-
For job queues,
SKIP LOCKEDis usually better: it skips locked rows instead of failing.START TRANSACTION; SELECT id FROM jobs WHERE status = 'pending' ORDER BY id LIMIT 10 FOR UPDATE SKIP LOCKED; -- process and update the claimed rows COMMIT;
Related errors
1205Lock wait timeout exceeded55P03PostgreSQL: lock not availableORA-00054Oracle: resource busy and acquire with NOWAIT specified
More transactions and locking errors
1213Deadlock found when trying to get lock1206Locks exceed the lock table size1792Write in a READ ONLY transaction3024Maximum statement execution time exceeded
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.