Affects: Spring Boot 2.7.5
I set following environment variables:
JAVA_TOOL_OPTIONS:-Dlogging.level.com.zaxxer.hikari.HikariConfig=DEBUG
-Dlogging.level.com.zaxxer.hikari=TRACE
SPRING_DATASOURCE_MAX_LIFETIME: "600000"
During startup following is logged:
maxLifetime................................1800000 While it should be 600000.
After debugging I think I understand the reason: during bean initialization 'getConnection' gets called, which results in initializing the pool with the default values, and the validation of the hikaripool logs the output.
See this state:
It seems not right to me to call 'getConnection' during bean initialization, but because Spring just invokes all get methods on the bean this goes wrong.
After this Hikari will create new connections and corresponding pool entries using PoolEntryCreator::call. These have the right settings, but the first connection not, which results in unexpected connection behavior.
Comment From: sbrannen
This sounds like it might be an issue better addressed by the Spring Boot team.
Comment From: wilkinsona
I can't reproduce the described behavior – with the configuration above getConnection() is not called during property binding. I can reproduce the problem if a try to configure a non-existent property that uses .connection. in its name, for example:
spring.datasource.hikari.connection.some-property=some-value
This is user error as there are no such properties. @dkwakkel please check your configuration for any properties that begin with spring.datasource.hikari.connection. and remove them. You may want to use Actuator and its config props and env endpoints to help with this. Also, please note that spring.datasource.max-lifetime has no effect and spring.datasource.hikari.max-lifetime should be used instead.
If the above does not help and the problem persists, please provide a complete yet minimal sample that reproduces the problem and we can re-open this issue and take another look.