alibaba / alibaba/druid

springboot框架Druid连接池,使用tidb数据库,偶尔出现db连接断开异常

Open
#3,941 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
28.2k
Forks
8.6k
PR merge metrics
No merged PRs in 30d

Description

【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)
略。。。

Contributor guide

Open the contributing guide

Research direction

No repository file, test, or entry point is named. Start by reproducing the CommunicationsException with the listed Spring Boot, Druid, JDBC, and TiDB configuration, then trace the connection failure; done means identifying a reproducible cause and documenting a verified fix or configuration change.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql, spring-boot
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.