You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2023/01/29 05:04:43 UTC

[kudu] branch master updated: [clock] detect unsynchronized clock earlier

This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 116b51d7b [clock] detect unsynchronized clock earlier
116b51d7b is described below

commit 116b51d7bb307a8b6830cfeb6e3b3e5110023236
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Fri Jan 27 17:13:11 2023 -0800

    [clock] detect unsynchronized clock earlier
    
    This patch adds an extra check for the return code of the ntp_adjtime()
    call in SystemNtp::Init().  This is to allow for earlier detection of
    unsynchronized local clock conditions if using the "system" time source.
    Before this patch, if the local clock wasn't synchronized with NTP, that
    fact would be detected later upon first call to WalltimeWithError().
    The latter usually happens when a Kudu server tries to find current time
    to generate a hybrid timestamp for an operation.
    
    This is a follow-up to e72208436a625391739217394c67d783e992367a.
    
    Change-Id: I32fd6ac1adfa04251e1e4b6237d650071e3b4dc9
    Reviewed-on: http://gerrit.cloudera.org:8080/19449
    Reviewed-by: Yifan Zhang <ch...@163.com>
    Reviewed-by: Yingchun Lai <ac...@gmail.com>
    Tested-by: Alexey Serbin <al...@apache.org>
---
 src/kudu/clock/system_ntp.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/kudu/clock/system_ntp.cc b/src/kudu/clock/system_ntp.cc
index 099457335..78d7e9b42 100644
--- a/src/kudu/clock/system_ntp.cc
+++ b/src/kudu/clock/system_ntp.cc
@@ -121,7 +121,9 @@ SystemNtp::SystemNtp()
 Status SystemNtp::Init() {
   timex t;
   t.modes = 0; // set mode to 0 for read-only query
-  RETURN_NOT_OK(CheckForNtpAdjtimeError(ntp_adjtime(&t)));
+  const int rc = ntp_adjtime(&t);
+  RETURN_NOT_OK(CheckForNtpAdjtimeError(rc));
+  RETURN_NOT_OK(NtpStateToStatus(rc));
 
   // The unit of the reported tolerance is ppm with 16-bit fractional part:
   // 65536 is 1 ppm (see http://man7.org/linux/man-pages/man3/ntp_adjtime.3.html