Skip to content

Commit

Permalink
[master] avoid crowded more writable for auto grow (seaweedfs#6214)
Browse files Browse the repository at this point in the history
avoid crowded more writable
seaweedfs#6121
  • Loading branch information
kmlebedev authored Nov 21, 2024
1 parent 75f5afa commit a49d9e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 3 additions & 6 deletions weed/server/master_grpc_server_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ func (ms *MasterServer) DoAutomaticVolumeGrow(req *topology.VolumeGrowRequest) {
func (ms *MasterServer) ProcessGrowRequest() {
go func() {
ctx := context.Background()
firstRun := true
firstRun := true
for {
if firstRun {
firstRun = false
firstRun = false
} else {
time.Sleep(14*time.Minute + time.Duration(120*rand.Float32())*time.Second)
time.Sleep(5*time.Minute + time.Duration(30*rand.Float32())*time.Second)
}
if !ms.Topo.IsLeader() {
continue
Expand All @@ -71,9 +71,6 @@ func (ms *MasterServer) ProcessGrowRequest() {
case mustGrow > 0:
vgr.WritableVolumeCount = uint32(mustGrow)
_, err = ms.VolumeGrow(ctx, vgr)
case crowded+volumeGrowStepCount >= writable:
vgr.WritableVolumeCount = volumeGrowStepCount
_, err = ms.VolumeGrow(ctx, vgr)
default:
for _, dc := range dcs {
if vl.ShouldGrowVolumesByDataNode("DataCenter", dc) {
Expand Down
7 changes: 5 additions & 2 deletions weed/topology/volume_layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ func (vl *VolumeLayout) removeFromWritable(vid needle.VolumeId) bool {
break
}
}
vl.removeFromCrowded(vid)
if toDeleteIndex >= 0 {
glog.V(0).Infoln("Volume", vid, "becomes unwritable")
vl.writables = append(vl.writables[0:toDeleteIndex], vl.writables[toDeleteIndex+1:]...)
vl.removeFromCrowded(vid)
return true
}
return false
Expand Down Expand Up @@ -506,7 +506,10 @@ func (vl *VolumeLayout) SetVolumeCapacityFull(vid needle.VolumeId) bool {
}

func (vl *VolumeLayout) removeFromCrowded(vid needle.VolumeId) {
delete(vl.crowded, vid)
if _, ok := vl.crowded[vid]; ok {
glog.V(0).Infoln("Volume", vid, "becomes uncrowded")
delete(vl.crowded, vid)
}
}

func (vl *VolumeLayout) setVolumeCrowded(vid needle.VolumeId) {
Expand Down

0 comments on commit a49d9e0

Please sign in to comment.