赞
踩
同组同事遇到的问题。
完成异常信息如下:
- The last packet successfully received from the server was xxx milliseconds ago. The last packet sent successfully to the server was xxx milliseconds ago.
-
- ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- org.springframework.dao.DataAccessResourceFailureException:
-
-
- ... 203 more
- at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2952)
- at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2502)
- 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。故产生了此异常信息。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。