Bug #77934 [NEW]: php-fpm kill -USR2 not working
| From: | marc+bugsphp at cdmon dot com | Date: | Wed, 24 Apr 2019 09:54:57 +0000 |
| Subject: | Bug #77934 [NEW]: php-fpm kill -USR2 not working | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220578@lists.php.net to get a copy of this message | ||
From: marc+bugsphp at cdmon dot com
Operating system: Debian 9
PHP version: 7.3.4
Package: FPM related
Bug Type: Bug
Bug description:php-fpm kill -USR2 not working
Description:
------------
When you try to restart graceful php-fpm it holds untill
process_control_timeout triggers and sends TERM to each child.
This happens from version 7.1.20 and 7.2.8, the fix that brokes this was
http://bugs.php.net/73342 the update was at 19 Jul 2018.
I was debugging the logs and found that the master process sends the
SIGQUIT to the childs, and then no reply from childs to master happens
since process_control_timeout stops:
>>> [24-Apr-2019 10:14:26.740642] DEBUG: pid 23148, fpm_pctl_kill_all(),
line 157: [pool marctestqa.com] sending signal 3 SIGQUIT to child 23165
The logs stucks on fpm_event_loop for process_control_timeout time, then
makes another fpm_pctl_kill_all but with SIGTERM:
>>> [24-Apr-2019 10:14:26.740697] DEBUG: pid 23148, fpm_event_loop(),
line 417: event module triggered 1 events
>>> [24-Apr-2019 10:14:46.741631] DEBUG: pid 23148, fpm_pctl_kill_all(),
line 157: [pool marctestqa.com] sending signal 15 SIGTERM to child
23165
Ok, fpm_event_loop is a timer that waits to the fpm_event_queue_fd:
>>> ret = module->wait(fpm_event_queue_fd, timeout); (line 409, file
fpm_events.c, php 7.3.4)
I will suppose that on debian the module system is epoll, then module =
fpm_event_epoll_module();, and then we have .wait =
fpm_event_epoll_wait,
ret = fpm_event_epoll_module->fpm_event_epoll_wait(fd,t)
And I can't follow this because I don't have more Linux internals
knowledge.
Test script:
---------------
edit php-fpm.conf and put some time into process_control_timeout:
[global]
process_control_timeout = 20s
Then open 2 terminals, in one call: watch -n0,1 "systemctl status
php-fpm.service".
On the other term call: kill -USR2 PHPFPMPID*.
then see how it waits the 20 seconds and force the kill (SIGTERM) onto
all the childrens. If you try this into 7.0 or prior to 7.2.8 or 7.1.20
it works.
*: PHPFPMPID: The current process ID of the Master.
Expected result:
----------------
A gradual restart of all the pools while they are freeing the sockets.
Actual result:
--------------
Wait till process_control_timeout, then SIGTERM all the pools.
--
Edit bug report at https://bugs.php.net/bug.php?id=77934&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77934&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77934&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77934&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77934&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77934&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77934&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77934&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77934&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77934&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77934&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77934&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77934&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77934&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77934&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77934&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77934&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77934&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77934&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77934&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77934&r=mysqlcfg