mysql 总是出现Last packet sent to the server was 18953 ms ago

写一辈子代码吧 发布于 2016/03/24 17:20
阅读 2K+
收藏 1
Last packet sent to the server was 18953 ms ago.
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2622)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2916)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)
    at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5442)
    at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:371)
    at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:328)
    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:91)
    ... 82 more
2016-03-24 17:07:52  WARN JDBCExceptionReporter:100 - SQL Error: 0, SQLState: null

2016-03-24 17:07:52 ERROR JDBCExceptionReporter:101 - Already closed.


网上说:“MySQL默认的空闲等待时间是8个小时,一旦空闲超过8个小时,就会抛出异常”

我这一直操作使用,然后系统操作操作就报这个玩意。


还有说:一般发生在并发比较多时,LAG严重,导致很多连接还未结束但到达默认限制时间便被连接池给kill了。

并没有多少用户/没有多少并发了。

这个什么原因造成的呀!另外一个系统用的同一框架毫无问题!!

加载中
0
写一辈子代码吧
写一辈子代码吧

Your DBCP Connection pool is timing out use the configuration below...

Simple solution is to make DBCP verify connections before giving them to the caller. Add the following properties to your BasicDataSource configuration:

<property name="testOnBorrow" value="true"/>
<property name="validationQuery" value="SELECT 1"/>

For a list of all options see here: http://commons.apache.org/dbcp/configuration.html

EDIT: For slight correction in what is happening see MJB's comment below.

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部