Fast fail connections on connect exceptions?

641 views
Skip to first unread message

Eric Hwang

unread,
Jul 3, 2014, 6:01:23 AM7/3/14
to hika...@googlegroups.com
I noticed that HikariCP will wait up until the maximum connect timeout if the initial connection attempt has any errors, regardless of the error. Is there some way to get HikariCP to fast fail on connection errors rather than waiting? This would be useful when for example the host:port is invalid etc.

Thanks,
Eric

Eric Hwang

unread,
Jul 3, 2014, 6:35:49 PM7/3/14
to hika...@googlegroups.com
Actually I ran a few more tests and it looks like HikariCP will wait up to the maximum connect timeout for any connection failures (even non-initializing connection errors). Any thoughts on how to make this fail faster?

-Eric

Brett Wooldridge

unread,
Jul 4, 2014, 3:38:58 AM7/4/14
to hika...@googlegroups.com
Do you mean even when initializationFailFast is enabled?  When initializationFailFast is enabled, an exception should be thrown during pool initialization.

Brett Wooldridge

unread,
Jul 4, 2014, 3:45:05 AM7/4/14
to hika...@googlegroups.com
HikariCP is designed to allow applications to start without error even if the database is not available.  HikariCP will continue trying to obtain connections until the Sun burns out, until you start your database, or until you stop your application.  The initializationFailFast  property controls whether HikariCP should cause an application start failure during initialization.  It is up to you or your framework to respond to the exception that is thrown accordingly.

With respect to individual getConnection() attempts performed by your application, they should honor the connectionTimeout property.  Note that Connections in HikariCP are created by a background thread, and this thread will never give up, regardless of failures, for the life of the application.
Reply all
Reply to author
Forward
0 new messages