mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
fix: fix panic when generating plans (#35309)
issue: https://github.com/milvus-io/milvus/issues/35335 Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
parent
72a175478f
commit
ae1b81ac1a
@ -269,6 +269,9 @@ func (g *rowCountBasedPlanGenerator) generatePlans() []SegmentAssignPlan {
|
||||
})
|
||||
}
|
||||
maxNode, minNode := nodesWithRowCount[len(nodesWithRowCount)-1], nodesWithRowCount[0]
|
||||
if len(maxNode.segments) == 0 {
|
||||
break
|
||||
}
|
||||
segment := maxNode.segments[rand.Intn(len(maxNode.segments))]
|
||||
plan := SegmentAssignPlan{
|
||||
Segment: segment,
|
||||
@ -346,6 +349,9 @@ func (g *segmentCountBasedPlanGenerator) generatePlans() []SegmentAssignPlan {
|
||||
})
|
||||
}
|
||||
maxNode, minNode := nodesWithSegmentCount[len(nodesWithSegmentCount)-1], nodesWithSegmentCount[0]
|
||||
if len(maxNode.segments) == 0 {
|
||||
break
|
||||
}
|
||||
segment := maxNode.segments[rand.Intn(len(maxNode.segments))]
|
||||
plan := SegmentAssignPlan{
|
||||
Segment: segment,
|
||||
@ -399,6 +405,9 @@ func newRandomPlanGenerator(maxSteps int) *randomPlanGenerator {
|
||||
func (g *randomPlanGenerator) generatePlans() []SegmentAssignPlan {
|
||||
g.currClusterCost = g.calClusterCost(g.replicaNodeSegments, g.globalNodeSegments)
|
||||
nodes := lo.Keys(g.replicaNodeSegments)
|
||||
if len(nodes) == 0 {
|
||||
return g.plans
|
||||
}
|
||||
for i := 0; i < g.maxSteps; i++ {
|
||||
// random select two nodes and two segments
|
||||
node1 := nodes[rand.Intn(len(nodes))]
|
||||
@ -408,6 +417,9 @@ func (g *randomPlanGenerator) generatePlans() []SegmentAssignPlan {
|
||||
}
|
||||
segments1 := g.replicaNodeSegments[node1]
|
||||
segments2 := g.replicaNodeSegments[node2]
|
||||
if len(segments1) == 0 || len(segments2) == 0 {
|
||||
continue
|
||||
}
|
||||
segment1 := segments1[rand.Intn(len(segments1))]
|
||||
segment2 := segments2[rand.Intn(len(segments2))]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user