diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-10-12 11:01:13 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-12 11:01:13 +0800 |
| commit | 2ff727a32d6d879a49ff5848b592518c96bb6403 (patch) | |
| tree | db952c7f054d44be208c5c4b4bc4c6769975a82c /weed/filer/reader_at.go | |
| parent | b9a446839a52739ddfdd072d0208c4dfe659056d (diff) | |
| parent | d5fcb0f474ac72389b89ba2d42adc4089b0f3e88 (diff) | |
| download | seaweedfs-2ff727a32d6d879a49ff5848b592518c96bb6403.tar.xz seaweedfs-2ff727a32d6d879a49ff5848b592518c96bb6403.zip | |
Merge pull request #25 from chrislusf/master
sync
Diffstat (limited to 'weed/filer/reader_at.go')
| -rw-r--r-- | weed/filer/reader_at.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go index fa51df687..835d6cfc2 100644 --- a/weed/filer/reader_at.go +++ b/weed/filer/reader_at.go @@ -11,6 +11,11 @@ import ( "io" "math/rand" "sync" + "time" +) + +var ( + ReadWaitTime = 6 * time.Second ) type ChunkReadAt struct { @@ -37,7 +42,8 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType { vid := VolumeId(fileId) locations, found := vidCache[vid] - if !found { + waitTime := time.Second + for !found && waitTime < ReadWaitTime { // println("looking up volume", vid) err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{ @@ -56,6 +62,16 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType { return nil }) + if err == nil { + break + } + glog.V(1).Infof("wait for volume %s", vid) + time.Sleep(waitTime) + waitTime += waitTime / 2 + } + + if err != nil { + return nil, err } for _, loc := range locations.Locations { |
