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
add lock for vidCache
Chris Lubd103c143a8d
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.goindex f73f72429e..04c64d4498 100644--- a/weed/filer/reader_at.go+++ b/weed/filer/reader_at.go@@ -38,9 +38,12 @@ type LookupFileIdFunctionType func(fileId string) (targetUrls []string, err errofunc LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {vidCache := make(map[string]*filer_pb.Locations)+ var vicCacheLock sync.RWMutexreturn func(fileId string) (targetUrls []string, err error) {vid := VolumeId(fileId)+ vicCacheLock.RLock()locations, found := vidCache[vid]+ vicCacheLock.RUnlock()waitTime := time.Secondfor !found && waitTime < ReadWaitTime {@@ -58,7 +61,9 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {glog.V(0).Infof("failed to locate %s", fileId)return fmt.Errorf("failed to locate %s", fileId)}+ vicCacheLock.Lock()vidCache[vid] = locations+ vicCacheLock.Unlock()return nil})