updatedb cron job re-nices wrong process (pid 7 by default)!

Bug #152692 reported by Matt LaPlante on 2007-10-14
34
Affects Status Importance Assigned to Milestone
findutils (Ubuntu)
Medium
Kees Cook
Gutsy
Medium
Unassigned

Bug Description

Binary package hint: findutils

I see a couple problems with the /etc/cron.daily/find cron job in the findutils 4.2.31-1ubuntu2 package (Gutsy RC).

1) There's an extra space in the shebang line (cosmetic)...
#! /bin/sh

2) It's passing a priority to ionice with the -p flag, however according to the ionice man page, the -p flag specifies a pid. This causes ionice to fail to run.
cd / && nice -n ${NICE:-10} ionice -c ${IONICE_CLASS:-2} -p ${IONICE_PRIORITY:-7} updatedb

> ioprio_set: No such process

" -p Pass in a process pid to change an already running process. "

TEST CASE:
1) force updatedb (/etc/cron.daily/find) to run via 'sudo /etc/cron.daily/find'
2) while updatedb runs, examine io priority with "ionice -p $(pidof updatedb)"
3) should report "best-effort: prio 7" (broken behavior shows "none: prio 0")

Øyvind Grønnesby (oyving) wrote :

I see this behavior as well. I guess the author intended to use the -n flag to ionice instead of -p.

The same here with my machine changing -p to -n in /etc/cron.daily/find fixes the problem

glance (glance-acc) wrote :

It took me a while to find this one, 3 out of 10 machines failed updatedb, the thing is that on the other 7 machines it accedently worked because of a khelper with pid 7.

Please fix.

Basilio Kublik (sourcercito) wrote :
Changed in findutils:
importance: Undecided → Low
status: New → Triaged
Luke Hoersten (lukehoersten) wrote :

That patch fixed the problem for me. Thanks.

Neal McBurnett (nealmcb) wrote :
Changed in findutils:
status: Triaged → Fix Committed
Neal McBurnett (nealmcb) wrote :

As noted in the duplicate of this bug, this seems to have been introduced by Bug #134692

Daniel Hahler (blueyed) wrote :

Basilio, thanks for the debdiff. Please change the upload target to gutsy-proposed in the changelog.

I'm subscribing ubuntu-sru and opening a nomination for Ubuntu Gutsy.

JFI: This appears to be fixed in Hardy, from the Debian merge - where they get it correctly.

Changed in findutils:
importance: Low → Medium
status: Fix Committed → Fix Released
Basilio Kublik (sourcercito) wrote :

Hi Daniel
here it goes, also change the comment at the changelog since closing this bug with the patch doesn't make sense anymore.

Kees Cook (kees) wrote :

Debdiff looks good to me.

Changed in findutils:
importance: Undecided → Medium
status: New → In Progress
Basilio Kublik (sourcercito) wrote :

the only change here is that i add the Bug ID back to the changelog, because every closed bug should have their reference ;-).

Kees Cook (kees) wrote :

I updated your diff slightly to use a safer version number (2.1 instead of 3).

Martin Pitt (pitti) wrote :

Sponsored and accepted into gutsy-updates. Please test.

Changed in findutils:
status: In Progress → Fix Committed
Kees Cook (kees) wrote :

I've confirmed that the gutsy-proposed version works correctly for me.

Kees Cook (kees) wrote :

testcase, btw, is:

