mysql数据库修改数据出现报错如下
Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
经查询说是数据库表死锁了,
首先查询这个表是否正在使用
SHOW OPEN TABLES WHERE in_use>0 AND `table` ='community_channel'
In_use为1表示这个表正在使用
然后查询进程
SHOW PROCESSLIST
# 或者
SELECT * FROM information_schema.processlist WHERE db = 'dayun-tsp-community';
查询发现当前表正在执行删除命令,但是query end有未完成的事务。
解决掉该进程
kill 279855
这里正常杀死这个进程。
查看正在锁定的事务
select * from information_schema.innodb_locks;
查看等待上锁的事务
select * from information_schema.innodb_lock_waits;