Skip to content

A connection that arrives while the listeners are paused is answered 503 instead of waiting in the backlog #359

Closed

Description

@EdmondDantes

http_server_pause_listeners (src/http_server_class.c) calls stop() on each listen event and expects new connections to wait in the kernel backlog until the resume. php-async cannot stop a uv_listen (true-async/php-async#305), so accepts go on: each connection that arrives during a pause reaches http_server_accept_callback, and the hard-cap safety net answers it 503, a path its own comment calls rare.

Reproduction: tests/phpt/server/h1/062-h1-paused-listener-leaves-the-backlog.phpt, setMaxConnections(2), two parked requests, a third client during the pause: 503 Service Unavailable on 5 of 5 runs, while getTelemetry()['listeners_paused'] reads true.

The comments at the backpressure primitives are wrong on a second point: under SO_REUSEPORT the kernel keeps hashing new connections to a paused worker's socket, so they wait for that worker (or are dropped once its backlog is full) rather than going to another one.

The fix is in php-async. This repository gets the tests (062, a burst past the cap, a re-pause during delivery), corrected comments, and two counters: accepts_refused_at_cap_total (nonzero means a pause did not hold) and accept_errors_total (accept failures were dropped without a trace).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions