Browse Source

mount: retry for directory listing with filer

related to https://github.com/chrislusf/seaweedfs/issues/1530
pull/1537/head
Chris Lu 4 years ago
parent
commit
28d4e1a51b
  1. 13
      weed/filesys/meta_cache/meta_cache_init.go

13
weed/filesys/meta_cache/meta_cache_init.go

@ -3,6 +3,8 @@ package meta_cache
import ( import (
"context" "context"
"fmt" "fmt"
"strings"
"time"
"github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
@ -16,6 +18,7 @@ func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.Full
glog.V(4).Infof("ReadDirAllEntries %s ...", path) glog.V(4).Infof("ReadDirAllEntries %s ...", path)
for waitTime := time.Second; waitTime < filer.ReadWaitTime; waitTime += waitTime / 2 {
err = filer_pb.ReadDirAllEntries(client, dirPath, "", func(pbEntry *filer_pb.Entry, isLast bool) error { err = filer_pb.ReadDirAllEntries(client, dirPath, "", func(pbEntry *filer_pb.Entry, isLast bool) error {
entry := filer.FromPbEntry(string(dirPath), pbEntry) entry := filer.FromPbEntry(string(dirPath), pbEntry)
if err := mc.doInsertEntry(context.Background(), entry); err != nil { if err := mc.doInsertEntry(context.Background(), entry); err != nil {
@ -27,8 +30,16 @@ func EnsureVisited(mc *MetaCache, client filer_pb.FilerClient, dirPath util.Full
} }
return nil return nil
}) })
if err != nil {
if err == nil {
break
}
if strings.Contains(err.Error(), "transport: ") {
glog.V(0).Infof("ReadDirAllEntries %s: %v. Retry in %v", path, err, waitTime)
time.Sleep(waitTime)
continue
}
err = fmt.Errorf("list %s: %v", dirPath, err) err = fmt.Errorf("list %s: %v", dirPath, err)
break
} }
return return
}) })

Loading…
Cancel
Save