mirror of https://github.com/milvus-io/milvus.git
skip to balance redundant segment (#23490)
Signed-off-by: Wei Liu <wei.liu@zilliz.com>pull/23508/head
parent
cbfe7a45ef
commit
3933080511
|
@ -152,9 +152,6 @@ func (b *RowCountBasedBalancer) balanceReplica(replica *meta.Replica) ([]Segment
|
|||
}
|
||||
}
|
||||
|
||||
log.Info("balance channel xxxxx",
|
||||
zap.Int64s("online nodes", lo.Keys(onlineNodesSegments)),
|
||||
zap.Int64s("offline nodes", lo.Keys(stoppingNodesSegments)))
|
||||
if len(nodes) == len(stoppingNodesSegments) || len(onlineNodesSegments) == 0 {
|
||||
// no available nodes to balance
|
||||
return nil, nil
|
||||
|
@ -189,6 +186,11 @@ func (b *RowCountBasedBalancer) balanceReplica(replica *meta.Replica) ([]Segment
|
|||
}
|
||||
}
|
||||
|
||||
segmentsToMove = lo.Filter(segmentsToMove, func(s *meta.Segment, _ int) bool {
|
||||
// if the segment are redundant, skip it's balance for now
|
||||
return len(b.dist.SegmentDistManager.Get(s.GetID())) == 1
|
||||
})
|
||||
|
||||
return b.genSegmentPlan(replica, nodesWithLessRow, segmentsToMove, average), b.genChannelPlan(replica, lo.Keys(onlineNodesSegments), lo.Keys(stoppingNodesSegments))
|
||||
}
|
||||
|
||||
|
|
|
@ -162,6 +162,21 @@ func (suite *RowCountBasedBalancerTestSuite) TestBalance() {
|
|||
},
|
||||
expectChannelPlans: []ChannelAssignPlan{},
|
||||
},
|
||||
{
|
||||
name: "skip balance for redundant segment",
|
||||
nodes: []int64{1, 2},
|
||||
segmentCnts: []int{1, 2},
|
||||
states: []session.State{session.NodeStateNormal, session.NodeStateNormal},
|
||||
distributions: map[int64][]*meta.Segment{
|
||||
1: {{SegmentInfo: &datapb.SegmentInfo{ID: 1, CollectionID: 1, NumOfRows: 20}, Node: 1}},
|
||||
2: {
|
||||
{SegmentInfo: &datapb.SegmentInfo{ID: 1, CollectionID: 1, NumOfRows: 20}, Node: 2},
|
||||
{SegmentInfo: &datapb.SegmentInfo{ID: 3, CollectionID: 1, NumOfRows: 40}, Node: 2},
|
||||
},
|
||||
},
|
||||
expectPlans: []SegmentAssignPlan{},
|
||||
expectChannelPlans: []ChannelAssignPlan{},
|
||||
},
|
||||
{
|
||||
name: "balance won't trigger",
|
||||
nodes: []int64{1, 2, 3},
|
||||
|
|
Loading…
Reference in New Issue