Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hikari and test on borrow option

I use spring boot 2 with Hikari connection pool, jpa and postgres.

Is there any reason to continue to use theses options

spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.testWhileIdle
like image 360
robert trudel Avatar asked Dec 20 '18 14:12

robert trudel


1 Answers

No, They are unknown properties to Hikari connection pool so no need ,

They exists only in Tomcat JDBC Connection Pool (used in old Spring boot) which you aren't using anymore.

Explanation of different between properties

DBCP testOnBorrow=false rollbackOnReturn=false enableAutoCommitOnReturn=false

Issues:

testOnBorrow=false increases the likelihood of broken connections given to your application rollbackOnReturn=false + enableAutoCommitOnReturn=false, like the C3P0 "remediation" above can bleed transactions between consumers or cause locks to be held for extended periods

HikariCP Differentiators

Tests connections with isValid() before returning them from the pool, with an optimization that bypasses the check if the connection was utilized within the last 1000ms Tracks connection state (and transaction state), and performs rollback() only the the case of a non-autocommit connections with uncommitted changes

like image 83
user7294900 Avatar answered Nov 16 '22 05:11

user7294900