4

HickariCP docs say:

HikariCP relies heavily on accurate high-resolution timers for both performance and reliability. It is imperative that your server is synchronized with a time-source such as an NTP server. Especially if your server is running within a virtual machine. Do not rely on hypervisor settings to "synchronize" the clock of the virtual machine. Configure time-source synchronization inside the virtual machine. If you come asking for support on an issue that turns out to be caused by lack time synchronization, you will be taunted publicly on Twitter.

Which other connection pooling libraries would you choose, which are less sensitive to virtual machine time drifts?

13

Any pool in an environment in which time can flow backwards or leap forwards, which it can in a virtual machine, is going to be subject to spurious failure when it does so.

Moreover, it is not just connection pools that are affected.

Any...

  • Timed waits
  • Timed polls from a concurrent collection
  • Object.wait() with a timeout
  • Thread.sleep() call
  • ...
  • Anything in Java that requires the measurment of time is affected.

If you cannot nail down your clock drift, you will encounter unexplained application failures, occurring in your code and third-party libraries.

HikariCP (i.e.me) got sick of spending hours trouble-shooting a user's issue, reading logs and thread dumps, only to discover their clock had jumped backwards or forwards more than a minute.

User: "Why did I get a bunch of connection timeouts?!"

(several days of back-and-forth questions and examining logs later...)

HikariCP: "Well, you asked the pool to try for 30 seconds to give you a connection ... then your clock jumped forward 42 seconds and Java (and the OS) unparked all the threads as if time had really passed."

It is really simple to fix, just configure NTP inside your VM.

  • Thanks. This requires the virtual infrastructure admin to provide you with an NTP service though. – matt Apr 15 '17 at 5:30
  • 1
    If your outbound access is blocked,yes. Otherwise, there are hundreds of public NTP servers. But nearly all infrastructure providers have NTP service. See docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html – brettw Apr 16 '17 at 5:51
  • Yep, but lots of code runs on-premise in segregated environments. I'm sure they have NTP services running in most those places of course. – matt Apr 16 '17 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.