mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add retry if volume can not be found
This commit is contained in:
parent
70af0ec24c
commit
8a52379ecb
|
@ -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…
Reference in a new issue