Bug #60961 [Opn]: Graceful Restart (USR2) isn't very graceful

From: Date: Thu, 09 Dec 2021 22:15:23 +0000
Subject: Bug #60961 [Opn]: Graceful Restart (USR2) isn't very graceful
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238307@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60961&edit=1

 ID:                 60961
 Updated by:         bukka@php.net
 Reported by:        phpbugs at oops dot mooo dot com
 Summary:            Graceful Restart (USR2) isn't very graceful
 Status:             Open
 Type:               Bug
 Package:            FPM related
 Operating System:   Debian Squeeze
 PHP Version:        7.0
-Assigned To:        
+Assigned To:        bukka
 Block user comment: N
 Private report:     N

 New Comment:

There is now an improvement in PHP 8.1 that might help a bit. It's from this PR https://github.com/php/php-src/pull/6753 that
makes it possible to configure max spawn rate so it's done much faster. I will keep this open
as it's not a full solution but it can significantly reduce the mentioned issues.


Previous Comments:
------------------------------------------------------------------------
[2019-12-05 14:21:04] ingo dot bez at gmx dot de

May I ask carefully if and when this problem will be solved?
Seven years open, a patch functional since the beginning of 2017 and public for 11 months now...
Wow.

------------------------------------------------------------------------
[2019-10-03 11:43:01] mike@php.net

The following pull request has been associated:

Patch Name: php-fpm: graceful restart without blocking/losing requests
On GitHub:  https://github.com/php/php-src/pull/3758
Patch:      https://github.com/php/php-src/pull/3758.patch

------------------------------------------------------------------------
[2018-08-23 15:33:04] danny dot kopping at hetzner dot co dot za

Hi

We have been experiencing this issue for a while, and after some investigation - we think we have
isolated the issue.

This is how we understand it:
When FPM receives a USR2 signal, it attempts to wait for its children to finish processing, and then
sends a QUIT signal to each child. If a child does not respond in the amount of time defined in
"process_control_timeout" then the master process sends a TERM.

Now, while FPM is waiting for its children to terminate, it goes into a "reloading" state,
it would seem. It prints the message "Reloading in progress ..." to its log. During this
time, one can send as many USR2 signals to the master process as one likes - it will not cause any
problems. However, if one sends a USR2 signal after the
execvp("/usr/sbin/php-fpm7.1", {"/usr/sbin/php-fpm7.1",
"--nodaemonize", "--fpm-config",
"/etc/php/7.1/fpm/php-fpm.conf"}) syscall and before receiving the "fpm is
running, pid xxx" log entry - then it will crash the master process and consequently all the
children.

Our suspicion is that the signal handling is buggy between startup time and moving into the
"ready to accept connections" state (without looking at the source).

------------------------------------------------------------------------
[2018-07-01 08:35:49] i at xstudio dot me

mark!

------------------------------------------------------------------------
[2017-11-30 17:17:14] federico dot omoto at gmail dot com

And this is also affecting the recently released PHP 7.2.0.
Is this bug expected to be fixed in the short term?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=60961


--
Edit this bug report at https://bugs.php.net/bug.php?id=60961&edit=1


Thread (16 messages)

« previous php.bugs (#238307) next »