1) wait for updatedb to run from cron
2) examine io priority with "ionice $(pidof updatedb)"
3) should report "best-effort: prio 7" (broken behavior shows "none: prio 0"

description: updated
description: updated
Brian Murray (brian-murray) wrote :

Is this SRU only for server installs? I'm a bit unclear on how slocate relates to findutils but on my desktop I have '/etc/cron.daily/find.notslocate' and '/etc/cron.daily/slocate'.

find.notslocate from findutils 4.2.31-1ubuntu2 or slocate does not have a reference to 'ionice' at all while

find.slocate has 'IONICE_PRIORITY' with '-n'

Additionally, when I installed the proposed package the file '/etc/cron.daily/find.notslocate.dpkg-new' was created and this has 'IONICE_PRIORITY' with '-n' in it. From looking at the slocate package it is also included in all the -desktop tasks. Hence my question.

Kees Cook (kees) on 2007-12-18
description: updated
Matt LaPlante (cybrmatt) wrote :

Brian:
  When the slocate package is installed, it essentially replaces the 'locate' functionality in findutils. It diverts findutils version of /etc/cron.daily/find to /etc/cron.daily/find.notslocate to prevent it from running (cron jobs with a dot in the name do not run). Slocates own /etc/cron.daily/slocate replaces this functionality. Since the script included with slocate is not broken (at least in this regard), anyone who has slocate installed is essentially unaffected by this bug.

Martin Pitt (pitti) wrote :

Brian: that's indeed another issue (bug 159516).

Brian Murray (brian-murray) wrote :

I've successfully verified this fix by removing slocate from a desktop install and observing ""none: prio 0" when running the cron job from package version 4.2.31-1ubuntu2. After updating to the proposed package, 4.2.31-1ubuntu2.1, the job was then observed to run with "best-effort: prio 7".

Martin Pitt (pitti) wrote :

Copied to gutsy-updates.

Changed in findutils:
status: Fix Committed → Fix Released
Magnus Wissler (gmw) wrote :

The priority class argument to ionice is still bugged; it passes a priority class of -2 to ionice if IONICE_PRIORITY is not set, which is an invalid priority class. I assume priority class 2 is what is intended here. This affects both /etc/cron.daily/slocate and /etc/cron.daily/notslocate.

Or should I report this as a new bug?

Magnus Wissler (gmw) wrote :

 The "-" is part of the shell expression. Duh! Ignore my previous idiotic post.

C (christian-solvare) wrote :

Isn't a space in the shebang line (right after #!) really required by POSIX?

Jeremy Nickurak (nickurak) wrote :

This bug was recently re-introduced to hardy. (Seeing this parameter mis-use on findutils 4.2.32-1ubuntu1 )

Martin Pitt (pitti) on 2008-02-11
Changed in findutils:
assignee: nobody → pitti
status: Fix Released → In Progress
Kees Cook (kees) wrote :

I don't see this problem. From debian/locate-cron.daily:

                # Avoid providing "-n" when IONICE_CLASS isn't 1 or 2
                case "$IONICE_CLASS" in
                        1|2) priority="-n ${IONICE_PRIORITY:-7}" ;;
                        *) priority="" ;;
                esac
                ionice -c $IONICE_CLASS $priority -p $$ > /dev/null 2>&1 || true

-n and -p are used correctly here. Am I misunderstanding something?

Changed in findutils:
assignee: pitti → keescook
status: In Progress → Invalid
Jeremy Nickurak (nickurak) wrote :

What file is that in? I don't have anything in hardy's /etc/cron.daily that looks like that:

atrus@kedri:/etc/cron.daily$ grep case.*IONICE *
atrus@kedri:/etc/cron.daily$
atrus@kedri:/etc/cron.daily$ apt-cache policy findutils
findutils:
  Installed: 4.2.32-1ubuntu1
  Candidate: 4.2.32-1ubuntu1
  Version table:
 *** 4.2.32-1ubuntu1 0
        500 http://ubuntu.arcticnetwork.ca hardy/main Packages
        100 /var/lib/dpkg/status

Kees Cook (kees) wrote :

If you have slocate installed, it's cron is likely active instead. grep for ionice in cron.daily?

Jeremy Nickurak (nickurak) wrote :

Hm. I'm not sure what happened then. Purging findutils left /etc/cron.daily/find there. I deleted it, reinstalled findutils, and now it appears that /etc/cron.daily/find isn't even in the package any more.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers