异常信息:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 29,742 milliseconds ago. The last packet sent successfully to the server was 29,742 milliseconds ago.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370)
at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3461)
略。。。
【TiDB 版本】:v4.0.4 【问题描述】:javaWeb程序在切换tidb数据库后,偶尔会抛出db连接断开异常,频率是每天4次左右。
框架:springboot2.2.2.RELEASE 连接池:druid1.1.20
连接池配置:
datasource druid pool
spring.datasource.dynamic.druid.filters= stat spring.datasource.dynamic.druid.initial-size=5 spring.datasource.dynamic.druid.max-active=300 spring.datasource.dynamic.druid.min-idle=16 spring.datasource.dynamic.druid.max-wait=60000 spring.datasource.dynamic.druid.time-between-eviction-runs-millis=360000 spring.datasource.dynamic.druid.min-evictable-idle-time-millis=360000 spring.datasource.dynamic.druid.validation-query=SELECT 1 FROM DUAL spring.datasource.dynamic.druid.test-while-idle=true
tidb查询数据源 spring.datasource.dynamic.datasource.datastidb.username=USERNAME spring.datasource.dynamic.datasource.datastidb.password=PASSWORD spring.datasource.dynamic.datasource.datastidb.url=jdbc:mysql://TIDB_DB?useUnicode=true&useSSL=false&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false spring.datasource.dynamic.datasource.datastidb.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.dynamic.datasource.datastidb.type=com.alibaba.druid.pool.DruidDataSource
注:为了不暴露真实的数据源,USERNAME,PASSWORD和TIDB_DB是使用临时的字符串
异常信息: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 29,742 milliseconds ago. The last packet sent successfully to the server was 29,742 milliseconds ago. at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370) at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3461) 略。。。