Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 243832 - sys-apps/preload-0.6.3-r4: ionice fails randomly when restarting preload
Summary: sys-apps/preload-0.6.3-r4: ionice fails randomly when restarting preload
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High minor
Assignee: Jeremy Olexa (darkside) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-24 15:51 UTC by Pacho Ramos
Modified: 2008-10-28 08:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
preload.init-d.patch (preload.init-d.patch,304 bytes, patch)
2008-10-24 15:53 UTC, Pacho Ramos
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pacho Ramos gentoo-dev 2008-10-24 15:51:50 UTC
When I restart preload service when using ionice with -c3 parameter it sometimes fails with errors like:

/etc/init.d/preload restart
 * Stopping preload ...                                                                                                                                [ ok ]
 * Starting preload ...
 * ionice'ing preload
execvp: No such file or directory                                                                                                                      [ !! ]

 /etc/init.d/preload restart
 * Stopping preload ...                                                                                                                                [ ok ]
 * Starting preload ...
 * ionice'ing preload
ioprio_set: No such process                                                                                                                            [ !! ]

You can try to reproduce it (you need a bit of patience) executing "/etc/init.d/preload restart" really quickly, repeating it just after prompt returns a lot of times (sometimes only 2 attempts are needed, but other times, you will need to try >10 attempts)

It seems to be easily workaround simply sleeping 1 sec

Reproducible: Always
Comment 1 Pacho Ramos gentoo-dev 2008-10-24 15:53:11 UTC
Created attachment 169724 [details, diff]
preload.init-d.patch

I add a sleep just before running ionice, it seems to work ok (at least for me)

Thanks
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-10-27 01:41:44 UTC
Yea, rather annoying. I found that the pid changes after it is started. It must fork and then kill the parent or something? This is why I could not accomplish a PIDFILE technique. 

Kai, any ideas on the best way to do this?

Comment 3 Kai Krakow 2008-10-27 07:38:37 UTC
Jeremy,

as always with such behaving daemons and the start/stop daemon mechanism, it is required to run the daemon in foreground (so it does not detach and thus not fork) and let std do the backgrounding. Now you can let std create a pidfile.

Have a look at the original init.d from my overlay to see how I did solve it. Additionally I found that on shutdown preload can take a long time to write its state file (especially when ionice'd). So please add a start-stop timeout to the stop function as I did it. Otherwise the shutdown process can kill preload while it is writing its state file. On the next boot preload doesn't start because the state file is corrupted then.

All that caused me some headache, too. So let's not repeat it. ;-)
Comment 4 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-10-27 22:50:20 UTC
(In reply to comment #3)
> Jeremy,
> 
> as always with such behaving daemons and the start/stop daemon mechanism, it is
> required to run the daemon in foreground (so it does not detach and thus not
> fork) and let std do the backgrounding. Now you can let std create a pidfile.
> 
> Have a look at the original init.d from my overlay to see how I did solve it.
> Additionally I found that on shutdown preload can take a long time to write its
> state file (especially when ionice'd). So please add a start-stop timeout to
> the stop function as I did it. Otherwise the shutdown process can kill preload
> while it is writing its state file. On the next boot preload doesn't start
> because the state file is corrupted then.
> 
> All that caused me some headache, too. So let's not repeat it. ;-)
> 

I literally copied you ssd arguments and got this:

%% sudo /etc/init.d/preload start
preload             | * Starting preload ...                              [ ok ]

%% ps aux|grep preload
root     15066  0.2  0.0   9972  1716 ?        SNs  17:42   0:00 /usr/sbin/preload -l /var/log/preload.log -V 4 -n 15 -s /var/lib/preload/preload.state

%% cat /var/run/preload.pid 
15063

It's not the same pid...

Comment 5 Kai Krakow 2008-10-27 23:16:56 UTC
Argh! :-(

Well it used to work some time ago. Will check it...
Comment 6 Kai Krakow 2008-10-28 01:00:52 UTC
Jeremy,

> /usr/sbin/preload -l /var/log/preload.log -V 4 -n 15 \
>    -s /var/lib/preload/preload.state


Where's the -f switch gone?
Comment 7 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2008-10-28 02:04:07 UTC
(In reply to comment #6)

> Where's the -f switch gone?

Dang.

Fixed now, you will see a shiny -r5 when you next sync. Hopefully this is the last fix needed =/

Thanks for reporting and thanks for helping.
Comment 8 Pacho Ramos gentoo-dev 2008-10-28 08:17:13 UTC
Thanks a lot to you and kai for the great support :-)