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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Use fallback if urls are not found
Konstantin Lebedev01996bccf8ca
diff --git a/weed/filer/stream.go b/weed/filer/stream.goindex 7da9fd0a03..71808017ed 100644--- a/weed/filer/stream.go+++ b/weed/filer/stream.go@@ -69,14 +69,14 @@ func StreamContent(masterClient wdclient.HasLookupFileIdFunction, writer io.WritfileId2Url := make(map[string][]string)for _, chunkView := range chunkViews {-urlStrings, err := masterClient.GetLookupFileIdFunction()(chunkView.FileId)if err != nil {glog.V(1).Infof("operation LookupFileId %s failed, err: %v", chunkView.FileId, err)return err} else if len(urlStrings) == 0 {- glog.Errorf("operation LookupFileId %s failed, err: urls not found", chunkView.FileId)- return fmt.Errorf("operation LookupFileId %s failed, err: urls not found", chunkView.FileId)+ errUrlNotFound := fmt.Errorf("operation LookupFileId %s failed, err: urls not found", chunkView.FileId)+ glog.Error(errUrlNotFound)+ return errUrlNotFound}fileId2Url[chunkView.FileId] = urlStrings}diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.goindex 3e76dc0c5e..d6a06bb576 100644--- a/weed/wdclient/masterclient.go+++ b/weed/wdclient/masterclient.go@@ -2,6 +2,7 @@ package wdclientimport ("context"+ "fmt""github.com/chrislusf/seaweedfs/weed/stats""math/rand""time"@@ -44,7 +45,7 @@ func (mc *MasterClient) GetLookupFileIdFunction() LookupFileIdFunctionType {func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []string, err error) {fullUrls, err = mc.vidMap.LookupFileId(fileId)- if err == nil {+ if err == nil && len(fullUrls) > 0 {return}err = pb.WithMasterClient(false, mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error {@@ -52,7 +53,7 @@ func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []striVolumeOrFileIds: []string{fileId},})if err != nil {- return err+ return fmt.Errorf("LookupVolume failed: %v", err)}for vid, vidLocation := range resp.VolumeIdLocations {for _, vidLoc := range vidLocation.Locations {@@ -65,7 +66,6 @@ func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []strifullUrls = append(fullUrls, "http://"+loc.Url+"/"+fileId)}}-return nil})return