I’m experiencing a strange behavior with HikariCP in my Spring Boot application. Even though there are idle connections available, HikariCP seems to be creating new connections instead of using the idle ones.
Below is my HikariCP configuration:
spring:
datasource:
hikari:
connection-timeout: 30000
minimum-idle: 20
maximum-pool-size: 20
idle-timeout: 10000
max-lifetime: 30000
auto-commit: false
The application runs fine for a while with the following status:
HikariPool-1 - Pool stats (total=20, active=0, idle=20, waiting=0)
However, when a large batch job is executed, a DB connection exception occurs. The problem is resolved when I increase the maximum-pool-size. The log then looks like this:
HikariPool-1 - Pool stats (total=24, active=4, idle=20, waiting=0)
My question is, why is my configuration creating new connections instead of using the idle ones when needed?
Expected status before I increased maximum-pool-size:
HikariPool-1 - Pool stats (total=20, active=4, idle=16, waiting=0)
Is there something wrong with my settings, or is there another issue I might be missing?
Additional Information:
- Spring Boot version: 3.1.10
Any insights or suggestions would be greatly appreciated!