Browse Source

add retry if volume can not be found

pull/1524/head
Chris Lu 4 years ago
parent
commit
8a52379ecb
  1. 10
      weed/filer/reader_at.go

10
weed/filer/reader_at.go

@ -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 {

Loading…
Cancel
Save