Bug 883421

Summary: forking type service with BusName assigned stucks in "deactivating" state
Product: [Fedora] Fedora Reporter: Jan Vcelak <jvcelak>
Component: systemdAssignee: Michal Schmidt <mschmidt>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: alonbl, johannbg, jskarvad, lnykryn, metherid, mschmidt, msekleta, notting, plautrba, systemd-maint, tsmetana, vpavlin
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-05 22:54:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Vcelak 2012-12-04 14:58:16 UTC
Description of problem:

This is a content of a service file provided by tuned package:

[Unit]
Description=Dynamic System Tuning Daemon
After=syslog.target

[Service]
Type=forking
PIDFile=/run/tuned/tuned.pid
BusName=com.redhat.tuned
ExecStart=/usr/sbin/tuned -d

[Install]
WantedBy=multi-user.target


Tuned is a forking service, but it also provides a DBus interface. (We do not use DBus activation yet.) Documentation recommends to set BusName= even if we are forking service.

Version-Release number of selected component (if applicable):
systemd-195-8.fc18.x86_64
tuned-2.1.0-1.fc18.noarch
dbus-1.6.8-2.fc18.x86_64

How reproducible:
with some luck


Steps to Reproduce:
1. systemctl start tuned
2. systemctl stop tuned
3. systemctl start tuned
4. systemctl stop tuned
5. ...
  
Actual results:
After a few "rounds" 'systemctl stop tuned' will hang.

$ systemctl status tuned                             # in other terminal
tuned.service - Dynamic System Tuning Daemon
          Loaded: loaded (/usr/lib/systemd/system/tuned.service; disabled)
          Active: deactivating (stop-sigkill) (Result: timeout) since Tue, 2012-12-04 14:54:48 CET; 1min 34s ago
         Process: 3980 ExecStart=/usr/sbin/tuned -d (code=exited, status=0/SUCCESS)
        Main PID: 3982
          CGroup: name=systemd:/system/tuned.service

Now I have to wait till the internal timeout expires and tuned is considered as stopped.


Expected results:

Systemd considers tuned to be stopped after the tuned daemon terminates.


Additional info:

If I comment out BusName= in service file, everything seems to work fine.

Comment 1 Michal Schmidt 2012-12-06 23:29:54 UTC
I can reproduce this. Some observations so far:
- systemd produces a warning "%s has a D-Bus service name specified, but is not of type dbus. Ignoring.", which is clearly incorrect, because the name is not ignored. The name is used as an indirect source to detect the main PID of the service.
- The utility of this kind of detection is dubious. Its interaction with the detection from PIDFile is undocumented and racy.
- It's also buggy: After a successful detection of the main PID it fails to add this PID to the set of PIDs watched by the manager. Consequently, when the SIGCHLD finally arrives for the PID, the service unit is not notified.
- There is a fallback in manager_dispatch_sigchld() to map the PID to the unit using the cgroup. This does not seem to work. The task is a zombie by then and zombies lose their cgroup membership, I think.

Comment 3 Fedora End Of Life 2013-12-21 15:13:55 UTC
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '18'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior to Fedora 18's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Fedora End Of Life 2014-02-05 22:54:13 UTC
Fedora 18 changed to end-of-life (EOL) status on 2014-01-14. Fedora 18 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.