JVM time drifting from OS time

Solution Unverified - Updated -

Environment

  • HP-UX + HP JDK
  • Linux + OpenJDK

Issue

  • After starting the HP-UX server, the HP-UX JVM time appears to drift from the OS time, sometimes drifting as far as one hour apart. The only way to resolve the problem is to restart the JVM.
  • Migrating from HP-UX to OpenJDK, where are the -XX:+UseGetTimeOfDay and -XX:+UseHighResolutionTimer options to avoid time drift?

Resolution

Use -XX:+UseGetTimeOfDay and -XX:+UseHighResolutionTimer to avoid time drift on the HP-UX JDK.

These options do not exist on OpenJDK. They are not needed because Linux and OpenJDK are not affected by this time drift issue (it uses gettimeofday by default).

Root Cause

The HP-UX JDK uses CPU ticks by default to calculate the current time, and sometimes the timer interrupt does not occur as frequently as it should.

Diagnostic Steps

  1. Obtain environment details JDK/OS combo
  2. Confirm if it's a virtualized environment
  3. Establish how the client is computing the time that is out of sync.
  4. Does the time drift increase significantly during periods when the server is busy?

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments