mysqldude
Error codes › 1205

MySQL & MariaDB error 1205: Lock wait timeout exceeded; try restarting transaction

Error messageLock wait timeout exceeded; try restarting transaction
Example from our test runs: Lock wait timeout exceeded; try restarting transaction (5.6.51)

A statement waited longer than innodb_lock_wait_timeout (50 seconds by default) for a row lock held by another transaction, and gave up. Only that statement is rolled back, not the whole transaction.

MySQLMariaDB
SymbolER_LOCK_WAIT_TIMEOUTER_LOCK_WAIT_TIMEOUT
SQLSTATEHY000HY000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

InnoDB locks the rows a transaction changes until it commits or rolls back. Another transaction that needs the same rows waits; after innodb_lock_wait_timeout seconds it gets 1205. Unlike a deadlock (1213), nothing is wrong with the waiting statement: it is blocked by someone else.

By default only the statement that timed out is rolled back; the rest of its transaction stays open (unless innodb_rollback_on_timeout is on), so your application must decide whether to retry the statement or roll back.

Why it happens

  • A transaction that stays open too long: a script that updates rows and then does slow work before committing, or a forgotten BEGIN in an interactive session or GUI tool.
  • An UPDATE / DELETE without a usable index locks far more rows than needed (it locks every row it scans).
  • Long batch jobs competing with online traffic for the same rows.

How to fix it

  • Find the blocker while it is happening. On MySQL 8.0 use SELECT * FROM sys.innodb_lock_waits\G; on MariaDB and older MySQL, information_schema.INNODB_TRX shows open transactions and trx_mysql_thread_id tells you which connection to look at (or KILL).
  • Keep transactions short: do the slow work before BEGIN, commit as soon as the writes are done.
  • Index the columns used in the WHERE of updates and deletes, so InnoDB locks only the rows it changes.
  • Retry the statement in the application. Raising innodb_lock_wait_timeout only makes the wait longer.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE acct (id INT PRIMARY KEY, bal INT) ENGINE=InnoDB;
    INSERT INTO acct VALUES (1, 100);
  2. Session A: open a connection, start a transaction and change row 1, but don't commit.

    USE demo;
    START TRANSACTION;
    UPDATE acct SET bal = 0 WHERE id = 1;
    -- leave this session open
  3. Session B: in a second connection, change the same row. It waits for A's lock (2 seconds here instead of the default 50).

    USE demo;
    SET SESSION innodb_lock_wait_timeout = 2;
    UPDATE acct SET bal = 50 WHERE id = 1;
  4. Session A: COMMIT (or ROLLBACK) releases the lock.

    COMMIT;

You get: ERROR 1205 (HY000) at line 1: Lock wait timeout exceeded; try restarting transaction(11.8.9)

Verified fixes

  1. Find the blocking transaction while it waits (sys.innodb_lock_waits on MySQL; information_schema on MariaDB)

    While session B is waiting, a third session shows who holds the lock. MySQL 8.0+:

    SELECT waiting_pid, waiting_query, blocking_pid, blocking_query FROM sys.innodb_lock_waits;

    MariaDB and older MySQL: list open transactions and their connection ids, then KILL the blocker if needed.

    SELECT trx_mysql_thread_id, trx_state, trx_started, trx_query FROM information_schema.INNODB_TRX;
    KILL 123;  -- trx_mysql_thread_id of the blocking transaction

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Session A holds a row lock; session B waits longer than innodb_lock_wait_timeout
repro
✓ 1205✓ 1205✓ 1205✓ 1205✓ 1205✓ 1205✓ 1205✓ 1205✓ 1205
Find the blocking transaction while it waits (sys.innodb_lock_waits on MySQL; information_schema on MariaDB)
fix
✓✓✓✓✓✓✓✓✓
Session A holds a row lock; session B waits longer than innodb_lock_wait_timeout repro
MySQL 5.6✓ 12055.7✓ 12058.0✓ 12058.4✓ 12059✓ 1205
MariaDB 10.6✓ 120510.11✓ 120511.4✓ 120511.8✓ 1205
Find the blocking transaction while it waits (sys.innodb_lock_waits on MySQL; information_schema on MariaDB) fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1213 ER_LOCK_DEADLOCKexplained
  • 2013 CR_SERVER_LOSTexplained