当前位置:   article > 正文

生产报错日志【The last packet successfully received from the server was 5,007 milliseconds ago】

the last packet successfully received from the server was

生产日志报错 显示日志异常为:
The last packet successfully received from the server was 5,007 milliseconds ago. The last packet sent successfully to the server was 5,005 milliseconds ago.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
问题原因:获取到的数据库连接超时了
解决方案:
1、在数据库连接上,加“&autoReconnect=true&failOverReadOnly=false”配置
2、设置数据库连接时间 wait_timeout
注意:连接池连接最大存活时长不应该超过数据库配置
数据库配置连接时间例如:
SET GLOBAL interactive_timeout = 300;
SET GLOBAL wait_timeout = 300;

3、若是是长事务导致的超时,则进行代码优化

相关URL参数可参考:
https://www.cnblogs.com/softidea/p/5765624.html

其他说明

1)配置说明

即使在创建Mysql时url中加入了autoReconnect=true参数,但是如果这个连接两次访问数据库的时间超出了服务器端wait_timeout的时间限制,还是会CommunicationsException: The last packet successfully received from the server was xxx milliseconds ago.
服务器端的参数可以用
show global variables like ‘wait_timeout’;
set global wait_timeout=10;
来进行设置,但是wait_timeout值不应该设的太高.

2)服务启动说明

若是服务配置在nacos或者类似配置中心上面,若是配置信息没有采用热加载方式,需要重启服务器的哦。常规属性值自动刷新的方式:
1》@RefreshScope注解
2》@ConfigurationProperties

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/1014651
推荐阅读
相关标签
  

闽ICP备14008679号