ntp init script started multiple times - causing 180 seconds wait on boot

Bug #246203 reported by Kjell Braden
14
Affects Status Importance Assigned to Milestone
ntp (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: ntp

ntp in intrepid causes to boot to wait 180 seconds because it's started three times: once from /etc/network/if-up.d/ntpdate, which locks the lockfile, and twice from upstart (no idea why, however, I see two processes: one is "invoke-rc.d ntp start" and one is something like "/etc/rc2.d/S23ntp start").

The latter both cause the boot process to stop because of lockfile-create retrying 9 times to get the lockfile.

$ LC_ALL=C apt-cache policy ntp
ntp:
  Installed: 1:4.2.4p4+dfsg-6ubuntu1
  Candidate: 1:4.2.4p4+dfsg-6ubuntu1
  Version table:
 *** 1:4.2.4p4+dfsg-6ubuntu1 0
        500 http://archive.ubuntu.com intrepid/main Packages
        100 /var/lib/dpkg/status

Related branches

Matti Lindell (mlind)
Changed in ntp:
status: New → Confirmed
Revision history for this message
Daniel J Blueman (danielblueman) wrote :

It's a race-condition, and is called from the ntpdate and ntp script in the DHCP exit-hook script dir:

# ls -l /etc/dhcp3/dhclient-exit-hooks.d/ntp*
-rw-r--r-- 1 root root 1242 2008-03-07 20:37 /etc/dhcp3/dhclient-exit-hooks.d/ntp
-rw-r--r-- 1 root root 802 2008-06-19 04:04 /etc/dhcp3/dhclient-exit-hooks.d/ntpdate

I see these processes:

root 6693 1 0 19:06 ? 00:00:00 /sbin/dhclient -d -sf /usr/lib/NetworkManager/nm-dhcp-client.action -pf /var/run/dhclient-eth0.pid -lf /var/run/dhclient-eth0.lease -cf /var/run/nm-dhclient-eth0.conf eth0
root 6752 1 0 19:06 ? 00:00:00 /bin/sh /etc/network/if-up.d/ntpdate
root 6756 6752 0 19:06 ? 00:00:00 lockfile-touch /var/lock/ntpdate
root 6788 6752 0 19:06 ? 00:00:00 /bin/sh /usr/sbin/invoke-rc.d --quiet ntp start
root 6804 6788 0 19:06 ? 00:00:00 /bin/sh /etc/init.d/ntp start
root 6811 6804 0 19:06 ? 00:00:00 lockfile-create /var/lock/ntpdate

It's a regression in 8.10, but as it's not installed per default, people aren't bumping into it.

The lockfile-create/remove/touchlock binaries are provided by lockfile-progs, which are a simple C wrapper around lockfile_touch(3). See 'man lockfile_touch'.

Revision history for this message
Kees Cook (kees) wrote :

It's actually not as much a race as a straight-up dead-lock. ntpdate tries to use the same lockfile as ntpd, and ntpdate calls ntpd stop/start, which blocks, waiting for the lock that ntpdate just created.

Changed in ntp:
importance: Undecided → Medium
milestone: none → intrepid-alpha-5
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ntp - 1:4.2.4p4+dfsg-6ubuntu2

---------------
ntp (1:4.2.4p4+dfsg-6ubuntu2) intrepid; urgency=low

  * debian/ntpdate.ifup: use a different lockfile to avoid dead-locks
    when restarting ntpd (LP: #246203).

 -- Kees Cook <email address hidden> Wed, 20 Aug 2008 09:48:33 -0700

Changed in ntp:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.