Public bug reported:

Important: Idle process killing under Ubuntu 18.04 (PHP-FPM 7.2,
ondemand process manager) seems to be working fine according to my
tests.

Release:
# lsb_release -d
Description:    Ubuntu 16.04.2 LTS

Package version:
# dpkg -l | grep fpm
ii  php7.0-fpm                          7.0.33-0ubuntu0.16.04.11                
                 amd64        server-side, HTML-embedded scripting language 
(FPM-CGI binary)

FPM settings:
pm = ondemand
pm.process_idle_timeout = 2s
(or if not specified -> default idle timeout is 10s)

What I expected to happen:
--------------------------
When using the "ondemand" process manager for FPM pools, idle children are 
killed after the corresponding setting "pm.process_idle_timeout". The default 
value for this setting is 10s.

What happened:
--------------
Since upgrading from version 7.0.33-0ubuntu0.16.04.9 to package 
7.0.33-0ubuntu0.16.04.11 the "pm.process_idle_timeout" is no longer taken into 
account! Therefor idle processes are longer alive which leads to more memory 
consumption and busy pools.

Further analysis:
-----------------
Since 7.0.33-0ubuntu0.16.04.11 only added 3 patches (CVE-2015-9253.patch, 
CVE-2020-7060.patch, CVE-2020-7059.patch) the problem with killing idle process 
must be introduced with one of these 3 patches. Before (version 
7.0.33-0ubuntu0.16.04.9) idle children were successfully killed after the 
default period of 10s.

Reproducing the bug:
--------------------
For one pool I changed the settings and enabled the debug log:
pm = ondemand
pm.max_children = 10
pm.max_requests = 500
pm.process_idle_timeout = 2s

Then I made a request to the pool and a new child was spawned. As no further 
requests were made I assumed after 2s the idle children gets killed by the 
process manager. This is what happened according to the debug log:
[19-Feb-2020 11:51:17.862968] DEBUG: pid 6253, fpm_children_make(), line 422: 
[pool testidle] child 6259 started
[19-Feb-2020 11:51:17.863099] DEBUG: pid 6253, fpm_pctl_on_socket_accept(), 
line 536: [pool testidle] got accept without idle child available .... I forked
[19-Feb-2020 11:51:18.419900] DEBUG: pid 6253, 
fpm_pctl_perform_idle_server_maintenance(), line 362: [pool testidle] currently 
1 active children, 0 spare children
[19-Feb-2020 11:51:19.420548] DEBUG: pid 6253, 
fpm_pctl_perform_idle_server_maintenance(), line 362: [pool testidle] currently 
0 active children, 1 spare children

Then I waited for ~25s and made another request (the idle child was not killed 
during this time and the child process was visible with pstree):
19-Feb-2020 11:51:46.454211] DEBUG: pid 6253, 
fpm_pctl_perform_idle_server_maintenance(), line 362: [pool testidle] currently 
0 active children, 1 spare children
[19-Feb-2020 11:51:46.746857] DEBUG: pid 6253, fpm_got_signal(), line 76: 
received SIGCHLD
[19-Feb-2020 11:51:46.747000] DEBUG: pid 6253, fpm_children_bury(), line 255: 
[pool testidle] child 6259 has been killed by the process management after 
28.884039 seconds from start
[19-Feb-2020 11:51:46.747044] DEBUG: pid 6253, fpm_event_loop(), line 424: 
event module triggered 1 events
[19-Feb-2020 11:51:46.927619] DEBUG: pid 6253, fpm_children_make(), line 422: 
[pool testidle] child 6260 started
[19-Feb-2020 11:51:46.927740] DEBUG: pid 6253, fpm_pctl_on_socket_accept(), 
line 536: [pool testidle] got accept without idle child available .... I forked

This behavior is not as expected, right before handling the new request
the child gets killed (I assume the check if the child is idle kicks in)
and a new one is forked!

Summary:
--------
Expected behavior: ondemand process manager kills idle process after 
pm.process_idle_timeout
Buggy behavior: idle children stay alive and are killed right before the next 
request if pm.process_idle_timeout has passed

** Affects: php7.0 (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "Memory consumption of FPM pool processes since idle 
processes are not killed"
   
https://bugs.launchpad.net/bugs/1863881/+attachment/5329504/+files/Screenshot_2020-02-19_12-00-43.png

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1863881

Title:
  php7.0-fpm: 7.0.33-0ubuntu0.16.04.11 - FPM ondemand process manager
  does not kill idle children after pm.process_idle_timeout

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php7.0/+bug/1863881/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to