reduce concurrent volume grow requests

This commit is contained in:
Chris Lu
2021-10-05 01:58:30 -07:00
parent 96119eab00
commit 332d49432d
3 changed files with 22 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ func (ms *MasterServer) ProcessGrowRequest() {
start := time.Now()
_, err := ms.vg.AutomaticGrowByType(req.Option, ms.grpcDialOption, ms.Topo, req.Count)
glog.V(1).Infoln("finished automatic volume grow, cost ", time.Now().Sub(start))
vl.DoneGrowRequest()
if req.ErrCh != nil {
req.ErrCh <- err
@@ -135,10 +136,11 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
vl := ms.Topo.GetVolumeLayout(option.Collection, option.ReplicaPlacement, option.Ttl, option.DiskType)
if vl.ShouldGrowVolumes(option) {
if !vl.HasGrowRequest() && vl.ShouldGrowVolumes(option) {
if ms.Topo.AvailableSpaceFor(option) <= 0 {
return nil, fmt.Errorf("no free volumes left for " + option.String())
}
vl.AddGrowRequest()
ms.vgCh <- &topology.VolumeGrowRequest{
Option: option,
Count: int(req.WritableVolumeCount),

View File

@@ -115,13 +115,14 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
vl := ms.Topo.GetVolumeLayout(option.Collection, option.ReplicaPlacement, option.Ttl, option.DiskType)
if vl.ShouldGrowVolumes(option) {
if !vl.HasGrowRequest() && vl.ShouldGrowVolumes(option) {
glog.V(0).Infof("dirAssign volume growth %v from %v", option.String(), r.RemoteAddr)
if ms.Topo.AvailableSpaceFor(option) <= 0 {
writeJsonQuiet(w, r, http.StatusNotFound, operation.AssignResult{Error: "No free volumes left for " + option.String()})
return
}
errCh := make(chan error, 1)
vl.AddGrowRequest()
ms.vgCh <- &topology.VolumeGrowRequest{
Option: option,
Count: writableVolumeCount,