filer: clear a dead test replica's reachability record before closing it (#12387)

* filer: clear a dead test replica's reachability record before closing it

The read path tries hosts that recently failed last. A dead test server
can land on a port an earlier test left marked as failed, so the live
replica answered first, nothing failed and the location refresh under
test never ran. Have the dead replica answer once through util_http so
its record is cleared before it closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: close the dead test replica when reaching it fails

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: clear the live test replica's reachability record too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 authored and GitHub committed 2026-11-03 20:47:43 -08:00
1 parent 329ccb8bc0
commit ba3fd257a3
2 files changed
+25 -7

No files matched your search

+21 -3
View File
@@ -160,9 +160,8 @@ func TestReaderCacheRefreshesLocationsAfterPartialFailure(t *testing.T) {
w.Write(payload)
}))
defer live.Close()
dead := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
deadURL := dead.URL
dead.Close()
reachServer(t, live)
deadURL := deadServerURL(t)
fileId := "3,abc"
invalidator := &mockCacheInvalidatorForReaderCache{}
@@ -191,6 +190,25 @@ func TestReaderCacheRefreshesLocationsAfterPartialFailure(t *testing.T) {
}
}
// reachServer has srv answer one request. The read path orders replicas by
// whether their host recently failed, and srv's port may be one an earlier test
// left marked as failed, so the answer clears that record.
func reachServer(t *testing.T, srv *httptest.Server) {
t.Helper()
if _, _, err := util_http.Get(srv.URL); err != nil {
t.Fatalf("reach %s: %v", srv.URL, err)
}
}
// deadServerURL is a replica that answered once and then went away.
func deadServerURL(t *testing.T) string {
t.Helper()
dead := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
defer dead.Close()
reachServer(t, dead)
return dead.URL
}
func TestReaderCacheRemovesFailedDownloader(t *testing.T) {
cache := newMockChunkCacheForReaderCache()
fileId := "425141,failed"