volume.balance: add delay during tight loop

fix https://github.com/chrislusf/seaweedfs/issues/2637
This commit is contained in:
chrislu 2022-02-08 00:53:55 -08:00
parent 9860405974
commit f18803424a
16 changed files with 22 additions and 17 deletions

View file

@ -38,7 +38,7 @@ func (c *commandCollectionList) Do(args []string, commandEnv *CommandEnv, writer
return err return err
} }
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -206,7 +206,7 @@ func collectEcNodes(commandEnv *CommandEnv, selectedDataCenter string) (ecNodes
// list all possible locations // list all possible locations
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return return
} }

View file

@ -8,6 +8,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/storage/types"
"io" "io"
"time"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -53,7 +54,7 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
vid := needle.VolumeId(*volumeId) vid := needle.VolumeId(*volumeId)
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }
@ -233,7 +234,11 @@ func lookupVolumeIds(commandEnv *CommandEnv, volumeIds []string) (volumeIdLocati
return resp.VolumeIdLocations, nil return resp.VolumeIdLocations, nil
} }
func collectTopologyInfo(commandEnv *CommandEnv) (topoInfo *master_pb.TopologyInfo, volumeSizeLimitMb uint64, err error) { func collectTopologyInfo(commandEnv *CommandEnv, delayBeforeCollecting time.Duration) (topoInfo *master_pb.TopologyInfo, volumeSizeLimitMb uint64, err error) {
if delayBeforeCollecting > 0 {
time.Sleep(delayBeforeCollecting)
}
var resp *master_pb.VolumeListResponse var resp *master_pb.VolumeListResponse
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error { err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {

View file

@ -267,7 +267,7 @@ func balancedEcDistribution(servers []*EcNode) (allocated [][]uint32) {
func collectVolumeIdsForEcEncode(commandEnv *CommandEnv, selectedCollection string, fullPercentage float64, quietPeriod time.Duration) (vids []needle.VolumeId, err error) { func collectVolumeIdsForEcEncode(commandEnv *CommandEnv, selectedCollection string, fullPercentage float64, quietPeriod time.Duration) (vids []needle.VolumeId, err error) {
// collect topology information // collect topology information
topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv) topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return return
} }

View file

@ -35,7 +35,7 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i
} }
// collect collection information // collect collection information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -38,7 +38,7 @@ func (c *commandS3BucketQuotaEnforce) Do(args []string, commandEnv *CommandEnv,
} }
// collect collection information // collect collection information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -76,7 +76,7 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer
} }
// collect topology information // collect topology information
topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv) topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv, 15*time.Second)
if err != nil { if err != nil {
return err return err
} }

View file

@ -58,7 +58,7 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
c.env = commandEnv c.env = commandEnv
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -59,7 +59,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
} }
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -45,7 +45,7 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri
} }
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -75,7 +75,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
fixedVolumeReplicas := map[string]int{} fixedVolumeReplicas := map[string]int{}
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 15*time.Second)
if err != nil { if err != nil {
return err return err
} }

View file

@ -455,7 +455,7 @@ func (c *commandVolumeFsck) collectVolumeIds(commandEnv *CommandEnv, verbose boo
volumeIdToServer = make(map[uint32]VInfo) volumeIdToServer = make(map[uint32]VInfo)
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return return
} }

View file

@ -39,7 +39,7 @@ func (c *commandVolumeList) Do(args []string, commandEnv *CommandEnv, writer io.
} }
// collect topology information // collect topology information
topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv) topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -78,7 +78,7 @@ func volumeServerEvacuate(commandEnv *CommandEnv, volumeServer string, skipNonMo
// list all the volumes // list all the volumes
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -57,7 +57,7 @@ func (c *commandVolumeTierDownload) Do(args []string, commandEnv *CommandEnv, wr
vid := needle.VolumeId(*volumeId) vid := needle.VolumeId(*volumeId)
// collect topology information // collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv) topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }

View file

@ -74,7 +74,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
} }
// collect topology information // collect topology information
topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv) topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv, 0)
if err != nil { if err != nil {
return err return err
} }