Bug #79928 [Opn]: fastcgi_finish_request() doesn't finish request

From: Date: Mon, 28 Dec 2020 20:00:10 +0000
Subject: Bug #79928 [Opn]: fastcgi_finish_request() doesn't finish request
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231278@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79928&edit=1 ID: 79928 Updated by: bukka@php.net Reported by: vedad at kajtaz dot net Summary: fastcgi_finish_request() doesn't finish request Status: Open Type: Bug Package: FPM related Operating System: FreeBSD 12.1-RELEASE PHP Version: 7.4.8 -Assigned To: +Assigned To: bukka Block user comment: N Private report: N New Comment: It's a bit late reply but you might want to read the comment in https://www.php.net/manual/en/function.fastcgi-finish-request.php which explains what can potentially happen. I would probably first check fpm status or even better set some monitoring to see how busy the children are and if you are using pm.max_children. Basically the timeout can happen if all children are overloaded with the lengthy tasks. Please update this bug if you notice something that you think doesn't look right in FPM. Previous Comments: ------------------------------------------------------------------------ [2020-08-04 13:47:09] vedad at kajtaz dot net Description: ------------ Hi, I have a FPM (unix socket) + nginx setup. I have a couple of scripts, invoked from cron through nginx, that are designed to run lengthy tasks. The very first thing these scripts do is to invoke fastcgi_finish_request() (after going through some routing logic). They don't produce any output, neither before nor after invoking fastcgi_finish_request(). I did try writing to stdout and/or seanding headers before the call, the behavior remains the same. Seldomly (roughly one request out of 10), FPM doesn't seem to notify nginx, which results in nginx reporting a timeout (which is configured to 30 seconds): 2020/08/03 18:38:33 [error] 82940#103032: *41412 upstream timed out (60: Operation timed out) while reading response header from upstream, client: XX.XXX.XXX.XXX, server: XXXXXXXXX.XXXXXXXXXX.com, request: "GET /cron/XXXXXXXXXX HTTP/1.1", upstream: "fastcgi://unix:/tmp/XXXXXXXXX.sock", host: "XXXXXXXXX.XXXXXXXXXX.com" Even when the 30 seconds timeout is not reached, I see instances of scripts running for more that a couple of milliseconds one would except when fastcgi_finish_request() is invoked straight away (first column = response time in seconds): 0.001 XX.XXX.XXX.XXX - - [04/Aug/2020:14:34:17 +0200] "GET /cron/XXXXXXXXXX HTTP/1.1" 200 5 "-" "cron" 17.253 XX.XXX.XXX.XXX - - [04/Aug/2020:14:34:17 +0200] "GET /cron/XXXXXXXXXX HTTP/1.1" 200 5 "-" "cron" I have no idea where to start to try debugging this issue. Any ideas? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79928&edit=1

« previous php.bugs (#231278) next »