// MySQL error reference

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
Error message
Statement aborted because lock(s) could not be acquired immediately and NOWAIT is set.

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

  1. Handle 3572 in code as a busy signal: retry later or pick other work.

  2. For job queues, SKIP LOCKED is 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

More transactions and locking errors

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.

// fewer errors, faster fixes

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.