FPM idle or req timeout causes no child available if write is delayed
オープン
まだ誰も着手していません。
Bug
SAPI: fpm
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
This problem can happen in ondemand mode if the connection is established but there is a significant write delay and pm.process_idle_timeout is set even to shorter value. In such case process idle can remove all children. But probably because the connection is established, it is past creating new child so the request fails.
The following tests results in such issue:
--TEST--
FPM: Process manager config pm.process_idle_timeout with keep alive set
--SKIPIF--
<?php
include "skipif.inc";
if (!getenv("FPM_RUN_RESOURCE_HEAVY_TESTS")) die("skip resource heavy test");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
require_once "tester.inc";
$cfg = <<<EOT
[global]
error_log = {{FILE:LOG}}
log_level = debug
[unconfined]
listen = {{ADDR}}
pm = ondemand
pm.max_children = 3
pm.min_spare_servers = 1
pm.process_idle_timeout = 1
pm.status_path = /status
;request_terminate_timeout = 2
EOT;
$code = <<<EOT
<?php
usleep(300000);
EOT;
$tester = new FPM\Tester($cfg, $code, clientTransport: 'stream');
$tester->start();
$tester->expectLogStartNotices();
//$tester->multiRequest(2, connKeepAlive: true);
$tester->multiRequest(2, connKeepAlive: true, writeDelay: 3000, readTimeout: 5000);
$tester->status([
'total processes' => 2,
]);
// wait for process idle timeout
sleep(2);
$tester->status([
'total processes' => 2,
]);
$tester->terminate();
$tester->expectLogTerminatingNotices();
$tester->close();
?>
Done
--EXPECT--
Done
--CLEAN--
<?php
require_once "tester.inc";
FPM\Tester::clean();
?>
Resulted in this output:
PHP Notice: fwrite(): Send of 611 bytes failed with errno=104 Connection reset by peer
But I expected this output instead:
no error
PHP Version
PHP 8
Operating System
Linux
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
組み込みの FPM\Tester reproducer から始め、特に ondemand 設定、pm.process_idle_timeout、keep-alive 接続、遅延書き込みを確認します。Linux 上でリソース負荷の高いテストを実行し、FPM のプロセスアイドル処理と関連するテスト出力を調査します。遅延したリクエストが引き続き使用可能で、connection-reset notice が生成されなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend, testing
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100