php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74083 master PHP-fpm is stopped on multiple reloads
Submitted: 2017-02-11 06:03 UTC Modified: -
Votes:8
Avg. Score:4.4 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:5 (62.5%)
Same OS:4 (50.0%)
From: afalaleev at plesk dot com Assigned:
Status: Open Package: FPM related
PHP Version: 7.1.1 OS: CentOS 7.x
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-02-11 06:03 UTC] afalaleev at plesk dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC