Limit EC re-balancing for ec.encode to relevant collections when a volume ID argument is provided. (#6347)

Limit EC re-balancing for `ec.encode` to relevant collections when a volume ID is provided.
This commit is contained in:
Lisandro Pin
2024-12-12 17:41:33 +01:00
committed by GitHub
parent 6320036c56
commit 23ffbb083c
3 changed files with 76 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math/rand/v2"
"sort"
"time"
"github.com/seaweedfs/seaweedfs/weed/glog"
@@ -182,6 +183,46 @@ func collectEcNodes(commandEnv *CommandEnv) (ecNodes []*EcNode, totalFreeEcSlots
return collectEcNodesForDC(commandEnv, "")
}
func collectCollectionsForVolumeIds(t *master_pb.TopologyInfo, vids []needle.VolumeId) []string {
if len(vids) == 0 {
return nil
}
found := map[string]bool{}
for _, dc := range t.DataCenterInfos {
for _, r := range dc.RackInfos {
for _, dn := range r.DataNodeInfos {
for _, diskInfo := range dn.DiskInfos {
for _, vi := range diskInfo.VolumeInfos {
for _, vid := range vids {
if needle.VolumeId(vi.Id) == vid && vi.Collection != "" {
found[vi.Collection] = true
}
}
}
for _, ecs := range diskInfo.EcShardInfos {
for _, vid := range vids {
if needle.VolumeId(ecs.Id) == vid && ecs.Collection != "" {
found[ecs.Collection] = true
}
}
}
}
}
}
}
if len(found) == 0 {
return nil
}
collections := []string{}
for k, _ := range found {
collections = append(collections, k)
}
sort.Strings(collections)
return collections
}
func moveMountedShardToEcNode(commandEnv *CommandEnv, existingLocation *EcNode, collection string, vid needle.VolumeId, shardId erasure_coding.ShardId, destinationEcNode *EcNode, applyBalancing bool) (err error) {
if !commandEnv.isLocked() {