php / php/php-src

FPM idle or req timeout causes no child available if write is delayed

Đang mở
#11,765 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Bug SAPI: fpm
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với reproducer FPM\Tester được tích hợp, đặc biệt là cấu hình ondemand, pm.process_idle_timeout, kết nối keep-alive và thao tác ghi bị trì hoãn. Chạy bài kiểm thử sử dụng nhiều tài nguyên trên Linux và kiểm tra cách xử lý trạng thái nhàn rỗi của tiến trình FPM cùng đầu ra kiểm thử liên quan; công việc được xem là hoàn tất khi yêu cầu bị trì hoãn vẫn có thể sử dụng và không tạo ra thông báo đặt lại kết nối nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, php
Lĩnh vực
backend, testing
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.