boot-time race between /etc/network/if-up.d/ntpdate and "/etc/init.d/ntp start"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ntp (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Precise |
Fix Released
|
Medium
|
Cam Cope | ||
Trusty |
Fix Released
|
Medium
|
Cam Cope |
Bug Description
[Impact]
* Hardware clocks are not stepped at boot, which can prevent NTP from ever
syncing the clock.
Incorrect clocks can cause serious issues in distributed systems.
* Upstream originally added a lock file to eliminate a race between the ntp
service (which keeps the clock synchronized during normal operation) and
ntpdate (which is used to step the clock by large intervals at boot time).
That change had a flaw which introduced a deadlock. An Ubuntu patch was
applied which broke the locking mechanism entirely, reintroducing the race
condition.
* This change undoes the Ubuntu patch and fixes the deadlock by unlocking
before attempting to start the ntp service.
[Test Case]
* There are two bugs: The race, and the deadlock. To reproduce the race more
consistently:
- add 'sleep 30' to '/etc/network/
'/usr/
'invoke-rc.d --quiet $service stop >/dev/null 2>&1 || true'. This will
reproduce the case where the ntp service starts between the stop command
and the ntpdate command.
The result will be that the ntpdate command fails. There will be a
message in syslog like:
'
- Reintroducing the lock brings back the deadlock issue. Both the ntpdate
if-up.d script and the ntp init script check the lock file, but the
ntpdate script attempted to start the ntp init script before unlocking
the lock. Moving the unlock before the init script invocation fixes
the deadlock. The original deadlock behavior is described here:
https:/
[Regression Potential]
* Low. Out-of-sync clocks could be changed a large amount at boot time, but
only for machines with static IP's. The clock is only likely to be in this
state if the clock was very skewed at boot time, which is also unlikely
since NTP usually keeps the software clock in sync during operation and
the hardware clock is updated at shutdown.
Changed in ntp (Ubuntu): | |
importance: | Undecided → Low |
status: | New → Confirmed |
tags: | added: patch |
Changed in ntp (Ubuntu): | |
importance: | Low → Medium |
description: | updated |
Changed in ntp (Ubuntu Precise): | |
importance: | Undecided → Medium |
Changed in ntp (Ubuntu Trusty): | |
importance: | Undecided → Medium |
Changed in ntp (Ubuntu Precise): | |
status: | New → Triaged |
Changed in ntp (Ubuntu Trusty): | |
status: | New → Triaged |
In addition, /etc/dhcp/ dhclient- exit-hooks. d/ntp is *also* getting in on the act, doing an ntp restart when it sees ntp service information from the DHCP server.