Follow up on thread: http://lists.freedesktop.org/archives/systemd-devel/2014-October/024482.html I have stumbled on a race condition on systemd-run --scope command. Due to race condition, unit might show up as active/running even though there is no process in the cgroup. The impact is big for us. We are starting some legacy scripts as scopes and a script might have something like this in the beginning. systemd-run --unit hello --scope /myscript #!/bins/h . /etc/configuration if [ $ENABLED == 'no' ] return Later on, when the script is enabled with ENABLED=yes, running systemd-run --unit hello --scope /myscript is returning immediately since systemd is considering hello.scope already active.
How to reproduce: [root@axis-00408cc563e5 /mnt/flash/root]27929# cat stress #!/bin/sh systemd-run --scope /bin/true & systemd-run --scope /bin/true & systemd-run --scope /bin/true & systemd-run --scope /bin/true & systemd-run --scope /bin/true & systemd-run --scope /bin/true & systemd-run --scope /bin/true & systemd-run --scope /bin/true & [root@axis-00408cc563e5 /mnt/flash/root]27929# ./stress [root@axis-00408cc563e5 /mnt/flash/root]27929# Running as unit run-27947.scope. Running as unit run-27946.scope. Running as unit run-27945.scope. Running as unit run-27948.scope. Running as unit run-27952.scope. Running as unit run-27950.scope. Running as unit run-27951.scope. Running as unit run-27949.scope. [root@axis-00408cc563e5 /mnt/flash/root]27929# systemctl -t scope UNIT LOAD ACTIVE SUB DESCRIPTION run-27945.scope loaded active running /bin/true run-27946.scope loaded active running /bin/true run-27947.scope loaded active running /bin/true run-27948.scope loaded active running /bin/true run-27949.scope loaded active running /bin/true run-27950.scope loaded active running /bin/true run-27951.scope loaded active running /bin/true run-27952.scope loaded active running /bin/true LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 8 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'. [root@axis-00408cc563e5 /mnt/flash/root]27929# systemctl status run-27945.scope ● run-27945.scope - /bin/true Loaded: loaded (/run/systemd/system/run-27945.scope; static) Drop-In: /run/systemd/system/run-27945.scope.d └─50-Description.conf Active: active (running) since Fri 2014-10-24 13:13:26 GMT; 15s ago
Fixed in git. http://cgit.freedesktop.org/systemd/systemd/commit/?id=de158ed22db60e3a6654557fa4aa72f7248550af
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.