springboot采用默认连接池hikaricp,系统在线上运行后,经常会突然大批量报错:nested exception is org.apache.ibatis.exceptions.PersistenceException:
error-1001.log-### 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 5009ms
数据库用的是Oracle 11g。
这种情况是偶然的,不是一直出现,一旦出现就会大批量报错。
我开启debug日志后,发现有如下错误:
- Failed to validate connection oracle.jdbc.driver.T4CConnection@1c16e38e (关闭的连接). Possibly consider using a shorter maxLifetime value.
- Closing connection oracle.jdbc.driver.T4CConnection@1c16e38e: (connection is dead)
- Failed to validate connection oracle.jdbc.driver.T4CConnection@65814e22 (关闭的连接). Possibly consider using a shorter maxLifetime value.
Closing connection oracle.jdbc.driver.T4CConnection@65814e22: (connection is dead)
- Failed to validate connection oracle.jdbc.driver.T4CConnection@739a232f (关闭的连接). Possibly consider using a shorter maxLifetime value.
Closing connection oracle.jdbc.driver.T4CConnection@739a232f: (connection is dead)
- Failed to validate connection oracle.jdbc.driver.T4CConnection@1c0ea44b (关闭的连接). Possibly consider using a shorter maxLifetime value.
- Closing connection oracle.jdbc.driver.T4CConnection@1c0ea44b: (connection is dead)
- Failed to validate connection oracle.jdbc.driver.T4CConnection@402488c1 (关闭的连接). Possibly consider using a shorter maxLifetime value.
- Closing connection oracle.jdbc.driver.T4CConnection@402488c1: (connection is dead)
Timeout failure stats (total=31, active=0, idle=31, waiting=0)
我对连接池参数做出各种调整,比如调低maxLifetime,修改,均无作用。系统访问量很低,orm用的mybatis,每个接口的查询速度非常快。
看着是获取连接超时了,缩小一下minimum-idle,亦或是调小一下 idle-timeout