MySQL服务器连接超时

发布于 2024-10-19 14:51:34 字数 3368 浏览 1 评论 0原文

MySQL服务器连接wait_timeout是28800秒,我的休眠应用程序不断超时(整个应用程序生命周期约为1小时)。

The last packet successfully received from the server was 4,396,266 milliseconds ago.  The last packet sent successfully to the server was 4,405,476 milliseconds ago.

hibernate 使用以下 c3p0 属性,我不明白为什么它超时,即使整个应用程序运行了大约 1 小时,并且空闲时间应该比这少得多。鉴于hibernate的连接超时值为5000秒,加上它每300秒检查一次空闲,为什么会发生这种情况?

<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.max_size">200</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.timeout">5000</property>

更新:详细错误消息:

Caused by: java.sql.BatchUpdateException: Communications link failure

The last packet successfully received from the server was 5,980,742 milliseconds ago.  The last packet sent successfully to the server was 5,9\
87,659 milliseconds ago.
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024)
        at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
        at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421)
        ... 15 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 5,980,742 milliseconds ago.  The last packet sent successfully to the server was 5,9\
87,659 milliseconds ago.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3358)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1970)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976)
        ... 20 more
Caused by: java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3339)

MySQL server connection wait_timeout is 28800 seconds, my hibernate apps keeps timing out(the whole application lifecyle was about 1 hour).

The last packet successfully received from the server was 4,396,266 milliseconds ago.  The last packet sent successfully to the server was 4,405,476 milliseconds ago.

hibernate uses the following c3p0 properties, I don't understand why it timed out even though the whole app ran for about 1 hour and the idle time should be much much less than that. Given that hibernate's connection has a timeout value of 5000 seconds, plus it checks for idle every 300 seconds, why did this happen?

<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.max_size">200</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.timeout">5000</property>

update: detailed error msg:

Caused by: java.sql.BatchUpdateException: Communications link failure

The last packet successfully received from the server was 5,980,742 milliseconds ago.  The last packet sent successfully to the server was 5,9\
87,659 milliseconds ago.
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024)
        at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
        at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421)
        ... 15 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 5,980,742 milliseconds ago.  The last packet sent successfully to the server was 5,9\
87,659 milliseconds ago.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3358)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1970)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
        at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976)
        ... 20 more
Caused by: java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3339)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文