Hikari Connection pool keeps timing out all connections with AWS Aurora

Viewed 2885

Facing an issue where my spring boot application with Hikari CP for Aurora MySQL database keeps timing out all connections after some time. Tried all different settings but not able to resolve. Here is my configuration:

spring.datasource.type=com.zaxxer.hikari.HikariDataSource

spring.datasource.test-on-borrow=true
spring.datasource.test-while-idle=true
spring.datasource.validation-query=select 1 from dual

spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.test-on-borrow=true
spring.datasource.hikari.test-while-idle=true
spring.datasource.hikari.validation-query=SELECT 1 from dual;

spring.datasource.hikari.idleTimeout = 540000
spring.datasource.hikari.idle-timeout = 540000
spring.datasource.hikari.keepaliveTime = 480000
spring.datasource.hikari.keepalive-time = 480000
spring.datasource.hikari.maxLifetime = 0
spring.datasource.hikari.max-lifetime = 0

Because of conflicting documentation around hikari tried using property names both with hyphens and camel case.

1 Answers

Uttam,

My team is getting a similar issue with our Spring Boot application, also using HikariCP, BUT connecting to AWS RDS (MySQL).

We still don't know what's causing the issue per se, but including the property spring.datasource.hikari.leak-detection-threshold={timeInMillis} have been helping us, as it pointed out there has been a connection leak in one of our interceptors.

PS.: I was going for a simple comment instead of a answer but I don't have enough reputation for this.

Edit: Using the leak detection property for Hikari, we found out an interceptor method that was leaking connections. Simply annotating it with Spring Boot's @Transactional solved the issue, but we are trying to figure it out why.

Related