clone volume locations in case they are changed

fix https://github.com/seaweedfs/seaweedfs/issues/4642
This commit is contained in:
chrislu
2023-07-06 00:32:58 -07:00
parent a315490f7d
commit 31b2751aff
5 changed files with 18 additions and 5 deletions

View File

@@ -141,6 +141,19 @@ func (vc *vidMap) GetLocations(vid uint32) (locations []Location, found bool) {
return nil, false
}
func (vc *vidMap) GetLocationsClone(vid uint32) (locations []Location, found bool) {
locations, found = vc.GetLocations(vid)
if found {
// clone the locations in case the volume locations are changed below
existingLocations := make([]Location, len(locations))
copy(existingLocations, locations)
return existingLocations, found
}
return nil, false
}
func (vc *vidMap) getLocations(vid uint32) (locations []Location, found bool) {
vc.RLock()
defer vc.RUnlock()