add retry if volume can not be found

This commit is contained in:
Chris Lu 2020-10-10 16:02:39 -07:00
parent 70af0ec24c
commit 8a52379ecb

View file

@ -11,6 +11,7 @@ import (
"io" "io"
"math/rand" "math/rand"
"sync" "sync"
"time"
) )
type ChunkReadAt struct { type ChunkReadAt struct {
@ -37,7 +38,8 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
vid := VolumeId(fileId) vid := VolumeId(fileId)
locations, found := vidCache[vid] locations, found := vidCache[vid]
if !found { waitTime := time.Second
for !found && waitTime < 6*time.Second {
// println("looking up volume", vid) // println("looking up volume", vid)
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{ resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
@ -56,6 +58,12 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
return nil return nil
}) })
if err == nil {
break
}
glog.V(1).Infof("wait for volume %s", vid)
time.Sleep(waitTime)
waitTime += waitTime / 2
} }
if err != nil { if err != nil {