From 7abed4e517dcc02ff2d3d12af1c46a00814efe9e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 23 Jun 2026 15:31:08 -0700 Subject: [PATCH] s3: skip 503 when client disconnects during remote cache wait (#10071) s3: don't write 503 to a disconnected client during remote cache wait When the remote-only cache poll returns without chunks, re-check the request context before emitting 503 + Retry-After. A client that disconnected during the wait surfaces as context.Canceled, which the caller already handles silently; writing to the closed connection only produced broken-pipe log noise. --- weed/s3api/s3api_object_handlers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index d71158567..ffd9a4b40 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -1011,6 +1011,11 @@ func (s3a *S3ApiServer) streamFromVolumeServers(w http.ResponseWriter, r *http.R } return newStreamErrorWithResponse(cacheErr) } else { + // Client disconnected during the cache wait: report cancellation, not 503, + // so we don't write to a closed connection. + if ctxErr := r.Context().Err(); ctxErr != nil { + return ctxErr + } // Cache not ready yet; return 503 with Retry-After for client backoff glog.V(1).Infof("streamFromVolumeServers: remote object %s/%s not cached yet, returning 503 for retry", bucket, object) w.Header().Set("Retry-After", "2")