当前位置:   article > 正文

The last packet successfully received from the server was xx milliseconds ago. The last packet sent

the last packet successfully received from the server was 1,808,721 millisec

同组同事遇到的问题。

完成异常信息如下:

  1. The last packet successfully received from the server was xxx milliseconds ago. The last packet sent successfully to the server was xxx milliseconds ago.
  2. ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
  3. org.springframework.dao.DataAccessResourceFailureException:
  4. ... 203 more
  5. at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2952)
  6. at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2502)
  7. Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

根据异常信息的描述,之后再次使用此数据库连接就说连接丢失了。应该是mysql服务器端超过了wait_time,然后主动关闭了这个连接。但是客户端还从线程池里拿到了这个已经被关闭的连接。所以报了这个错误。

程序也有相应的配置:

testOnConnect: 在连接初始化时执行连接可用性检查testOnBorrow:在借出连接时检查连接可用性testOnReturn:在客户端归还连接时检查连接可用性testWhileIdle:在检查闲置连接时同时检查连接可用性。

最后通过与 DBA 的沟通,由于之前系统存在慢 SQL,所以 DBA 上了一个脚本,超过 20s 的SQL 都会被强制 kill。故产生了此异常信息。

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

闽ICP备14008679号