[systemd-devel] service killed by cgroup controller pids?

Han Pingtian hanpt at linux.vnet.ibm.com
Mon Mar 21 03:02:02 UTC 2016


Hi there,

I am running some stress tests on a beta system which using 229 verison
systemd and a 4.4 kernel. I found that if a service forking children
firecly, it will be killed. This problem can be reproduced with 4.5+
kernel. I have composed a simple reproducing script:

% cat /etc/systemd/system/reproducer.service 
[Unit]
Description=Reproducer of systemd services killed by pids
After=multi-user.target

[Service]
ExecStart=/home/hpt/reproducer/reproducer.sh
Type=forking

[Install]
WantedBy=multi-user.target

% cat /home/hpt/reproducer/reproducer.sh
#!/bin/bash

foo()
{
        #exec sh -c "echo $1: \$\$;sleep 60"
        echo $1: $(date)
        sleep 60
}

bar()
{
        c=1
        while true
        do
                for ((i=1;i<=2048;i++))
                do
                        foo $c &
                        ((c++))
                done

                wait
                c=1
        done
}

# main
bar &

disown -a

exit 0

After running about 3 minutes, the service failed like this:

● reproducer.service - Reproducer of systemd services killed by pids
   Loaded: loaded (/etc/systemd/system/reproducer.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2016-03-18 07:06:15 CDT; 2 days ago
  Process: 8253 ExecStart=/home/hpt/reproducer/reproducer.sh (code=exited, status=0/SUCCESS)
 Main PID: 8255 (code=exited, status=254)

Mar 18 07:06:13 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:14 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:14 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:14 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:15 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:15 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:15 pinelp3 reproducer.sh[8253]: /home/hpt/reproducer/reproducer.sh: fork: Resource temporarily unavailable
Mar 18 07:06:15 pinelp3 systemd[1]: reproducer.service: Main process exited, code=exited, status=254/n/a
Mar 18 07:06:15 pinelp3 systemd[1]: reproducer.service: Unit entered failed state.
Mar 18 07:06:15 pinelp3 systemd[1]: reproducer.service: Failed with result 'exit-code'.


The default TasksMax is 512. Is this a problem of kernel? I think child 
processes cannot be forked shouldn't cause parent to die. Is that right?

Thanks in advance!

Han Pingtian



More information about the systemd-devel mailing list