[Mysql] mysql-Lock wait timeout exceeded; try restarting transaction


本文总阅读量

1、mysql执行一条update语句报错:

1
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

查看当前系统锁等待超时时间:

1
2
3
4
5
6
7
show variables like '%lock_wait_timeout%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| innodb_lock_wait_timeout | 30 |
| lock_wait_timeout | 60 |
+--------------------------+-------+

innodb事务锁等待超时事件30s,其他非innodb事务锁等待事件超时为60s,

2、查看造成事务阻塞的信息:

select * from information_schema.innodb_trx\G;查看innodb_trx各列参数,点击此处

线程id为1308的事务被线程id为1311的事务阻塞,查看不到线程id为1311正在执行的语句

3、查看事务锁信息,记录了当前锁的相关信息;查看innodb_lock各列参数,点击此处

select * from information_schema.innodb_locks\G

4、查看线程id为1311的线程信息,select * from information_schema.processlist where id=1311\G,


该事务command为sleep,表示事务sql语句已经执行完成,但是锁仍然存在,没有释放手动kill掉该线程,在执行其他操作正常。

1
kill 1311
目录
  1. 1. 1、mysql执行一条update语句报错:
  2. 2. 2、查看造成事务阻塞的信息:
  3. 3. 3、查看事务锁信息,记录了当前锁的相关信息;查看innodb_lock各列参数,点击此处:
  4. 4. 4、查看线程id为1311的线程信息,select * from information_schema.processlist where id=1311\G,

Proudly powered by Hexo and Theme by Lap
本站访客数人次
© 2020 zeven0707's blog