From: afalaleev at plesk dot com
Operating system: CentOS 7.x
PHP version: 7.1.1
Package: FPM related
Bug Type: Bug
Bug description:master PHP-fpm is stopped on multiple reloads
Description:
------------
PHP-FPM is stopped, when it receive more than one SIGUSR2 in a short
time.
The reason:
- On receiving SIGUSR2 php-fpm calls execvp(path, ...)
- Process starts.
-- It inherit all opened handles.
-- But all signal handlers is reseted to SIG_DFL
So, if SIGUSR2 income before process change the signal handler, it will
exit, because it's a default action on receiving SIGUSR2.
The bug is actual for all versions of PHP: 5.6, 7.0, 7.1.
The possible decision (in attached patch) is to block the signal before
execvp(...), and unblock it after changing the signal handlers.
The attached patch solve the problem for all versions of PHP: 5.6, 7.0,
7.1.
Test script:
---------------
With a high probability, it may happened on send 2 reloads without any
timeout:
# systemctl reload php71-fpm.service; systemctl reload
php71-fpm.service
For greater reliability, the following script can be executed:
# for i in $(seq 1 100); do systemctl reload php71-fpm.service; done
Expected result:
----------------
# systemctl status php71-fpm.service
â php71-fpm.service - The PHP 7.1.1 FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php71-fpm.service; enabled;
vendor preset: disabled)
Active: active (running) since Sat 2017-02-11 12:41:10 +07; 6min ago
Process: 17828 ExecReload=/bin/kill -USR2 $MAINPID (code=exited,
status=0/SUCCESS)
Main PID: 17002 (php-fpm)
Status: "Processes active: 0, idle: 0, Requests: 0, slow: 0, Traffic:
0req/sec"
CGroup: /system.slice/php71-fpm.service
ââ17002 php-fpm: master process
(/opt/php/7.1/etc/php-fpm.conf)
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Feb 11 12:41:30 a10-52-35-250.qa.ru systemd[1]: Reloaded The PHP 7.1.1
FastCGI Process Manager.
Actual result:
--------------
# systemctl status php71-fpm.service;
â php71-fpm.service - The PHP 7.1.1 FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php71-fpm.service; enabled;
vendor preset: disabled)
Active: failed (Result: signal) since Sat 2017-02-11 12:27:11 +07;
13min ago
Process: 16348 ExecReload=/bin/kill -USR2 $MAINPID (code=exited,
status=0/SUCCESS)
Main PID: 15808 (code=killed, signal=USR2)
Status: "Processes active: 0, idle: 0, Requests: 0, slow: 0, Traffic:
0req/sec"
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
Feb 11 12:27:12 a10-52-35-250.qa.ru systemd[1]: Unit php71-fpm.service
cannot be reloaded because it is inactive.
--
Edit bug report at https://bugs.php.net/bug.php?id=74083&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74083&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74083&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74083&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74083&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74083&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74083&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74083&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74083&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74083&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74083&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74083&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74083&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74083&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74083&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74083&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74083&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74083&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74083&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74083&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74083&r=mysqlcfg