事务超时导致,com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client

由于一定定时任务导致出现的异常信息(部分):

### Error querying database.  Cause: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request

原因是由于执行业务超出了配置的事务超时时间

由于在代码中配置了超时时间为60S,但是业务执行超出了60s导致出现异常

解决方案:

1.调大超时间(不建议)

2.将事务拆成多个小事务(建议)

本人使用第二种

参考文章:

https://izhong.me/index.php/archives/105/

https://zhuanlan.zhihu.com/p/28308813


版权声明:本文为u011186019原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。