I used to have a tomcat
connection pool configuration restricting the initial pool size: spring.datasource.tomcat.initial-size=2
Now switch
I just found out it had to do with my configuration of multiple datasources.
In general, the property spring.datasource.hikari.minimum-idle=2
automatically restricts the startup pool size correctly!
But if having multiple data sources, there was a configuration property missing, as follows:
@Bean
@ConfigurationProperties("spring.datasource.secondary.hikari")
public DataSource secondatyDataSource() {
return ...
}
Before I just had "spring.datasource.secondary"
, and there by my property "spring.datasource.secondary.hikari.*"
was not taken into account.
This is probably wrong documented in https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html
You can use these properties provided in spring boot:
spring.datasource.hikari.minimumIdle=5
spring.datasource.hikari.maximumPoolSize=8
and then:
spring.datasource.hikari.idleTimeout=120000
to limit the life of idle connections, but hikari doesn't give you such property for initial number of connections.
With spring boot, set these properties in your application.properties.
spring.jpa.hibernate.hikari.minimumIdle=5
spring.datasource.hikari.maximum-pool-size=10