1229
MySQLERRORCommonLockingHIGH confidence
Lock wait timeout exceeded; try restarting transaction
Production Risk
High — frequent timeouts indicate lock contention requiring architectural review.
What this means
ER_LOCK_WAIT_TIMEOUT (1229, SQLSTATE HY000) — an alternate path to the lock wait timeout error — is raised when a transaction waits longer than innodb_lock_wait_timeout seconds to acquire a row lock. The waiting transaction is rolled back.
Why it happens
- 1Long-running transaction holding row locks that another transaction needs
- 2Application failing to commit or rollback transactions promptly
- 3Deadlock-adjacent scenario where one transaction is not automatically chosen as victim
How to reproduce
trigger — this will error
trigger — this will error
-- Session 1: holds lock START TRANSACTION; UPDATE accounts SET balance = 200 WHERE id = 1; -- Session 2: waits and times out START TRANSACTION; UPDATE accounts SET balance = 300 WHERE id = 1; -- waits... ERROR 1229
expected output
ERROR 1229 (HY000): Lock wait timeout exceeded; try restarting transaction
Fix
Identify and terminate blocking transaction
Identify and terminate blocking transaction
SELECT * FROM information_schema.INNODB_TRX; KILL <blocking_thread_id>;
Why this works
Find the blocking transaction and kill it to release the lock.
Sources
Official documentation ↗
MySQL 8.0 — 1229 ER_LOCK_WAIT_TIMEOUT
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev