Hikari 和测试借用选项
Hikari and test on borrow option
我使用 spring boot 2 和 Hikari
连接池、jpa 和 postgres。
是否有任何理由继续使用这些选项
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.testWhileIdle
不,它们是 Hikari 连接池的未知属性,因此不需要,
它们仅存在于您不再使用的 Tomcat JDBC Connection Pool(用于旧的 Spring 引导)。
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
我使用 spring boot 2 和 Hikari
连接池、jpa 和 postgres。
是否有任何理由继续使用这些选项
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.testWhileIdle
不,它们是 Hikari 连接池的未知属性,因此不需要,
它们仅存在于您不再使用的 Tomcat JDBC Connection Pool(用于旧的 Spring 引导)。
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