php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69724 pm.ondemand forks fewer child workers than it should
Submitted: 2015-05-28 23:10 UTC Modified: 2017-10-24 07:45 UTC
Votes:64
Avg. Score:4.9 ± 0.5
Reproduced:57 of 58 (98.3%)
Same Version:51 (89.5%)
Same OS:55 (96.5%)
From: barry at jaspan dot org Assigned:
Status: Open Package: FPM related
PHP Version: 5.5.25 OS: Linux
Private report: No CVE-ID: None
 [2015-05-28 23:10 UTC] barry at jaspan dot org
Description:
------------
The FPM pm.ondemand process manager has a subtle bug in the way it uses edge-triggered polling (with epoll() or kqueue()) that causes it not to notice when multiple requests arrive at the same time, and thus not to fork the appropriate number of children to handle them.  The bug was introduced during pm.ondemand's initial development, when the author switched from level-triggered select/poll to edge-triggered epoll/kqueue in order to a different bug that resulted in the fpm parent process entering a cpu spin loop for brief periods when new requests arrived.

The details of the bug are too subtle to fully describe here.  However, the PR I am about to submit for this bug report contains a new DESIGN.md file that includes a thorough explanation.



Test script:
---------------
I do not know how to create a self-contained test case for this.  However, using a custom web-testing tool I wrote called Goofy (https://github.com/bjaspan/goofy), it is easy to reproduce.  The README file in that repo shows using Goofy to demonstrate the exact bug in FPM that I am reporting here.

Expected result:
----------------
When N requests arrive nearly simultaneously, and FPM is allowed to fork N more processes, it should fork N more processes.

Actual result:
--------------
When N requests arrive nearly simultaneously, and FPM is allowed to fork N more processes, it almost always forks fewer than N processes, usually a lot fewer.  The exact number depends on race conditions with the fpm parent, children, epoll in the kernel, and who knows what else.

Patches

SmallerPatchKeepsEdgeLevelAndChildrenTellParentsMore (last revision 2016-11-24 16:47 UTC by nick at cpanel dot net)
Updatedpatchforlatest5.6 (last revision 2016-08-24 23:19 UTC by nick at cpanel dot net)
ywaqvokc (last revision 2015-07-16 12:07 UTC by sample at email dot tst)
blqcykmi (last revision 2015-07-16 12:01 UTC by sample at email dot tst)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-01 01:41 UTC] stas@php.net
-Assigned To: +Assigned To: fat
 [2017-10-24 07:45 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: fat +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 07:01:29 2024 UTC