springboot项目中redis连接超时问题

问题出现原因:

     用户登录后,停留在页面,一段时间不操作,再去使用相关功能提示IO异常,主机强制关闭了一个已有的连接

解决:

查询服务器相关的日志报出大量以下错误内容

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-3 - Connection is not available, request timed out after 30001ms.

### The error may exist in tfgic/tdcr/dao/ContractBaseInfoMapper.java (best guess)

### The error may involve tfgic.tdcr.dao.ContractBaseInfoMapper.selectCount

### The error occurred while executing a query

### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-3 - Connection is not available, request timed out after 30001ms.]

 org.mybatis.spring.MyBatisSystemException: 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-3 - Connection is not available, request timed out after 30001ms.

### The error may exist in tfgic/tdcr/dao/ContractBaseInfoMapper.java (best guess)

### The error may involve tfgic.tdcr.dao.ContractBaseInfoMapper.selectCount

### The error occurred while executing a query

### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-3 - Connection is not available, request timed out after 30001ms.

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)

 

乍一看以为是HikariPool连接池有问题,查阅了大量相关资料去修改HikariPool连接池配置,都不生效。将项目在本地运行,测试同样的接口,想着控制台可能会提示不同的错误,发现控制台报了redis的IO异常,以及其他相关错误,确认不是HikariPool连接池相关问题,从而转入到redis 的问题排查。

第一阶段参考:http://www.classinstance.cn/detail/77.html

该博客内容出现问题和项目遇到的问题类似,经过修改排查,最终发现问题

第二阶段参考:https://blog.csdn.net/xianyirenx/article/details/84207393

第二篇博客算是对问题确认的博客,因为springboot配置连接池的时候使用的是jedis,所以在pom中排除lettuce引用,解决问题。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值