Adar Dembo has submitted this change and it was merged. (
http://gerrit.cloudera.org:8080/15171 )
Change subject: [clock] ntp_gettime(): STA_NANO bites again
......................................................................
[clock] ntp_gettime(): STA_NANO bites again
Even with the most recent glibc 2.31, ntptimeval::time::tv_usec can
either be in nanoseconds or microseconds and it's not possible to tell
that apart if using only the information returned by ntp_gettime() call:
sysdeps/unix/sysv/linux/ntp_gettime.c:
------------------------------
int
ntp_gettime (struct ntptimeval *ntv)
{
struct timex tntx;
int result;
tntx.modes = 0;
result = __adjtimex (&tntx);
ntv->time = tntx.time;
ntv->maxerror = tntx.maxerror;
ntv->esterror = tntx.esterror;
return result;
}
------------------------------
In the code above, __adjtimex() populates the the timex structure taking
into account the STA_NANO flag, which is subject to current setting by
ADJ_MICRO. However, ntp_gettime() does not convert the value of the
ntptimeval::time::tv_usec field using the presence of STA_NANO flag in
tntx.status.
So, on Linux it's necessary to use ntp_adjtime() to get NTP time and
maxerror because ntp_gettime() is essentially unusable. See [1] as
well.
In contrast, the ntp_gettime() call on BSD-based systems (e.g. macOS)
does not bring such surprises.
This is a follow-up to e72208436a625391739217394c67d783e992367a.
[1]
https://stackoverflow.com/questions/16063408/does-ntp-gettime-actually-return-nanosecond-precision
Change-Id: Id171b6fea2274d32a35c6173bab9996b36c0c4f6
Reviewed-on: http://gerrit.cloudera.org:8080/15171
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Adar Dembo <[email protected]>
---
M src/kudu/clock/system_ntp.cc
1 file changed, 35 insertions(+), 19 deletions(-)
Approvals:
Alexey Serbin: Verified
Adar Dembo: Looks good to me, approved
--
To view, visit http://gerrit.cloudera.org:8080/15171
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id171b6fea2274d32a35c6173bab9996b36c0c4f6
Gerrit-Change-Number: 15171
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Adar Dembo <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Volodymyr Verovkin <[email protected]>