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
fix nil crash
Chris Lua61453d3ece8
diff --git a/weed/operation/lookup_vid_cache.go b/weed/operation/lookup_vid_cache.goindex 1ed03613d6..d4980a1f53 100644--- a/weed/operation/lookup_vid_cache.go+++ b/weed/operation/lookup_vid_cache.go@@ -3,6 +3,7 @@ package operationimport ("errors""strconv"+ "sync""time""github.com/chrislusf/seaweedfs/weed/glog"@@ -13,6 +14,7 @@ type VidInfo struct {NextRefreshTime time.Time}type VidCache struct {+ sync.RWMutexcache []VidInfo}@@ -22,6 +24,8 @@ func (vc *VidCache) Get(vid string) ([]Location, error) {glog.V(1).Infof("Unknown volume id %s", vid)return nil, err}+ vc.RLock()+ defer vc.RUnlock()if 0 < id && id <= len(vc.cache) {if vc.cache[id-1].Locations == nil {return nil, errors.New("Not Set")@@ -39,6 +43,8 @@ func (vc *VidCache) Set(vid string, locations []Location, duration time.Durationglog.V(1).Infof("Unknown volume id %s", vid)return}+ vc.Lock()+ defer vc.Unlock()if id > len(vc.cache) {for i := id - len(vc.cache); i > 0; i-- {vc.cache = append(vc.cache, VidInfo{})