Bug #73056 [Com]: shell_exec cause PHP FPM child processes exit and start very quickly forever

From: Date: Fri, 14 Oct 2016 13:16:00 +0000
Subject: Bug #73056 [Com]: shell_exec cause PHP FPM child processes exit and start very quickly forever
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204770@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73056&edit=1

 ID:                 73056
 Comment by:         robing at transip dot nl
 Reported by:        samer dot mhana at gmail dot com
 Summary:            shell_exec cause PHP FPM child processes exit and
                     start very quickly forever
 Status:             Open
 Type:               Bug
 Package:            FPM related
 Operating System:   Ubuntu 16.04.1 LTS
 PHP Version:        7.0.10
 Block user comment: N
 Private report:     N

 New Comment:

So after some more experimenting we managed to 'solve' this by using proc_open instead in
combination with pipes instead of one of the exec family functions.


Previous Comments:
------------------------------------------------------------------------
[2016-10-14 11:40:44] robing at transip dot nl

This seems to be caused by the fact that the program you execute sets STDIN to non-blocking. We
encountered it with passthru and ssh, and eventually managed to reproduce it by executing the
following php script in passthru:

<?php
stream_set_blocking(STDIN, false);
echo "Blah";
?>

------------------------------------------------------------------------
[2016-09-09 14:58:13] samer dot mhana at gmail dot com

I found what trigger this behavior. PHP function "shell_exec" and "exec" cause
this "craziness" to start and continue. But not with all shell commands. In my case, Only
when I execute the following line:

shell_exec('cleancss /home/statics/my.css');

OR this line:

exec('cleancss /home/statics/my.css');

However, all the shell commands that I tried (such as ls, cat uglifyjs ....) does not cause the
problem.

Now I think that this problem strongly related to this: https://bugs.php.net/bug.php?id=70185.

------------------------------------------------------------------------
[2016-09-09 11:26:02] samer dot mhana at gmail dot com

Description:
------------
Dear sirs

I have installed php 7.0.10 on my Ubuntu server. PHP run in FPM mode with nginx. PHP does not have
user load (only me) since I am working privately on new project

PHP configuration is minimal. some standard extensions along with pecl xdebug, redis and maxmind.

The weird problem that happens: PHP child processes keeping exit and restart continuously without
stop. Here are some of the lines of my FPM log (Debug):

*********************************************************************
[09-Sep-2016 12:51:00.158151] NOTICE: pid 15821, fpm_children_make(), line 421: [pool php7-admin]
child 1156 started
[09-Sep-2016 12:51:00.158164] DEBUG: pid 15821, fpm_event_loop(), line 419: event module triggered 1
events
[09-Sep-2016 12:51:00.161542] DEBUG: pid 15821, fpm_event_loop(), line 419: event module triggered 2
events
[09-Sep-2016 12:51:00.161571] DEBUG: pid 15821, fpm_got_signal(), line 76: received SIGCHLD
[09-Sep-2016 12:51:00.161585] NOTICE: pid 15821, fpm_children_bury(), line 252: [pool php7-admin]
child 1154 exited with code 0 after 0.011634 seconds from start
[09-Sep-2016 12:51:00.162047] NOTICE: pid 15821, fpm_children_make(), line 421: [pool php7-admin]
child 1157 started
[09-Sep-2016 12:51:00.162065] DEBUG: pid 15821, fpm_event_loop(), line 419: event module triggered 1
events
[09-Sep-2016 12:51:00.165706] DEBUG: pid 15821, fpm_event_loop(), line 419: event module triggered 2
events
[09-Sep-2016 12:51:00.165733] DEBUG: pid 15821, fpm_got_signal(), line 76: received SIGCHLD
[09-Sep-2016 12:51:00.165748] NOTICE: pid 15821, fpm_children_bury(), line 252: [pool php7-admin]
child 1155 exited with code 0 after 0.011767 seconds from start
[09-Sep-2016 12:51:00.166188] NOTICE: pid 15821, fpm_children_make(), line 421: [pool php7-admin]
child 1158 started
[09-Sep-2016 12:51:00.166201] DEBUG: pid 15821, fpm_event_loop(), line 419: event module triggered 1
events
[09-Sep-2016 12:51:00.169747] DEBUG: pid 15821, fpm_event_loop(), line 419: event module triggered 2
events
[09-Sep-2016 12:51:00.169773] DEBUG: pid 15821, fpm_got_signal(), line 76: received SIGCHLD
[09-Sep-2016 12:51:00.169786] NOTICE: pid 15821, fpm_children_bury(), line 252: [pool php7-admin]
child 1156 exited with code 0 after 0.011643 seconds from start
*************************************************

There are millions of line in that log files that are created in just few hours. 

After I restart PHP Master process,  everything return normal for few hours. After that I find high
CPU load for the master process, and check the log to find this outcome.

I tried to unload extensions, changing "pm" to static and back to ondemand. But always the
same result (PHP FPM goes crazy after few hours).

Here is my PHP-FPM conf

[global]
emergency_restart_threshold = 100
emergency_restart_interval = 1d
error_log = log/php-fpm-admin.log
log_level = debug

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

[php7-admin]
user = myuser
group = myuser
listen = /home/myuser/php7-admin.sock
listen.owner = myuser
listen.group = nogroup
listen.mode = 0660
listen.backlog=2000
pm = static
pm.max_children = 3
pm.process_idle_timeout = 10
pm.max_requests = 2000
security.limit_extensions = .php
catch_workers_output = yes


I really need to resolve this issue before I move on in my project. I searched the whole bug system
and internet if anything can help with no luck. I only found (somehow similar) bug https://bugs.php.net/bug.php?id=70185




Test script:
---------------
No test script. it Just happens without executing specific script.

Expected result:
----------------
Expected that PHP-FPM only kill child processes after reaching pm.process_idle_timeout > 10
seconds OR pm.max_requests > 2000 in "ondemand" or only after reaching the
pm.max_requests in static mode.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73056&edit=1


Thread (6 messages)

« previous php.bugs (#204770) next »