Bug 231203 - use ionice in /etc/cron.daily/mlocate
Bug#: 231203 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: enhancement Priority: P2
Resolution: FIXED Assigned To: base-system@gentoo.org Reported By: billie@gentoo.org
Component: Applications
URL: 
Summary: use ionice in /etc/cron.daily/mlocate
Keywords:  
Status Whiteboard: 
Opened: 2008-07-08 17:44 0000
Description:   Opened: 2008-07-08 17:44 0000
Sometimes when updatedb is running it is rather annoying because it sucks much
disk I/O. So I thought it would be a good idea to use ionice in combination
with nice for the cron script. I searched the net and found that the Ubuntu
people already do this[1,2].

What do you think about this?

[1] https://bugs.launchpad.net/ubuntu/+source/findutils/+bug/134692
[2] http://launchpadlibrarian.net/9631597/slocate_3.1-1ubuntu2.dsc.diff

------- Comment #1 From SpanKY 2008-08-19 00:55:46 0000 -------
rlocate doesnt really make sense ... it doesnt run a periodic cronjob

the Ubuntu patch has syntax errors (wonder if they realize it ...).  so ive
implemented it myself for our slocate-3.1-r2.

http://sources.gentoo.org/sys-apps/slocate/files/slocate-3.1-cron2.patch?rev=1.1

just need to update mlocate ...

------- Comment #2 From Daniel Pielmeier 2008-08-19 06:59:44 0000 -------
(In reply to comment #1)
> rlocate doesnt really make sense ... it doesnt run a periodic cronjob

Oh, I did not know about this. I know mlocate and slocate use the cronjob so I
was under the impression rlocate does this too.

> the Ubuntu patch has syntax errors (wonder if they realize it ...).  so ive
> implemented it myself for our slocate-3.1-r2.
> http://sources.gentoo.org/sys-apps/slocate/files/slocate-3.1-cron2.patch?rev=1.1

Thanks for implementing this! Where are the syntax errors? I just saw your
approach looks a bit cleaner as it saves one if statement for instance.

> just need to update mlocate ...

What is the differnce in checking for /usr/bin/updatedb instead of
/usr/bin/slocate. I guess that way it can be applied in a similar way for
mlocate.

------- Comment #3 From Daniel Pielmeier 2008-09-06 12:46:18 0000 -------
Created an attachment (id=164714) [details]
mlocate.cron.diff

Patches for mlocate. They are done in the same way like slocate.

------- Comment #4 From Daniel Pielmeier 2008-09-06 12:46:42 0000 -------
Created an attachment (id=164715) [details]
updatedb.conf.diff

------- Comment #5 From Daniel Pielmeier 2008-09-06 18:34:36 0000 -------
(In reply to comment #4)
> Created an attachment (id=164715) [edit] [details]
> updatedb.conf.diff
> 

Okay it does not work the same way as slocate because updatedb from mlocate
exits when it gets unknown options.

So possibilities are using an extra configuration file to set nice and ionice
values for the cron job, hard coding the values in the cron file or patch
mlocate so it does not exit when it gets unknown options.

I don't know if patching is difficult maybe it is just enough to remove

        case UCT_IDENTIFIER:
          error_at_line (0, 0, UPDATEDB_CONF, uc_line,
                         _("unknown variable `%s'"), uc_lex_buf);
          goto skip_to_eol;

from src/conf.c. Have not tested this yet.

I for now use the extra configuration file option.

Or are there probably other possibilities?

------- Comment #6 From Christian Faulhammer 2008-09-06 19:38:57 0000 -------
(In reply to comment #5)
> So possibilities are using an extra configuration file to set nice and ionice
> values for the cron job, hard coding the values in the cron file or patch
> mlocate so it does not exit when it gets unknown options.

 I am all for extra configuration file.  If you prepare everything and test it
I happily commit it (bit short on time).

------- Comment #7 From Daniel Pielmeier 2008-09-06 19:49:38 0000 -------
Created an attachment (id=164751) [details]
mlocate-0.21.ebuild.diff

patched ebuild to install extra configuration file

------- Comment #8 From Daniel Pielmeier 2008-09-06 19:50:12 0000 -------
Created an attachment (id=164753) [details]
mlocate.cron.diff

changed cron file

------- Comment #9 From Daniel Pielmeier 2008-09-06 19:51:06 0000 -------
Created an attachment (id=164754) [details]
mlocate-cron.conf

additional file to control nice and ionice in the mlocate cron job

------- Comment #10 From Daniel Pielmeier 2008-09-06 19:53:27 0000 -------
By the way, is it possible that the updatedb.conf for mlocate is from slocate.
They look the same but are not completely the same. If possible they could be
adjusted.

------- Comment #11 From Christian Faulhammer 2008-09-07 02:11:47 0000 -------
Synced updatedb.conf, applied your patches (one typo though).  Closing and
thanks.

------- Comment #12 From Daniel Pielmeier 2008-09-07 06:31:24 0000 -------
(In reply to comment #11)
> Synced updatedb.conf, applied your patches (one typo though).  Closing and
> thanks.
> 

Which typo? Do you mean?

--- mlocate/mlocate.cron        2008-09-07 08:15:45.000000000 +0200
+++ mlocate-new/mlocate.cron    2008-09-07 08:16:42.000000000 +0200
@@ -4,14 +4,14 @@
 then
        if [ -f /etc/updatedb.conf ]
        then
-               args=""
+           args=""
        else
-               args="-f proc"
+           args="-f proc"
        fi

        if [ -f /etc/mlocate-cron.conf ]
        then
-               . /etc/mlocate-cron.conf
+               source /etc/mlocate-cron.conf
        fi

        # run on active process in case ionice isnt installed, or

So besides the different indention the only difference I see is the usage of
(source config) vs (. config). I always thought it makes no difference which
one is used. I took the dot as it was the same for slocate.

------- Comment #13 From Christian Faulhammer 2008-09-07 08:31:16 0000 -------
> (In reply to comment #11)
> > Synced updatedb.conf, applied your patches (one typo though).  Closing and
> > thanks.
> > 
> 
> Which typo? Do you mean?

 No, this one:
+       doins "${FILESDIR}/mlocate-cron.conf"
+       fperms 0644 /etc/mlocate.conf

Perms are not set on the right file.

(In reply to comment #12)
> So besides the different indention the only difference I see is the usage of
> (source config) vs (. config). I always thought it makes no difference which
> one is used. I took the dot as it was the same for slocate.

 There is no difference but I think the dot is really non-obvious and people
could miss to see it.

------- Comment #14 From Daniel Pielmeier 2008-09-07 10:47:31 0000 -------
(In reply to comment #13)
> 
>  No, this one:
> +       doins "${FILESDIR}/mlocate-cron.conf"
> +       fperms 0644 /etc/mlocate.conf
> 
> Perms are not set on the right file.

Aargh, copy-paste, thanks for spotting.

> 
>  There is no difference but I think the dot is really non-obvious and people
> could miss to see it.
> 

Okay thanks for the clarification and for putting this into the tree.