Bug 69800

Summary: Reload of systemd makes it restart service that was stopping
Product: systemd Reporter: Sylvia Else <sylviabz1>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Test case
Patch to correct bug

Description Sylvia Else 2013-09-25 09:16:33 UTC

    
Comment 1 Sylvia Else 2013-09-25 09:28:09 UTC
Created attachment 86539 [details]
Test case

See README file in tar archive
Comment 2 Sylvia Else 2013-09-25 09:33:25 UTC
If a systemctl stop foo command has been given, but the foo service has not yet stopped, and then the systemctl --system daemon-reload is given, then when the foo service eventually stops, systemd will restart it, when clearly it should not.

I speculate that the particular bit of state consisting of the fact that the service is being stopped gets lost in the process of serialization and deserialization.

Since it appears that a reload also occurs for systemctl disable foo, this makes it a particular gotcha for a service that is seeking to stop and disable itself.
Comment 3 Sylvia Else 2013-09-26 00:39:07 UTC
Further tests using systemctl is-active before and after the systemctl --system daemon-reload show that the service remains in the state "deactivating" until it stops, so the cause of its being restarted is presumably something rather more subtle than just losing the fact that it's being stopped :(
Comment 4 Sylvia Else 2013-09-26 09:56:46 UTC
Then again, I wasn't far off after all.

The Service type's forbid_restart field is not preserved by serialization/deserialization, so the fact that the service should not be restarted after stopping is lost.

I'll submit a proposed patch once I've tested it.
Comment 5 Sylvia Else 2013-09-26 13:43:39 UTC
Created attachment 86639 [details] [review]
Patch to correct bug
Comment 6 Zbigniew Jedrzejewski-Szmek 2013-10-08 03:47:03 UTC
Patch applied in http://cgit.freedesktop.org/systemd/systemd/commit/?id=6aca9a5.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.