Bug #67583 [Opn]: double fastcgi_end_request on max_children limit

From: Date: Thu, 05 Feb 2015 05:17:09 +0000
Subject: Bug #67583 [Opn]: double fastcgi_end_request on max_children limit
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190471@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67583&edit=1

 ID:                 67583
 User updated by:    saprykin dot dmitry at gmail dot com
 Reported by:        saprykin dot dmitry at gmail dot com
 Summary:            double fastcgi_end_request on max_children limit
 Status:             Open
 Type:               Bug
 Package:            FPM related
 PHP Version:        5.5.14
 Block user comment: N
 Private report:     N

 New Comment:

No. It is not merged. It is just labeled as bugfix. See php-src/710 request


Previous Comments:
------------------------------------------------------------------------
[2015-02-04 16:36:46] sdgf at example dot com

I see the pull request is merged. Is this fixed in any stable PHP release?

------------------------------------------------------------------------
[2014-07-07 11:18:18] saprykin dot dmitry at gmail dot com

Changed PHP Version

------------------------------------------------------------------------
[2014-07-07 10:37:59] saprykin dot dmitry at gmail dot com

Description:
------------
Php sends 2 fastcgi FCGI_END_REQUEST records instead of one when fastcgi_finish_request(); called
and fpm param max_requests exceeded.

* one is sent on fastcgi_finish_request(); call
* other is sent in block  

fpm_main.c:1951 

requests++; 
if (max_requests && (requests == max_requests)) { 
    fcgi_finish_request(&request, 1); 
    break; 
}


I have created pull request for this bug https://github.com/php/php-src/pull/709
 
It confuses fastcgi client (i.e. nginx) receiving 2 FCGI_END_REQUEST records one after another.

Test script:
---------------
<?php

ignore_user_abort();
fastcgi_finish_request();
sleep(10);

?>

Nginx configuration

upstream fpm
{
    server 127.0.0.1:9000;
    keepalive 1;
}

server
{
    ......
    fastcgi_keep_conn on;
    fastcgi_param SCRIPT_NAME /index.php;
    fastcgi_pass fpm;
    ......
}

PHP FPM configuration

max_children = 1
max_requests = 2

Expected result:
----------------
No errors in nginx error log

Actual result:
--------------
Every second request is finished with 502 status

Nginx error.log contains records:

2014/07/07 13:42:58 [error] 11253#0: *1 upstream sent unexpected FastCGI record: 3 while reading
response header from upstream, client: 127.0.0.1, server: localhost, request: "GET
/nginx_test.phtml HTTP/1.1", upstream: "fastcgi://127.0.0.1:8002", host:
"localhost:8081"


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



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


Thread (8 messages)

« previous php.bugs (#190471) next »