Caused by: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction

发布时间 2023-09-28 09:43:20作者: h*z

153392398	RUNNING	2023-08-23 09:10:09			6	397413			0	2	4	1136	2	2	0	REPEATABLE READ	1	1		0	0	0	0	
328854561014064	RUNNING	2023-08-23 09:19:03			0	397493			0	0	0	1136	0	0	0	REPEATABLE READ	1	1		0	0	0	0	
328854560997800	RUNNING	2023-08-23 09:06:41			0	397338			0	0	0	1136	0	0	0	REPEATABLE READ	1	1		0	0	0	0

解决方案

1.首先执行这条sql,找到对应的trx_mysql_thread_id字段

SELECT * FROM information_schema.INNODB_TRX;

2.再执行这条sql,查看有无数据

select * from performance_schema.data_locks;

3.如果上面两张表有数据

执行kill trx_mysql_thread_id,重新执行2中的sql,若是查不到数据 说明就可以了。

至于具体原因以及原理 后续再了解,暂时解决这个报错