Skip to content

[S3] Cut off response bodies still streaming at the shutdown deadline #239

Closed

Description

@saworbit

With #231, S3Server::shutdown_on cuts off requests still running when the grace period ends: their handlers are dropped and the client gets 503 ServiceUnavailable. A handler that has already returned its response is past that point, though. A GET whose body is still streaming keeps its connection open, and that connection's task holds an Arc<S3View> (and the store's sled lock) after run() returns.

spacectl serve-s3 isn't affected in practice, since the process exits right after run() and the runtime drops the task. Code that embeds S3Server and keeps its runtime running is: the store stays open until the client finishes or disconnects.

Where: cut_off_when_told and the wind-down after cut_off.cancel() in crates/protocol-s3/src/server.rs.

Proposed: at the cut-off, end streaming response bodies too, for example by wrapping the response body in one that stops at the cancellation token. Implement http_body::Body directly so the size hint and Content-Length are kept rather than switching to chunked encoding.

Done when:

  • a test in crates/protocol-s3/tests/shutdown_test.rs starts a large GET, reads part of it, signals with a short grace period, and finds the store can be reopened once run() returns;
  • responses not cut off keep their Content-Length.

Activity

  1. added
    enhancement
    P3
    on Nov 15, 2026
  2. saworbit commented on Nov 15, 2026

    @saworbit
    OwnerAuthor

    Fixed in 5116505, PR #251. I put the cut-off on the connection rather than the response body. A client that stops reading leaves hyper waiting on the socket, so a wrapped body never gets polled. Each connection's IO now fails once a close token fires, and that wakes a write stuck on the client. run() fires it 1 s after the 503 cut-off. Bodies are untouched, so Content-Length stays. Test reopens the store while the client still holds the connection, and fails without the close. Changelog updated. Closes when the PR merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3enhancementprotocol-s3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions