aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_common.go
diff options
context:
space:
mode:
authorLisandro Pin <lisandro.pin@proton.ch>2024-12-13 15:05:32 +0100
committerGitHub <noreply@github.com>2024-12-13 06:05:32 -0800
commit926cfea3dca8f836e5133b2e56007fdec9e13b34 (patch)
tree16dbe87fd984a65ce71ac5c0d6a3ff83f434c235 /weed/shell/command_ec_common.go
parentb81def5e5c3e936098aba07f203796890f2acf69 (diff)
downloadseaweedfs-926cfea3dca8f836e5133b2e56007fdec9e13b34.tar.xz
seaweedfs-926cfea3dca8f836e5133b2e56007fdec9e13b34.zip
Parallelize EC shards balancing across racks. (#6352)
Diffstat (limited to 'weed/shell/command_ec_common.go')
-rw-r--r--weed/shell/command_ec_common.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index c38518664..fff3db429 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -679,17 +679,18 @@ func (ecb *ecBalancer) doDeduplicateEcShards(collection string, vid needle.Volum
return nil
}
-// TODO: enable parallelization
func (ecb *ecBalancer) balanceEcShardsAcrossRacks(collection string) error {
// collect vid => []ecNode, since previous steps can change the locations
vidLocations := ecb.collectVolumeIdToEcNodes(collection)
+
// spread the ec shards evenly
+ ecb.wgInit()
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 {