brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.91k stars 2.92k forks source link

connectionTimeout property is not propagated to Postgres driver creating the connection #2202

Open Jeaksen opened 4 months ago

Jeaksen commented 4 months ago

I'm using HikariCP 5.1.0 and Postgres driver org.postgresql:postgresql:42.6.2.

The HikariConfig.connectionTimeout property is not passed on to the driver - setting the timeout has no effect on the final connection timeout.

image

After some debugging I found that the driver is trying to fetch "loginTimeout" property from the Properties object that is passed to the driver, but that property is never set. During PoolBase initialization the setLoginTimeout method is calling DriverDataSource implementation, which calls DriverManager.setLoginTimeout(seconds), however, the Postgres driver doesn't use this value.

I tested this with an Oracle driver com.oracle.database.jdbc:ojdbc8:21.9.0.0. In that case the property works fine.

For now I made I quick hack for Postgres and during pool configuration I added this line: hikariConfig.addDataSourceProperty("loginTimeout", 3);

quaff commented 4 days ago

The name is ambiguous, but you can refer to the Javadoc, it states wait for a connection from the pool : https://github.com/brettwooldridge/HikariCP/blob/80d30d34c91fa5a2ac3757c6f61cb3177ddc4018/src/main/java/com/zaxxer/hikari/HikariConfigMXBean.java#L29