zoukankan      html  css  js  c++  java
  • 超时机制

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

    org.springframework.dao.RecoverableDataAccessException: 
    ### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    The last packet successfully received from the server was 1,454,140 milliseconds ago.  The last packet sent successfully to the server was 1,454,141 milliseconds ago.
    ### The error may involve miCoupon.unfreeze-Inline
    ### The error occurred while setting parameters
    ### SQL: update mi_coupon set status = 1, consume_xiaomi_id = null, consume_order_id = null, lock_time = null where consume_order_id=? and status=2
    ### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    
    The last packet successfully received from the server was 1,454,140 milliseconds ago.  The last packet sent successfully to the server was 1,454,141 milliseconds ago.
    ; SQL []; Communications link failure
    
    The last packet successfully received from the server was 1,454,140 milliseconds ago.  The last packet sent successfully to the server was 1,454,141 milliseconds ago.; nested exception is com.mysql.jdbc.e
    xceptions.jdbc4.CommunicationsException: Communications link failure
    
    The last packet successfully received from the server was 1,454,140 milliseconds ago.  The last packet sent successfully to the server was 1,454,141 milliseconds ago.
            at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:98)
            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(<generated>)
            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(<generated>)
            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小时后断开,需要再次重连。

     

  • 相关阅读:
    《学习OpenCV》第一版课后习题解答
    【练习8.11】等级匹配cvMatchContourTrees、凸缺陷计算cvConvexityDefects
    支持与不支持in-place操作的OpenCV函数汇总
    【练习8.10】直接使用cvFindContour的结果图片和cvDrawContour的方式提取Hu矩,观察在图片缩放或旋转时的稳定性
    【练习8.7】cvGoodFeaturesToTrack确定图像强角点、cvFindCornerSubPix亚像素级角点检测
    【练习8.6】使用不同参数值观察cvFindDominantPoints寻找关键点的效果
    【练习8.5】轮廓长度计算机cvApproxPoly逼近
    【练习8.2】使用指定标志创建序列cvCreateSeq、在序列中插入元素
    【练习8.1】查找轮廓、寻找关键点cvFindDominantPoints、访问序列中的元素
    C或C++中struct内存对齐计算精简方案
  • 原文地址:https://www.cnblogs.com/igoodful/p/12073098.html
Copyright © 2011-2022 走看看