Browse Source

Parallelize EC shards balancing across racks. (#6352)

pull/6354/head
Lisandro Pin 1 week ago
committed by GitHub
parent
commit
926cfea3dc
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 11
      weed/shell/command_ec_common.go

11
weed/shell/command_ec_common.go

@ -679,17 +679,18 @@ func (ecb *ecBalancer) doDeduplicateEcShards(collection string, vid needle.Volum
return nil return nil
} }
// TODO: enable parallelization
func (ecb *ecBalancer) balanceEcShardsAcrossRacks(collection string) error { func (ecb *ecBalancer) balanceEcShardsAcrossRacks(collection string) error {
// collect vid => []ecNode, since previous steps can change the locations // collect vid => []ecNode, since previous steps can change the locations
vidLocations := ecb.collectVolumeIdToEcNodes(collection) vidLocations := ecb.collectVolumeIdToEcNodes(collection)
// spread the ec shards evenly // spread the ec shards evenly
ecb.wgInit()
for vid, locations := range vidLocations { for vid, locations := range vidLocations {
if err := ecb.doBalanceEcShardsAcrossRacks(collection, vid, locations); err != nil {
return err
}
ecb.wgAdd(func() error {
return ecb.doBalanceEcShardsAcrossRacks(collection, vid, locations)
})
} }
return nil
return ecb.wgWait()
} }
func countShardsByRack(vid needle.VolumeId, locations []*EcNode) map[string]int { func countShardsByRack(vid needle.VolumeId, locations []*EcNode) map[string]int {

Loading…
Cancel
Save