Skip to content

upstream: reply 503 to client when forwarding the request fails#16

Open
ChristopherWirt wants to merge 1 commit into
quantcast:masterfrom
ChristopherWirt:fix/upstream-write-error-no-client-reply
Open

upstream: reply 503 to client when forwarding the request fails#16
ChristopherWirt wants to merge 1 commit into
quantcast:masterfrom
ChristopherWirt:fix/upstream-write-error-no-client-reply

Conversation

@ChristopherWirt

Copy link
Copy Markdown
Collaborator

Problem

12_routing.t fails nondeterministically under concurrent load. The failures are reported as MISROUTE ... got='', but they are dropped responses, not misroutes: an occasional request receives no response at all and the client blocks until its read timeout (passing runs ~5.4s, failing runs ~10.5s — one client timeout longer).

Cause

In httplite_upstream_write_handler, when c->send() of the request to the upstream returns NGX_ERROR (the upstream connection failed or was refused under burst load), the handler deactivated the upstream and returned without replying to the waiting client.

Every other upstream-failure path (broken connection, read error, connect timeout) sends the client an HTTP 503, which the test treats as a retriable error. This one path sent nothing, so the client received no bytes and hung until timeout.

Fix

Send the same 503 Service Unavailable the read-error path uses before deactivating the upstream, so the client gets a retriable error instead of hanging.

Verification

  • 12_routing.t: 10/10 consecutive passes (was flaky).
  • Full suite passes.

The write handler deactivated the upstream on send() error without
replying to the waiting client, so the request hung until the client's
read timeout. Send a 503 like the other failure paths. Fixes the
12_routing.t flake.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant