[systemd-devel] possible bug guessing mainpid when service type=forking..

Marius Tolzmann tolzmann at molgen.mpg.de
Mon Jun 20 10:34:47 PDT 2011


Hello..

Today we hit a bug where incorrect guessing of the MAINPID in a
Type=forking service always killed the service somehow..

The service in question was ypbind from the ypbind-mt package from
kernel.org/utils/NIS..

It forks two times to detach and provides the mainpid in
/var/run/ypbind.pid .. setting PIDFile=/var/run/ypbind.pid and setting
Type=forking always did the job - until today, when we installed it on a
somehow slower hardware.

There seems to be some kind of race-condition where systemd takes the
pid of the first fork() as the MAINPID which then gets killed after the
second fork() - i don't know for sure and may be totally wrong here.

Since tracing systemd and/or increasing debug level changed the behavior
so much that the bug wasn't triggered anymore i can't provide any more
information about this.

We fixed this issue by patching ypbind-mt to run in foreground an let
systemd do the forking - as intended 8)

But it still seems to be some kind of bug in setting the correct MAINPID
in Type=forking service files.

The bug was triggered when providing PIDFile= and also when PIDFile= was
commented out. It works fine on slightly faster systems and may also
work fine on even slower hardware.

I tried systemd v27 and v29 - same problem.

Fixing the ypbind binary solved everything for us - so i don't know if
anybody cares to fix this.. but it was hard to find what could have
happened because the service just won't start even if started again and
again manually and worked all the time.

BTW a patch for ypbind-mt adding a -foreground commandline switch will
be sent to the maintainers soon..

bye marius..



-- 
Dipl.-Inf. Marius Tolzmann <marius.tolzmann at molgen.mpg.de>
----------------------------------.------------------------------
MPI f. molekulare Genetik         |
Ihnestrasse 63-73, D-14195 Berlin |   ==> MarIuX GNU/Linux <==
Phone: +49 (0)30 8413 1709        |
----------------------------------^------------------------------
God put me on earth to accomplish a certain number of things.
Right now I am so far behind..
   ..I will never die.         <by calvin from calvin&hobbes ;)>


More information about the systemd-devel mailing list