php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43224 support real graceful reload of fastcgi
Submitted: 2007-11-09 11:42 UTC Modified: 2013-02-18 00:33 UTC
From: glen at delfi dot ee Assigned: dmitry (profile)
Status: No Feedback Package: CGI/CLI related
PHP Version: 5.2.5RC2 OS: PLD Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: glen at delfi dot ee
New email:
PHP Version: OS:

 

 [2007-11-09 11:42 UTC] glen at delfi dot ee
Description:
------------
currently (checked 5.3 and 5.2) php-fcgi when receiving terminating 
signal, finishes the request, ie does not terminate immedately.

however it does not close the socket it is listening for incoming 
connections.

and there's no way to make the process really terminate in a nice 
way. ie if you really want to terminate fcgi backend processes while 
not caring whether the request is finished or not you can do this 
only by sending SIGKILL, but it might be too brutal :)

for the first problem i've created patch for unix (linux) platform, 
few testing shows that it really works.

for the second problem i'd suggest to use SIGINT for graceful 
restart (close listening socket, end when php processing finishes)

and SIGTERM would just close listening socket and abort php 
processing by making the child exit itself.

patch for 5.2.4 (also 5.2.5RC2):
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/php-fcgi-graceful.patch?only_with_tag=MAIN

patch for 5.3-snap:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/php-fcgi-graceful.patch?only_with_tag=DEVEL



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-11 11:18 UTC] glen at delfi dot ee
hi

any progress with the patch?

i can confirm that it works without problems since i initially 
created the patch.
 [2008-07-29 09:00 UTC] dmitry@php.net
FastCGI PHP SAPI supports only gracefull restart initiated by SIGTERM and SIGUSR1, however you still able to terminate worker processes with sending SIGINT/SIGQUIT to process group.

I'm not going to change it as it may break behavior with some FastCGI managers.
 [2008-07-29 09:22 UTC] glen at delfi dot ee
Didn't know about SIGQUIT, but ok, you can keep the signal handlers, 
but closing listening sockets on SIGTERM does not break process 
managers, it will do only good.

as for original behaviour, if you have some long running request 
running and you terminate fcgi processes with SIGTERM you can not 
start new fcgi processes on same tcp port (as the socket is still in 
use)

so to summarize signal handlers would be:
SIGTERM, SIGUSR1 - graceful shutdown -- listening sockets are 
closed, processing continues until scripts finish

SIGINT, SIGQUIT (, SIGKILL) - immediate shutdown -- listening 
sockets are closed, processes are terminated unconditionally whether 
they are idle or not.
 [2008-11-16 16:09 UTC] glen at delfi dot ee
ping?

for now the patch only makes php-fcgi to close listening socket on 
SIGTERM, so if it continues to run, new processes are able to spawn 
to the same tcp port.

http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/php-fcgi-graceful.patch?rev=1.8
 [2011-02-21 20:54 UTC] jani@php.net
-Package: Feature/Change Request +Package: CGI related
 [2011-04-08 15:48 UTC] dmitry@php.net
-Status: Assigned +Status: Feedback
 [2011-04-08 15:48 UTC] dmitry@php.net
the listening socket is already set into SO_REUSEADDR mode, so it's not a problem to start new PHP FastCGI process(es) while another is not finished yet.
 [2013-02-18 00:33 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 02 21:01:28 2024 UTC