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
protect locations slice
Chris Lu9f3f2f7c79d7
diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.goindex 2556049c33..4c43a225a8 100644--- a/weed/wdclient/vid_map.go+++ b/weed/wdclient/vid_map.go@@ -37,12 +37,7 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrl string, err errorreturn "", err}- locations := vc.GetLocations(uint32(id))- if len(locations) == 0 {- return "", fmt.Errorf("volume %d not found", id)- }-- return locations[vc.r.Intn(len(locations))].Url, nil+ return vc.GetRandomLocation(uint32(id))}func (vc *vidMap) LookupFileId(fileId string) (fullUrl string, err error) {@@ -85,6 +80,18 @@ func (vc *vidMap) GetLocations(vid uint32) (locations []Location) {return vc.vid2Locations[vid]}+func (vc *vidMap) GetRandomLocation(vid uint32) (serverUrl string, err error) {+ vc.RLock()+ defer vc.RUnlock()++ locations := vc.vid2Locations[vid]+ if len(locations) == 0 {+ return "", fmt.Errorf("volume %d not found", id)+ }++ return locations[vc.r.Intn(len(locations))].Url, nil+}+func (vc *vidMap) addLocation(vid uint32, location Location) {vc.Lock()defer vc.Unlock()