Lock wait timeout exceeded; try restarting transaction

What gives this away is the word transaction. It is evident by the statement that the query was attempting to change at least one row in one or more InnoDB tables.

Since you know the query, all the tables being accessed are candidates for being the culprit.

From there, you should be able to run SHOW ENGINE INNODB STATUS\G

You should be able to see the affected table(s)

You get all kinds of additional Locking and Mutex Information.

Here is a sample from one of my clients:'

You should consider increasing the lock wait timeout value for InnoDB by setting the innodb_lock_wait_timeout, default is 50 sec

mysql> show variables like 'innodb_lock_wait_timeout';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| innodb_lock_wait_timeout | 50 |
+--------------------------+-------+
1 row in set (0.01 sec)
You can set it to higher value in /etc/my.cnf permanently with this line [mysqld]
innodb_lock_wait_timeout=120
and restart mysql. If you cannot restart mysql at this time, run this: SET GLOBAL innodb_lock_wait_timeout = 120;
You could also just set it for the duration of your session SET innodb_lock_wait_timeout = 120;
followed by your query Give it a Try !!!
上一篇:leetcode:程序员面试技巧


下一篇:Android Bitmap相关知识点——类型、创建、压缩、转换等