diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go index 3a952a0d2..3342fece0 100644 --- a/weed/wdclient/masterclient.go +++ b/weed/wdclient/masterclient.go @@ -580,8 +580,9 @@ func (mc *MasterClient) resetVidMap() { mc.vidMapLock.Lock() defer mc.vidMapLock.Unlock() - // Create a shallow clone to preserve in the cache chain - tail := mc.vidMap.shallowClone() + // Preserve the existing vidMap in the cache chain + // No need to clone - the existing vidMap has its own mutex for thread safety + tail := mc.vidMap nvm := newVidMap(tail.DataCenter) nvm.cache.Store(tail) diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.go index 87848a3fc..179381b0c 100644 --- a/weed/wdclient/vid_map.go +++ b/weed/wdclient/vid_map.go @@ -54,21 +54,6 @@ func newVidMap(dataCenter string) *vidMap { } } -// shallowClone creates a shallow copy of the vidMap for use in cache chaining. -// The caller is responsible for ensuring thread safety. -func (vc *vidMap) shallowClone() *vidMap { - newMap := &vidMap{ - vid2Locations: vc.vid2Locations, - ecVid2Locations: vc.ecVid2Locations, - DataCenter: vc.DataCenter, - } - // Atomically copy the cache pointer - if cachedMap := vc.cache.Load(); cachedMap != nil { - newMap.cache.Store(cachedMap) - } - return newMap -} - func (vc *vidMap) getLocationIndex(length int) (int, error) { if length <= 0 { return 0, fmt.Errorf("invalid length: %d", length)