mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-22 06:20:05 +08:00
Fix a race condition when handle VolumeLocationList
This commit is contained in:
@@ -165,7 +165,7 @@ func vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLayout *VolumeL
|
||||
volumeLayout.accessLock.RLock()
|
||||
tmpMap := make(map[needle.VolumeId]*VolumeLocationList)
|
||||
for vid, locationList := range volumeLayout.vid2location {
|
||||
tmpMap[vid] = locationList
|
||||
tmpMap[vid] = locationList.Copy()
|
||||
}
|
||||
volumeLayout.accessLock.RUnlock()
|
||||
|
||||
|
@@ -18,6 +18,14 @@ func (dnll *VolumeLocationList) String() string {
|
||||
return fmt.Sprintf("%v", dnll.list)
|
||||
}
|
||||
|
||||
func (dnll *VolumeLocationList) Copy() *VolumeLocationList {
|
||||
list := make([]*DataNode, len(dnll.list))
|
||||
copy(list, dnll.list)
|
||||
return &VolumeLocationList{
|
||||
list: list,
|
||||
}
|
||||
}
|
||||
|
||||
func (dnll *VolumeLocationList) Head() *DataNode {
|
||||
//mark first node as master volume
|
||||
return dnll.list[0]
|
||||
|
Reference in New Issue
Block a user