Clarification on validationTimeout

2,639 views
Skip to first unread message

Wayne Huang

unread,
Jan 30, 2015, 3:02:27 PM1/30/15
to hika...@googlegroups.com
Hi,

I'm currently using 2.0.1 and I'm thinking about updating to 2.3.1. Looking through the source, it appears that the internal validation timeout in 2.0.1 was the same value as the connection timeout. I've been using 0 as the connection timeout which means getConnection() should wait forever for a connection. Now that validation timeout is a separate property and cannot be set to 0, what are the implications if I have connection timeout set to 0. If my assumptions are correct, there is now no way in 2.3.1 to obtain the same behavior as 2.0.1? Since we are looking to make HikariCP the default connection pool which could have various consequences for our user base, I'd like to fully understand any potential changes in behavior.

Also, great work on HikariCP!

This message, and any documents attached hereto, may contain confidential or proprietary information intended only for the use of the addressee(s) named above or may contain information that is legally  privileged. If you are not the intended addressee, or the person responsible for delivering it to the intended addressee, you are hereby notified that reading, disseminating, distributing or copying this message is strictly prohibited. If you have received this message by mistake, please immediately notify us by replying to the message and delete the original message and any copies immediately thereafter.  Thank you for your cooperation.

Brett Wooldridge

unread,
Jan 30, 2015, 9:39:16 PM1/30/15
to hika...@googlegroups.com
Hi Wayne,

I'll do my best to explain the internals of HikariCP in this respect.  When you call getConnection(), HikariCP will not return until (1) a Connection becomes available in the pool, or (2) the connectionTimeout is reached.  If connectionTimeout is 0 (infinite), getConnection() will not return until a Connection becomes available in the pool.

Let's say that inside of getConnection() HikariCP finds an available Connection in the bag collection, HikariCP will then try to validate that the Connection is alive before returning it to you.  This is where the validationTimeout applies.  If the Connection cannot be validated as "alive" within validationTimeout milliseconds, HikariCP will consider that Connection "dead" and will close it then eject it from the pool.  The thread in getConnection() will then try to obtain another Connection from the bag collection.  They may repeat many times, until connectionTimeout is reached or a valid Connection is found.  Again, if connectionTimeout is infinite, the thread will keep waiting for Connections from the bag collection (either new ones or ones returned by other threads) and keep testing them until it finds a good one.

Hope this clarifies the internal pool behavior.

-Brett

Wayne Huang

unread,
Jan 30, 2015, 10:07:04 PM1/30/15
to hika...@googlegroups.com
That's exactly what I needed to know. Thanks for the clarification.
Reply all
Reply to author
Forward
0 new messages