sudo timedatectl timesync-status has high jitter and offset

I’ve noticed that since the last update of the Ubuntu kernel the OS clock randomly jumps seconds. I noticed that after running a simple Python app which showed that the timestamps on the print statements are not in chronological order. Below is an example of print of the console and the timestamp of my Django app:

[2023-08-28 17:11:00,078: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:01,190: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:02,378: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:03,462: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:04,630: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:05,758: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:07,122: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:08,350: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:09,606: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:10,966: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:55,717: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:56,938: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:58,294: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:10:59,514: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:00,842: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:02,494: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:04,098: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:05,798: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:09,506: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:10,542: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:11,666: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:12,803: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:14,043: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:15,147: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:16,251: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:17,351: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:18,383: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:19,427: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:20,495: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:21,579: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:22,691: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:23,847: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:24,987: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:26,151: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:11,857: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:12,969: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:14,117: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:15,197: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:16,281: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:17,489: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:18,650: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:19,774: WARNING/ForkPoolWorker-1] Contato un secondo
[2023-08-28 17:11:20,850: WARNING/ForkPoolWorker-1] Contato un secondo

Opening the Clock application also shows that seconds run, sometimes faster, sometimes slower, and sometimes they jump from a certain number to another.

My Ubuntu server uses timedatectl to sync time. Here are the server’s details:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy
Linux lab01 6.5.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 12 10:22:43 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

I can’t understand why, but clock jumps a lot. It’s like it counts super fast, it figures out the time is wrong, and kind of jumps back. For example, these are two date commands with 1 s between them:

lab@lab01:~$ date
Mon Mar 25 02:25:24 PM CET 2024
lab@lab01:~$ date
Mon Mar 25 02:25:03 PM CET 2024

sudo timedatectl timesync-status shows a high jitter and offset values (tens of seconds) but I can’t understand why:

    Server: 162.159.200.1 (0.pool.ntp.org)
Poll interval: 32s (min: 32s; max 34min 8s)
         Leap: normal
      Version: 4
      Stratum: 3
    Reference: A0E080C
    Precision: 1us (-25)
Root distance: 9.864ms (max: 5s)
       Offset: -22.284696s
        Delay: 3.924ms
       Jitter: 10.223410s
 Packet count: 53
    Frequency: +0.000ppm

I’ve also noticed that there are some issues with the clocksource:

$ sudo dmesg | grep clocksource
[    0.026856] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
[    0.100958] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles: 0x2c9485be866, max_idle_ns: 440795258057 ns
[    0.106744] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.146577] clocksource: Switched to clocksource tsc-early
[    1.765438] clocksource: timekeeping watchdog on CPU1: Marking clocksource 'tsc-early' as unstable because the skew is too large:
[    1.765440] clocksource:                       'refined-jiffies' wd_nsec: 512032000 wd_now: fffedc08 wd_last: fffedb88 mask: ffffffff
[    1.765442] clocksource:                       'tsc-early' cs_nsec: 852454992 cs_now: 9bda08539 cs_last: 9207bcdc0 mask: ffffffffffffffff
[    1.765443] clocksource:                       Clocksource 'tsc-early' skewed 340422992 ns (340 ms) over watchdog 'refined-jiffies' interval of 512032000 ns (512 ms)
[    1.765445] clocksource:                       'tsc-early' is current clocksource.
[    1.765448] tsc: Marking TSC unstable due to clocksource watchdog
[    1.985248] clocksource: Switched to clocksource refined-jiffies

I have tried to make chrony work with no luck. Currently my chrony.conf is:

pool 0.pool.ntp.org burst
sourcedir /run/chrony-dhcp
sourcedir /etc/chrony/sources.d
keyfile /etc/chrony/chrony.keys
driftfile /var/lib/chrony/chrony.drift
ntsdumpdir /var/lib/chrony
logdir /var/log/chrony
maxupdateskew 100.0
rtcsync
makestep 1 -1
maxdistance 12000

I’ve added the maxdistance trying to fix the issue.

The command sudo chronyc sources -v shows the following:

MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? ns2.fibertelecom.it           2   6     3    59  -278.5s[-278.5s] +/-   53ms
^? ns3.fibertelecom.it           3   6     3    59  -277.7s[-277.7s] +/-   38ms
^? ns1.fibertelecom.it           2   6     3    60  -276.1s[-276.1s] +/-   35ms
^? nettuno.ntp.irh.it            2   6     3    60  -276.9s[-276.9s] +/-   11ms

and chronyc tracking:

Reference ID    : 00000000 ()
Stratum         : 0
Ref time (UTC)  : Thu Jan 01 00:00:00 1970
System time     : 0.000000001 seconds fast of NTP time
Last offset     : +0.000000000 seconds
RMS offset      : 0.000000000 seconds
Frequency       : 86.704 ppm fast
Residual freq   : +0.000 ppm
Skew            : 0.000 ppm
Root delay      : 1.000000000 seconds
Root dispersion : 1.000000000 seconds
Update interval : 0.0 seconds
Leap status     : Not synchronised

Any suggestions?

Asked By: NicoCaldo

||

A small fix on the grub make it works again

In the /etc/default/grub file you must add tsc=nowatchdog to GRUB_CMDLINE_LINUX_DEFAULT

Save and reboot and it should work

Answered By: NicoCaldo
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.