mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
wdclient: serve a failed read's re-lookup without the master filter
The master drops a pushed update when a client's channel is full, so the gateway's view of a volume can lack a live replica. Filtering lookups by that view would then hand a read that failed on the listed server the same server again, and the read path retries only when the locations change. InvalidateCache now marks the volume, and its next provider answer is served whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac31753a68
commit
08c0a55265
2 files changed
+32
-1
No files matched your search
@@ -632,3 +632,20 @@ func TestPushedAddLeavesUncachedVolumeAlone(t *testing.T) {
|
||||
t.Fatalf("an add cached volume 5 at %v", cached)
|
||||
}
|
||||
}
|
||||
|
||||
// A master that dropped a replica's add lists only the other one. A read
|
||||
// failing there re-looks the volume up, and that answer must reach the
|
||||
// replica the master did not list.
|
||||
func TestRelookupAfterFailedReadServesWholeAnswer(t *testing.T) {
|
||||
a := Location{Url: "a:8080"}
|
||||
b := Location{Url: "b:8080"}
|
||||
provider := &testLocationProvider{locations: map[string][]Location{"5": {a, b}}}
|
||||
mc := moveClient()
|
||||
fc := hookedFilerClient(mc, provider)
|
||||
pushVolumeLocation(mc, a.Url, []uint32{5}, nil, nil, nil)
|
||||
expectServed(t, fc, "5", a)
|
||||
|
||||
fc.InvalidateCache("5,01")
|
||||
|
||||
expectServed(t, fc, "5", a, b)
|
||||
}
|
||||
@@ -46,6 +46,10 @@ type vidMapClient struct {
|
||||
// answered: that answer may still carry an earlier master's view, and a
|
||||
// server the current master never knew is never pushed as removed.
|
||||
authority *vidMap
|
||||
// relookups holds vids a failed read invalidated. Their next provider
|
||||
// answer is served whole, since the authority may lack a replica whose
|
||||
// add the master dropped on a full client channel.
|
||||
relookups map[uint32]struct{}
|
||||
}
|
||||
|
||||
type recentDelete struct {
|
||||
@@ -444,7 +448,9 @@ func (vc *vidMapClient) fillLocations(vid uint32, locations []Location, epoch ui
|
||||
vc.recentDeletesMu.Lock()
|
||||
defer vc.recentDeletesMu.Unlock()
|
||||
vc.expireRecentDeletes(time.Now())
|
||||
if vc.authority != nil {
|
||||
if _, relookup := vc.relookups[vid]; relookup {
|
||||
delete(vc.relookups, vid)
|
||||
} else if vc.authority != nil {
|
||||
if current, found := vc.authority.GetCurrentLocations(vid); found {
|
||||
if listed := listedLocations(locations, current); len(listed) > 0 {
|
||||
locations = listed
|
||||
@@ -498,5 +504,13 @@ func (vc *vidMapClient) InvalidateCache(fileId string) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if vc.authority != nil {
|
||||
vc.recentDeletesMu.Lock()
|
||||
if vc.relookups == nil {
|
||||
vc.relookups = make(map[uint32]struct{})
|
||||
}
|
||||
vc.relookups[uint32(vid)] = struct{}{}
|
||||
vc.recentDeletesMu.Unlock()
|
||||
}
|
||||
vc.vidMap.deleteVid(uint32(vid))
|
||||
}
|
||||
Reference in new issue
Block a user