生产异常 Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceed

1、程序中报错日志:

Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: 
Lock wait timeout exceeded; try restarting transaction;
 Lock wait timeout exceeded; try restarting transaction; 
nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: 
Lock wait timeout exceeded; try restarting transaction

 

 

2、查看未提交事务:

select * from  information_schema.INNODB_TRX;

SELECT 
    a.id,a.user,a.host,b.trx_started,b.trx_query 
FROM information_schema.processlist a RIGHT OUTER JOIN information_schema.innodb_trx b
ON a.id = b.trx_mysql_thread_id;

 

 

 

 

3、手动执行该update语句,失败,等待锁超时:

update orders set *** where id='79302e18a8e848ccb2323c48ca4ca349';

update orders set *** where id='aeff09dbbc1a4668bf959f675d536ece';

 

4、由于是生产,急需处理业务数据,所以临时解决方案,是先kill 掉,未能提交事务的线程,

kill  trx_mysql_thread_id(上图中的trx_mysql_thread_id是10, 所以 执行  kill  10)

目前的解决方案,就是手动kill掉长期挂起,未提交的事务。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值