-
Notifications
You must be signed in to change notification settings - Fork 7.9k
#69724: pm.ondemand forks fewer child workers than it should #1308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Conflicts: sapi/fpm/fpm/fastcgi.c
Conflicts: sapi/fpm/fpm/fastcgi.c
…aphp55-fork-fix Conflicts: sapi/fpm/fpm/fastcgi.c
Conflicts: sapi/fpm/fpm/fpm_main.c
|
||
### Dynamic | ||
|
||
### Ondemand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section describes the reported problem and proposed solution.
An additional benefit of this change is that it makes pm.ondemand work on any supported OS since it no longer uses edge-triggering. |
A cleaned version of the above 'patch' that checks against the PHP 5.6.10 branch:
Patch was tested against PHP 5.6.10 branch. |
I submitted my PR against 5.5 because the bug submission guidelines specifically said to do so. I'm happy to re-submit it against 5.6 if that is preferred. |
I just found this after submitting https://bugs.php.net/bug.php?id=72935 |
Patch updated for newer 5.6 |
Since this targets a security fix only branch, and since a patch against a supported branch would have to be different, I'm closing this PR. Please take this action as encouragement to open a clean PR against a supported branch. On a side note, if you wish to add a document like the design document included in this PR, can I ask that this is made as a separate pull request from this fix. |
@krakjoe I opened this PR in May 2015, 14 months before PHP 5.5 was EOL'ed. Please explain why I should feel motivated to update and re-test the patch against a newer version. Will my new PR be acted on in a timely fashion? |
That's a reasonable question. This is a larger patch to FPM, a component most of us are not familiar with... Do we have someone who is able+willing to review a rebased version of this change? |
@bjaspan sorry about the way this has been handled, that it was ignored for so long ... We are trying to find someone who can review it ... please do the PR, and I'll make noise until someone ok's it, that's the best I can do ... as Nikita said, most of us are unfamiliar, or have cursory familiarity with fpm. We are fixing the way all pull requests are dealt with ... again, sorry ... |
You want it first for PHP 7 now, right? |
I would recommend to target the master branch. (This probably won't go into PHP-7.0 at this point, per this comment.) |
Yeah, master is best. |
@bjaspan Please see the updated patch in https://bugs.php.net/bug.php?id=69724 . The original patch fixed the problem caused a FPM to spawn too many (potentially 100s) of processes when you just connected to the socket. cPanel tracked this as CPANEL-9788 Replication of that problem below from that case:
Example of what I see happen consistently on a test machine:
I used "nc" in these examples because it's only connecting to the socket and then disconnecting. On my personal test VM the problem is much less severe (this is a race condition), but php-fpm does spawn multiple processes when it should not, I got 6 of them out of this test, sometimes it is only 3:
Its hard to trigger the race condition so 99/100 times it works as exepected:
|
@bdraco Please clarify: Are you saying that the change proposed in this PR, and in https://bugs.php.net/bug.php?id=69724, has the race condition bug causing many extra child procs to be spawned on socket connect/disconnect? |
@bjaspan Yes, the original patch does. Please see the new patch here : https://bugs.php.net/patch-display.php?bug_id=69724&patch=SmallerPatchKeepsEdgeLevelAndChildrenTellParentsMore&revision=latest |
Realistically, I am unlikely to have time to update and test this PR. Since @bdraco seems to have become involved, I recommend going with his work. I do strongly suggest accepting the design documentation that I wrote. One big problem with FPM is that it is a big pile of completely undocumented code, making it almost impossible for anyone to improve it. I wrote the design docs as I figured out what I needed to figure out to write this PR. It would be a shame to lose that knowledge. |
Hi, As a note, cPanel has hired RogueWave to dig into this breakage and hopefully come to a proper solution. We are working with Ryan and Maurice at this point on this bug. |
What issues or PRs should I subscribe to to be notified of further progress? Just https://bugs.php.net/bug.php?id=69724? |
Both places would be good to monitor for movement. |
@bjaspan just found your design document by chance, after a day of trying to understand how FPM works internally. May I encourage you to submit that as a PR on its own? It’s a valuable addition that you must have put a lot of time into. |
Just a note here that I finally picked this up. I'm not too thrilled about introducing new pipes but can't currently think about better solution. I will try to think more about it but if I don't figure out something better, I will update this to some more acceptable form and play with it. It should hopefully get fixed in 2025 - it's currently my FPM priority. |
Glad to hear it! I have long since moved on and am no longer involved with PHP, though. |
Sure no worries. Apology for such a long delay. It was created before I started maintaining FPM and way before PHP Foundation was created so there was no real funding to get it handled. Things are better now so this should get finally sorted out. |
This PR is a proposed solution to https://bugs.php.net/bug.php?id=69724. The changes are subtle and to critical code within FPM, so it needs a careful review. I took the liberty of starting a new file, DESIGN.md, to document how FPM works internally. This allowed me to describe the complete situation and how this change solves it.