Soft Reset Hikari Pool in case of auto recovery failure

4,320 views
Skip to first unread message

Anupom

unread,
Apr 21, 2015, 8:22:14 PM4/21/15
to hika...@googlegroups.com
Hello Everyone,

We infrequently get into situations similar to the Behavior#3 mentioned here https://github.com/brettwooldridge/HikariCP/issues/159. In cases like these, we end up restarting the server as the pool does not recover by itself. It would be nice if we could somehow force a soft reset of the connection pool and avoid full server restart. I don't know if there's any way to do that now currently. May be something like com.zaxxer.hikari.pool.HikariPool#softEvictConnections() followed by a com.zaxxer.hikari.pool.BaseHikariPool#fillPool() would just do. Seems like there's no public API that does similar thing. Or may be there's something else we can do. I am looking for suggestions.

Thanks.

Brett Wooldridge

unread,
Apr 21, 2015, 9:01:19 PM4/21/15
to hika...@googlegroups.com
First, make sure you are running the latest version (currently 2.3.6) of the pool.  You don't say what database you are using, it is PostgreSQL?  If so, as commented at the end of that bug, one of the things you might try is setting the loginTimeout property on the PostgreSQL datasource.

You can invoke the softEvictConnections() through the MBean, either interactively through jconsole or Java Mission Control, or programatically.  The housekeeping thread calls fillPool() every 30 seconds to "top off" the pool if needed, so there is no need to invoke it explicitly.

-Brett

Anupom Syam

unread,
Apr 22, 2015, 4:05:16 PM4/22/15
to Brett Wooldridge, hika...@googlegroups.com
Thanks for your in detail answer Brett. Seems like exactly what I was looking for. I have one more question, what actually happens when we soft evict an active in-use connection, when do we close that connection?

Thanks once again.

--
You received this message because you are subscribed to a topic in the Google Groups "HikariCP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hikari-cp/Qz9A1DP2Bsw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hikari-cp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brett Wooldridge

unread,
Apr 22, 2015, 7:38:54 PM4/22/15
to hika...@googlegroups.com
The way soft eviction works is by immediately evicting idle connections, and "marking" in-use connections for eviction. When a marked connection is returned to the pool by your application it is closed and removed from the pool.

-Brett

Anupom Syam

unread,
Apr 22, 2015, 7:40:01 PM4/22/15
to Brett Wooldridge, hika...@googlegroups.com
Great, thanks Brett. Appreciate your help.

On Wed, Apr 22, 2015 at 4:38 PM, Brett Wooldridge <brett.wo...@gmail.com> wrote:
The way soft eviction works is by immediately evicting idle connections, and "marking" in-use connections for eviction. When a marked connection is returned to the pool by your application it is closed and removed from the pool.

-Brett
Reply all
Reply to author
Forward
0 new messages