mysql 异常 Lock wait timeout exceeded; try restarting transaction;expc=java.sql.SQLExcept

这种一般是等锁超时了,可以设置延长等锁时间。

mysql> set innodb_lock_wait_timeout=100

Query OK, 0 rows affected (0.02 sec)
查询当前等锁时间
mysql> show variables like 'innodb_lock_wait_timeout';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| innodb_lock_wait_timeout | 100   |
+--------------------------+-------+
但我们更倾向于找出耗时长的sql,看是哪里hold住了。
SHOW ENGINE INNODB STATUS\G 

You can see list of locked tables by-

 show open tables where in_use>0;

查看当前在用的线程。

show full processlist;
如果是之前的线程,可以查看慢日志。先到 Mysql的配置文件查看slow log的日志目录,再到该目录查看日志。
posted @ 2018-04-13 09:51  yansum  阅读(170)  评论(0编辑  收藏  举报