mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
[master] avoid vacuum if not enough replica copies (#3924)
avoid vacuum if not enough replica copies
This commit is contained in:
parent
bf8a9d2db1
commit
409c9328de
|
@ -187,8 +187,12 @@ func (t *Topology) Vacuum(grpcDialOption grpc.DialOption, garbageThreshold float
|
||||||
if vl != nil {
|
if vl != nil {
|
||||||
volumeLayout := vl.(*VolumeLayout)
|
volumeLayout := vl.(*VolumeLayout)
|
||||||
if volumeId > 0 {
|
if volumeId > 0 {
|
||||||
if volumeLayout.Lookup(needle.VolumeId(volumeId)) != nil {
|
vid := needle.VolumeId(volumeId)
|
||||||
t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, preallocate)
|
volumeLayout.accessLock.RLock()
|
||||||
|
locationList, ok := volumeLayout.vid2location[vid]
|
||||||
|
volumeLayout.accessLock.RUnlock()
|
||||||
|
if ok {
|
||||||
|
t.vacuumOneVolumeId(grpcDialOption, volumeLayout, c, garbageThreshold, locationList, vid, preallocate)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, preallocate)
|
t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, preallocate)
|
||||||
|
@ -208,23 +212,27 @@ func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeL
|
||||||
volumeLayout.accessLock.RUnlock()
|
volumeLayout.accessLock.RUnlock()
|
||||||
|
|
||||||
for vid, locationList := range tmpMap {
|
for vid, locationList := range tmpMap {
|
||||||
|
t.vacuumOneVolumeId(grpcDialOption, volumeLayout, c, garbageThreshold, locationList, vid, preallocate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
volumeLayout.accessLock.RLock()
|
func (t *Topology) vacuumOneVolumeId(grpcDialOption grpc.DialOption, volumeLayout *VolumeLayout, c *Collection, garbageThreshold float64, locationList *VolumeLocationList, vid needle.VolumeId, preallocate int64) {
|
||||||
isReadOnly := volumeLayout.readonlyVolumes.IsTrue(vid)
|
volumeLayout.accessLock.RLock()
|
||||||
volumeLayout.accessLock.RUnlock()
|
isReadOnly := volumeLayout.readonlyVolumes.IsTrue(vid)
|
||||||
|
isEnoughCopies := volumeLayout.enoughCopies(vid)
|
||||||
|
volumeLayout.accessLock.RUnlock()
|
||||||
|
|
||||||
if isReadOnly {
|
if isReadOnly || !isEnoughCopies {
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("check vacuum on collection:%s volume:%d", c.Name, vid)
|
glog.V(2).Infof("check vacuum on collection:%s volume:%d", c.Name, vid)
|
||||||
if vacuumLocationList, needVacuum := t.batchVacuumVolumeCheck(
|
if vacuumLocationList, needVacuum := t.batchVacuumVolumeCheck(
|
||||||
grpcDialOption, vid, locationList, garbageThreshold); needVacuum {
|
grpcDialOption, vid, locationList, garbageThreshold); needVacuum {
|
||||||
if t.batchVacuumVolumeCompact(grpcDialOption, volumeLayout, vid, vacuumLocationList, preallocate) {
|
if t.batchVacuumVolumeCompact(grpcDialOption, volumeLayout, vid, vacuumLocationList, preallocate) {
|
||||||
t.batchVacuumVolumeCommit(grpcDialOption, volumeLayout, vid, vacuumLocationList)
|
t.batchVacuumVolumeCommit(grpcDialOption, volumeLayout, vid, vacuumLocationList)
|
||||||
} else {
|
} else {
|
||||||
t.batchVacuumVolumeCleanup(grpcDialOption, volumeLayout, vid, vacuumLocationList)
|
t.batchVacuumVolumeCleanup(grpcDialOption, volumeLayout, vid, vacuumLocationList)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue