mysql 数据库连接 aborted connection问题处理

1、问题现象:

应用连接mysql数据库出现超时情况,错误信息如下所示:

2022-12-15 14:13:13.831 ERROR 1548945 --- [ XNIO-1 task-12] c.s.v.c.f.s.h.GlobalBizExceptionHandler  : 全局异常信息 ex=nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
### The error may exist in cn/seres/vst/testCase/mapper/TestProgramMapper.java (best guess)
### The error may involve cn.seres.vst.testCase.mapper.TestProgramMapper.selectList
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
2、问题分析:

分析mysql数据库日志,发现存在连接超时和通讯包错误的信息

造成mysql出现aborted_connects可能原因是:

a、程序退出前,客户机程序没有调用mysql_close()

b、客户端睡眠时间超过了wait_timeout或interactive_timeout参数的秒数;

c、客户端程序在数据传输过程中终止。

按照这个思路,马上排查程序配置,发现程序使用的连接池设置的超时时间大于mysql的超时时间

3、解决方案

修改mysql数据库wait_timeout和interactive_timeout参数,由默认28800修改为程序连接池设置的超时时间600000,问题现象得以解决。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值