问题出现原因:
用户登录后,停留在页面,一段时间不操作,再去使用相关功能提示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引用,解决问题。