程序忽然提示异常:
com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
字面意思上看,大致是数据库表被锁定了,建议重启事务。
查了下公司wiki,可以有如下操作建议:
查询是否锁表
show OPEN TABLES where In_use > 0;
查询进程
show processlist
查询到相对应的进程===然后 kill id
查看正在锁的事务
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
查看等待锁的事务
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
查看事务锁
SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX ORDER BY trx_started