Browse Source

[master] avoid crowded more writable for auto grow (#6214)

avoid crowded more writable
https://github.com/seaweedfs/seaweedfs/issues/6121
pull/6267/head
Konstantin Lebedev 1 month ago
committed by GitHub
parent
commit
a49d9e020c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      weed/server/master_grpc_server_volume.go
  2. 7
      weed/topology/volume_layout.go

9
weed/server/master_grpc_server_volume.go

@ -43,12 +43,12 @@ func (ms *MasterServer) DoAutomaticVolumeGrow(req *topology.VolumeGrowRequest) {
func (ms *MasterServer) ProcessGrowRequest() { func (ms *MasterServer) ProcessGrowRequest() {
go func() { go func() {
ctx := context.Background() ctx := context.Background()
firstRun := true
firstRun := true
for { for {
if firstRun { if firstRun {
firstRun = false
firstRun = false
} else { } 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() { if !ms.Topo.IsLeader() {
continue continue
@ -71,9 +71,6 @@ func (ms *MasterServer) ProcessGrowRequest() {
case mustGrow > 0: case mustGrow > 0:
vgr.WritableVolumeCount = uint32(mustGrow) vgr.WritableVolumeCount = uint32(mustGrow)
_, err = ms.VolumeGrow(ctx, vgr) _, err = ms.VolumeGrow(ctx, vgr)
case crowded+volumeGrowStepCount >= writable:
vgr.WritableVolumeCount = volumeGrowStepCount
_, err = ms.VolumeGrow(ctx, vgr)
default: default:
for _, dc := range dcs { for _, dc := range dcs {
if vl.ShouldGrowVolumesByDataNode("DataCenter", dc) { if vl.ShouldGrowVolumesByDataNode("DataCenter", dc) {

7
weed/topology/volume_layout.go

@ -407,10 +407,10 @@ func (vl *VolumeLayout) removeFromWritable(vid needle.VolumeId) bool {
break break
} }
} }
vl.removeFromCrowded(vid)
if toDeleteIndex >= 0 { if toDeleteIndex >= 0 {
glog.V(0).Infoln("Volume", vid, "becomes unwritable") glog.V(0).Infoln("Volume", vid, "becomes unwritable")
vl.writables = append(vl.writables[0:toDeleteIndex], vl.writables[toDeleteIndex+1:]...) vl.writables = append(vl.writables[0:toDeleteIndex], vl.writables[toDeleteIndex+1:]...)
vl.removeFromCrowded(vid)
return true return true
} }
return false return false
@ -506,7 +506,10 @@ func (vl *VolumeLayout) SetVolumeCapacityFull(vid needle.VolumeId) bool {
} }
func (vl *VolumeLayout) removeFromCrowded(vid needle.VolumeId) { 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) { func (vl *VolumeLayout) setVolumeCrowded(vid needle.VolumeId) {

Loading…
Cancel
Save