超时机制

网友投稿 612 2022-10-10

超时机制

超时机制

mysql连接的超时问题:Communications link failure

org.springframework.dao.RecoverableDataAccessException: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet successfully received from the server was 1,454,140 milliseconds ago. The last packet sent successfully to the server was 1,454,141Inline### The error occurred while1, consume_xiaomi_id = null, consume_order_id = null, lock_time = null where consume_order_id=? and status=2last packet successfully received from the server was 1,454,140 milliseconds ago. The last packet sent successfully to the server was 1,454,141last packet successfully received from the server was 1,454,140 milliseconds ago. The last packet sent successfully to the server was 1,454,141last packet successfully received from the server was 1,454,140 milliseconds ago. The last packet sent successfully to the server was 1,454,14198) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:82) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy13.update(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294) at com.xiaomi.bss2.dao.MiCouponDao.unfreeze(MiCouponDao.java:23) at com.xiaomi.bss2.service.MiCouponService.unfreeze(MiCouponService.java:27) at com.xiaomi.bss2.main.Bss2ServiceImpl.cancelOrder(Bss2ServiceImpl.java:63) at com.xiaomi.bss2.main.Bss2ServiceImpl$$FastClassBySpringCGLIB$$67f6d028.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:736) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:671) at com.xiaomi.bss2.main.Bss2ServiceImpl$$EnhancerBySpringCGLIB$$ea0735d6.cancelOrder() at com.xiaomi.bss2.main.Bss2ServiceThriftImpl$1.handle(Bss2ServiceThriftImpl.java:35) at com.xiaomi.bss2.main.Bss2ServiceThriftImpl$1.handle(Bss2ServiceThriftImpl.java:32) at com.xiaomi.bss2.main.Bss2ServiceThriftImpl.handle(Bss2ServiceThriftImpl.java:87) at com.xiaomi.bss2.main.Bss2ServiceThriftImpl.cancelOrder(Bss2ServiceThriftImpl.java:32) at sun.reflect.GeneratedMethodAccessor233.invoke(Unknown Source)

原因分析:

MySQL连接时,服务器默认的“wait_timeout”是8小时,也就是说一个connection空闲超过8个小时,Mysql将自动断开该connection。connections如果空闲超过8小时,Mysql将其断开,而DBCP连接池并不知道该connection已经失效,如果这时有Client请求connection,DBCP将该失效的Connection提供给Client,将会造成异常。其中wait_timeout就是负责超时控制的变量,其时间为长度为28800s,就是8个小时,那么就是说MySQL的服务会在操作间隔8小时后断开,需要再次重连。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:CLIFramework - 一个命令行应用程序框架,为构建灵活、简单的命令行应用程序
下一篇:修改表结构 ddl语句
相关文章

 发表评论

暂时没有评论,来抢沙发吧~