brettwooldridge / HikariCP

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

Support for keepalive specific query #2118

Open mathieufortin01 opened 9 months ago

mathieufortin01 commented 9 months ago

Im thinking of a use case where I want to survive a writer node becoming a reader. I already have connection-init-sql validating this so newly created connections are ok.

I dont want to rely on max lifetime since those are long lived connections.

connection-test-query is executed on every acquisition, and ideally i dont want all acquisitions to have that cost, for rare failover occurences.

The keepalive task is already a backgroud task, and Its my understanding it uses the connection-test-query if present or else the JDBC v4 isValid(), and that on failure will evict the connection. This seems like a good place to cleanup the pool.

Ideally, the isValid() function would be used for connection acquisitions, and the keepalive would use another statement. This implies:

Maybe im over thinking this and having the 'writer node check' at every acquisition is fine. But being able to reduce the keep alive task schedule would also help in that case.