mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: retry for directory listing with filer
related to https://github.com/chrislusf/seaweedfs/issues/1530
This commit is contained in:
parent
c127da1219
commit
28d4e1a51b
|
@ -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,19 +18,28 @@ 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)
|
||||||
|
|
||||||
err = filer_pb.ReadDirAllEntries(client, dirPath, "", func(pbEntry *filer_pb.Entry, isLast bool) error {
|
for waitTime := time.Second; waitTime < filer.ReadWaitTime; waitTime += waitTime / 2 {
|
||||||
entry := filer.FromPbEntry(string(dirPath), pbEntry)
|
err = filer_pb.ReadDirAllEntries(client, dirPath, "", func(pbEntry *filer_pb.Entry, isLast bool) error {
|
||||||
if err := mc.doInsertEntry(context.Background(), entry); err != nil {
|
entry := filer.FromPbEntry(string(dirPath), pbEntry)
|
||||||
glog.V(0).Infof("read %s: %v", entry.FullPath, err)
|
if err := mc.doInsertEntry(context.Background(), entry); err != nil {
|
||||||
return err
|
glog.V(0).Infof("read %s: %v", entry.FullPath, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if entry.IsDirectory() {
|
||||||
|
childDirectories = append(childDirectories, entry.Name())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if entry.IsDirectory() {
|
if strings.Contains(err.Error(), "transport: ") {
|
||||||
childDirectories = append(childDirectories, entry.Name())
|
glog.V(0).Infof("ReadDirAllEntries %s: %v. Retry in %v", path, err, waitTime)
|
||||||
|
time.Sleep(waitTime)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("list %s: %v", dirPath, err)
|
err = fmt.Errorf("list %s: %v", dirPath, err)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue