Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Use BackoffSchedule for getLookupFileId

Konstantin Lebedev7b1497ee63ce
diff --git a/weed/filer/stream.go b/weed/filer/stream.go
index 71808017ed..d1b66e88dc 100644
--- a/weed/filer/stream.go
+++ b/weed/filer/stream.go
@@ -18,6 +18,12 @@ import (
"github.com/chrislusf/seaweedfs/weed/wdclient"
)
+var getLookupFileIdBackoffSchedule = []time.Duration{
+ 150 * time.Millisecond,
+ 600 * time.Millisecond,
+ 1800 * time.Millisecond,
+}
+
func HasData(entry *filer_pb.Entry) bool {
if len(entry.Content) > 0 {
@@ -69,7 +75,15 @@ func StreamContent(masterClient wdclient.HasLookupFileIdFunction, writer io.Writ
fileId2Url := make(map[string][]string)
for _, chunkView := range chunkViews {
- urlStrings, err := masterClient.GetLookupFileIdFunction()(chunkView.FileId)
+ var urlStrings []string
+ var err error
+ for _, backoff := range getLookupFileIdBackoffSchedule {
+ urlStrings, err = masterClient.GetLookupFileIdFunction()(chunkView.FileId)
+ if err == nil && len(urlStrings) > 0 {
+ time.Sleep(backoff)
+ break
+ }
+ }
if err != nil {
glog.V(1).Infof("operation LookupFileId %s failed, err: %v", chunkView.FileId, err)
return err