Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does Hikari recycle connections?

I please you all for an answer I could not find in the HikariCP doc. Given I set the following pool parameters:

minimumIdle 1
idleTimeout 10 minutes
maxLifeTime 20 minutes

When my app stays idle (with nobody making requests) during the night, I expect Hikari to close each connection 10 minutes after the connection's last request, after the last connection being closed create a new one (and hold it in the pool), and then close and re-create this idle connection every 20 minutes. Did I understood correctly?

The fact is that after an idle period on my app, I see (uppon the next request) the following exception:

WARN  c.z.hikari.proxy.ConnectionProxy - Connection oracle.jdbc.driver.T4CConnection@3c63f80e <POOL_NAME> marked as broken because of SQLSTATE(08003), ErrorCode(17008).
java.sql.SQLRecoverableException: Closed Connection

The connection has probably been closed by Oracle and cannot be used. I'll try to avoid this using the above config. Another point is that I do not understand why I get a closed connection from the pool. This should never happen, as Hikari does test the connection's state before returning it...

Note: I am not the owner of the DB, I cannot configure it or let it be reconfigured to suit my needs. I also have no access to its config.

Our set-up is Spring 4.1.6, Hibernate 4.3.7 with JPA 2.1 API, Hikari 2.1.0

like image 943
Gaël Oberson Avatar asked Nov 15 '15 14:11

Gaël Oberson


People also ask

How does Hikari connection pool work?

"HikariCP is solid high-performance JDBC connection pool. A connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools may significantly reduce the overall resource usage." - You can find out more here.

Does Hikari close connection?

In case if a database is not responding (i.e connection is no more valid) then HikariCP closes this connection and removes it from the pool. Refilling the pool after closing and removing of dead connection is an important step taken by HikariCP when pool state is normal (i.e it's not shut down or suspended).

What is idle connections in Hikari?

Minimum IdleThis property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. If the idle connections dip below this value and total connections in the pool are less than maximumPoolSize , HikariCP will make the best effort to add additional connections quickly and efficiently.

How does HikariCP compare to other connection pools?

The pool restores normal operations after that. HikariCP seems to perform better than the other connection pools we've tested—C3P0, BoneCP, and Apache DBCP. However, when selecting a connection pool, there are other aspects to take into account, such as the configuration options it provides and connection testing.


1 Answers

Your understanding of the pool parameters is correct. It is possible that the Oracle instance has a shorter idle timeout than 10 minutes. One thing you can do is to enable DEBUG level logging for the com.zaxxer.hikari package. You'll get a lot more information about what is going on internally within HikariCP, without being too noisy.

Feel free to post the log as an issue on Github and we'll take a look at it.

like image 173
brettw Avatar answered Oct 14 '22 02:10

brettw