Skip to content

timedated SetNtp: wrong PropertiesChanged value #9672

Closed

Description

@martinpitt

systemd version the issue has been seen with

239

Used distribution

Debian unstable

When testing Cockpit on Debian testing we noticed a timedated/timesyncd regression, apparently introduced in systemd 239. Debian testing is the only distribution that has 239 - Fedora 28, RHEL etc. all still have 238 where this problem does not occur.

Steps to reproduce the problem

Try to disable and re-enable NTP:

busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb false false
busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP
sleep 1
busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb true false
busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP

One would expect the output "false" and then "true". Sometimes the second property get is false initially, and then true, i. e. it can take some time to settle; that's fine. However, sometimes (in about one out of three runs for me) it doesn't become true even after several minutes.

When that happens, the D-Bus property is false, but timesyncd is running:

● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-07-20 11:35:17 EDT; 39s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 8299 (systemd-timesyn)
   Status: "Synchronized to time server 193.141.27.1:123 (0.debian.pool.ntp.org)."
    Tasks: 2 (limit: 1152)
   Memory: 948.0K
   CGroup: /system.slice/systemd-timesyncd.service
           └─8299 /lib/systemd/systemd-timesyncd

Jul 20 11:35:16 unassigned-hostname systemd[1]: Starting Network Time Synchronization...
Jul 20 11:35:17 unassigned-hostname systemd[1]: Started Network Time Synchronization.
Jul 20 11:35:17 unassigned-hostname systemd-timesyncd[8299]: Synchronized to time server 193.141.27.1:123 (0.debian.pool.ntp.org).

Interestingly, when I call timedatectl in this steady broken state, it initially agrees ("NTP service: inactive"), but a second or so later both the D-Bus property and the output of timedatectl NTP service: become true. So calling timedatectl somehow "tickles" timedated to update the property.

Activity

  1. yuwata commented on Jul 21, 2018

    @yuwata
    Member

    @martinpitt Could you test #9684?

  2. martinpitt commented on Jul 22, 2018

    @martinpitt
    ContributorAuthor

    I looked at this more closely, and the underlying reason for our test failure is that timedated now sends out wrong PropertiesChanged signals when changing NTP. This can be demonstrated with watching for these:

     dbus-monitor --system "type='signal', member='PropertiesChanged', path='/org/freedesktop/timedate1'"
    

    (Note that busctl --match does not seem to actually work, so using good old dbus-monitor here). When disabling NTP, the property change is correct:

    # busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb false true
    signal time=1532254753.834069 sender=:1.44 -> destination=(null destination) serial=494 path=/org/freedesktop/timedate1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
       string "org.freedesktop.timedate1"
       array [
          dict entry(
             string "NTP"
             variant             boolean false
          )
       ]
    

    But when enabling it, it's wrong:

    # busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb true true
    
    signal time=1532254804.535813 sender=:1.44 -> destination=(null destination) serial=512 path=/org/freedesktop/timedate1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
       string "org.freedesktop.timedate1"
       array [
          dict entry(
             string "NTP"
             variant             boolean false
          )
       ]
    

    At this point, GetProperty and the above PropertiesChanged disagree:

    # busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP
    b true
    

    This is true even with the fix from #9684.

  3. changed the title [-]timedated SetNtp race condition[/-] [+]timedated SetNtp: wrong PropertiesChanged value[/+] on Jul 22, 2018
  4. martinpitt commented on Jul 22, 2018

    @martinpitt
    ContributorAuthor

    I've now also seen the wrong PropertiesChanged value in the other direction: Disabling NTP sends a property change with value true. I'll run a bisect now.

  5. martinpitt commented on Jul 22, 2018

    @martinpitt
    ContributorAuthor

    git bisect confirms that this is also related to commit 5d28074. Until then, the property changes were correct, that is the first bad commit.

  6. martinpitt commented on Jul 26, 2018

    @martinpitt
    ContributorAuthor

    Works perfectly again now, thanks!

  7. added a commit that references this issue on Oct 31, 2018
    193fa92
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions