tidb 连接报错

【 TiDB 使用环境】生产环境
【 TiDB 版本】 6.5.1
【遇到的问题:问题现象及影响】
SQLException异常:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

【资源配置】
程序连接数据库配置

tidb:
datasource:
druid: url: jdbc:mysql://xxxx:4000/xxx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
driver-class-name: com.mysql.jdbc.Driver
username: xxx
initialSize: 10
minIdle: 10
maxActive: 100
maxWait: 600000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000

wait_timeout变量值 是 28800,tidb集群 是正常的,会是 连接被 timeout中断之后,程序再用报错了吗

如果用了链接池就把数据库层的waittimeout和connecttimeout去掉,另外可以设置下链接池的保活时间

waittimeout和connecttimeout,这怎么去掉啊

tidb的wait_timeout,28800秒,超时这个时间的sleep连接,会被 tidb kill 吧

您这是 已经在使用的系统 还是 新上线的 ??

这个问题 一般有3种情况:我遇到的

  1. 驱动问题 ,仅仅对于新上线的系统。长时间运行的就不是驱动问题
  2. 数据库断开。 可以设置重连机制 来解决。
  3. 连接数过多。 可以增加tidb 的连接回收时间。 因为连接数太多。导致 无法建立新链接

请参考

很多的系统了

也可能应用的连接池满了。

minIdle: 10
maxActive: 100

连接池最大100个,AP类的应用应该不会

连接池满的话,应该会有pool 之类的关键字吧

这个sleep时间这么长,是wait_timeout没有起作用吗

这是连接池初始化的吧,需要保活

应该是连接池满了吧