Only balance segments in targets (#20635)

Signed-off-by: yah01 <yang.cen@zilliz.com>

Signed-off-by: yah01 <yang.cen@zilliz.com>
pull/20628/head
yah01 2022-11-16 14:33:11 +08:00 committed by GitHub
parent 35db3d2352
commit 31872f436c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -86,7 +86,11 @@ func (s *Server) balanceSegments(ctx context.Context, req *querypb.LoadBalanceRe
dstNodeSet.Remove(srcNode)
toBalance := typeutil.NewSet[*meta.Segment]()
// Only balance segments in targets
segments := s.dist.SegmentDistManager.GetByNode(srcNode)
segments = lo.Filter(segments, func(segment *meta.Segment, _ int) bool {
return s.targetMgr.GetHistoricalSegment(segment.GetCollectionID(), segment.GetID(), meta.CurrentTarget) != nil
})
allSegments := make(map[int64]*meta.Segment)
for _, segment := range segments {
allSegments[segment.GetID()] = segment