[ 
https://issues.apache.org/jira/browse/ARTEMIS-2213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16728896#comment-16728896
 ] 

ASF GitHub Bot commented on ARTEMIS-2213:
-----------------------------------------

Github user wy96f commented on the issue:

    https://github.com/apache/activemq-artemis/pull/2481
  
    @michaelandrepearce @franz1981 
    Here is the code of System::nanoTime from openjdk:
    jlong os::javaTimeNanos() {
      if (Linux::supports_monotonic_clock()) {
        struct timespec tp;
        int status = Linux::clock_gettime(CLOCK_MONOTONIC, &tp);
        assert(status == 0, "gettime error");
        jlong result = jlong(tp.tv_sec) * (1000 * 1000 * 1000) + 
jlong(tp.tv_nsec);
        return result;
      } else {
        timeval time;
        int status = gettimeofday(&time, NULL);
        assert(status != -1, "linux error");
        jlong usecs = jlong(time.tv_sec) * (1000 * 1000) + jlong(time.tv_usec);
        return 1000 * usecs;
      }
    }
    
    If monotonic clock is not supported, nanoTime is implemented like 
currentTimeMillis.
    If clock_gettime is used, as man page says: CLOCK_MONOTONIC_RAW (since 
Linux 2.6.28; Linux-specific) similar to CLOCK_MONOTONIC, but provides access 
to a raw hardware-based time that is not subject to NTP adjustments. That's to 
say CLOCK_MONOTONIC maybe affected by ntp. See 
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8006942, 
https://github.com/rust-lang/rust/issues/37902 for reference. Not sure 
CLOCK_MONOTONIC won't jump backward, please correct me if anything wrong:)


> Clock drift causing server halt
> -------------------------------
>
>                 Key: ARTEMIS-2213
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2213
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 2.6.3
>            Reporter: yangwei
>            Priority: Critical
>
> In our production cluster some brokers crashed. There is nothing unusual in 
> the dump stack. After digging into code, we found component was incorrectly 
> expired. When clock drifted back, left time was less than enter time. If the 
> component was not entered in default 120000ms, it would be expired and server 
> was halted.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to