Req #78413 [NEW]: request_terminate_timeout does not take effect after fastcgi_finish_request

From: Date: Wed, 14 Aug 2019 00:32:37 +0000
Subject: Req #78413 [NEW]: request_terminate_timeout does not take effect after fastcgi_finish_request
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222243@lists.php.net to get a copy of this message
From:             rs dot orlov at gmail dot com
Operating system: 
PHP version:      Irrelevant
Package:          FPM related
Bug Type:         Feature/Change Request
Bug description:request_terminate_timeout does not take effect after fastcgi_finish_request

Description:
------------
Hi there.

It is common practice to call fastcgi_finish_request as soon as response
is ready to be sent and defer some heavy load tasks after that. But here
is the problem: process will no longer be terminated if it exceeds
request_terminate_timeout.

It happens because fpm_request_finished called inside
fastcgi_finish_request changes request state to FPM_REQUEST_FINISHED.
But fpm_request_check_timed_out only checks processes being in state
between FPM_REQUEST_ACCEPTING and FPM_REQUEST_END.

Turns out that there is no way to limit execution time of a worker after
fastcgi_finish_request. That behavior may lead to all fpm-pool being
occupied.

Possible solution may be a config option which enables
fpm_request_check_timed_out for processes in FPM_REQUEST_FINISHED state,

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

fastcgi_finish_request();

$time = microtime(true);
// must be any time greater than configured request_terminate_timeout
$delaySec = 10;

while ($delaySec > (microtime(true) - $time)) {
	usleep(100000);
}


Expected result:
----------------
Php worker being terminated by fpm after %request_terminate_timeout% of
execution time


-- 
Edit bug report at https://bugs.php.net/bug.php?id=78413&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=78413&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=78413&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=78413&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=78413&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=78413&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=78413&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=78413&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=78413&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=78413&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=78413&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78413&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=78413&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=78413&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=78413&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=78413&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=78413&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=78413&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#222243) next »