From 29d00ae7940407f941ef6ba89a92b3d1e24563ce Mon Sep 17 00:00:00 2001 From: "user.email" Date: Mon, 26 Oct 2026 02:55:56 -0700 Subject: [PATCH] volume: skip the proxy lookup error when the inbound request is gone --- weed/server/volume_server_handlers_read.go | 3 +++ weed/server/volume_server_handlers_read_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/weed/server/volume_server_handlers_read.go b/weed/server/volume_server_handlers_read.go index 1a5bd4839f..b12f8ef92c 100644 --- a/weed/server/volume_server_handlers_read.go +++ b/weed/server/volume_server_handlers_read.go @@ -67,6 +67,9 @@ func (vs *VolumeServer) proxyReqToTargetServer(w http.ResponseWriter, r *http.Re } lookupResult, err := operation.LookupVolumeIdWithContext(r.Context(), vs.GetMaster, vs.grpcDialOption, volumeId.String()) if err != nil && vs.ReadMode == "proxy" { + if r.Context().Err() != nil { + return + } glog.V(0).InfofCtx(r.Context(), "lookup error: %v %s", err, r.URL.Path) InternalError(w, r, nil) return diff --git a/weed/server/volume_server_handlers_read_test.go b/weed/server/volume_server_handlers_read_test.go index f4a1774124..cf0c2600c6 100644 --- a/weed/server/volume_server_handlers_read_test.go +++ b/weed/server/volume_server_handlers_read_test.go @@ -355,6 +355,18 @@ func TestProxyReqToTargetServerCancelsUpstreamBodyReadWithInboundRequest(t *test } func TestProxyReqToTargetServerDistinguishesLookupFailureFromNoLocation(t *testing.T) { + t.Run("cancelled request skips the lookup error response", func(t *testing.T) { + const volumeID = "849300107" + vs := newProxyTestVolumeServer(t, volumeID, nil, nil) + ctx, cancel := context.WithCancel(context.Background()) + cancel() + w := httptest.NewRecorder() + vs.proxyReqToTargetServer(w, httptest.NewRequest(http.MethodGet, "/"+volumeID+",abcdef", nil).WithContext(ctx)) + if w.Code != http.StatusOK { + t.Errorf("status %d, want no response written for a cancelled request", w.Code) + } + }) + t.Run("master lookup failure is internal error", func(t *testing.T) { const volumeID = "849300103" vs := newProxyTestVolumeServer(t, volumeID, nil, status.Error(codes.Unavailable, "master unavailable"))