Skip to content

Commit

Permalink
enhance: [2.4] Provide secondary index criteria when filter leaderview (
Browse files Browse the repository at this point in the history
#37777) (#37802)

Cherry-pick from master
pr: #37777 
Related to #37630

---------

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Nov 21, 2024
1 parent 28adfe4 commit 0bd2617
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion internal/querycoordv2/observers/collection_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ func (ob *CollectionObserver) observePartitionLoadStatus(ctx context.Context, pa
}
subChannelCount := loadedCount
for _, segment := range segmentTargets {
views := ob.dist.LeaderViewManager.GetByFilter(meta.WithSegment2LeaderView(segment.GetID(), false))
views := ob.dist.LeaderViewManager.GetByFilter(
meta.WithChannelName2LeaderView(segment.GetInsertChannel()),
meta.WithSegment2LeaderView(segment.GetID(), false))
nodes := lo.Map(views, func(view *meta.LeaderView, _ int) int64 { return view.ID })
group := utils.GroupNodesByReplica(ob.meta.ReplicaManager, partition.GetCollectionID(), nodes)
loadedCount += len(group)
Expand Down
4 changes: 3 additions & 1 deletion internal/querycoordv2/task/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func (action *SegmentAction) IsFinished(distMgr *meta.DistributionManager) bool
}

// segment found in leader view
views := distMgr.LeaderViewManager.GetByFilter(meta.WithSegment2LeaderView(action.segmentID, false))
views := distMgr.LeaderViewManager.GetByFilter(
meta.WithChannelName2LeaderView(action.Shard()),
meta.WithSegment2LeaderView(action.segmentID, false))
if len(views) == 0 {
return false
}
Expand Down
4 changes: 3 additions & 1 deletion internal/querycoordv2/task/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ func (scheduler *taskScheduler) preAdd(task Task) error {
taskType := GetTaskType(task)

if taskType == TaskTypeMove {
views := scheduler.distMgr.LeaderViewManager.GetByFilter(meta.WithSegment2LeaderView(task.SegmentID(), false))
views := scheduler.distMgr.LeaderViewManager.GetByFilter(
meta.WithChannelName2LeaderView(task.Shard()),
meta.WithSegment2LeaderView(task.SegmentID(), false))
if len(views) == 0 {
return merr.WrapErrServiceInternal("segment's delegator not found, stop balancing")
}
Expand Down
3 changes: 3 additions & 0 deletions internal/querycoordv2/task/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ func (suite *TaskSuite) TestLoadSegmentTask() {
ID: targetNode,
CollectionID: suite.collection,
Segments: map[int64]*querypb.SegmentDist{},
Channel: channel.ChannelName,
}
for _, segment := range suite.loadSegments {
view.Segments[segment] = &querypb.SegmentDist{NodeID: targetNode, Version: 0}
Expand Down Expand Up @@ -575,6 +576,7 @@ func (suite *TaskSuite) TestLoadSegmentTaskNotIndex() {
ID: targetNode,
CollectionID: suite.collection,
Segments: map[int64]*querypb.SegmentDist{},
Channel: channel.ChannelName,
}
for _, segment := range suite.loadSegments {
view.Segments[segment] = &querypb.SegmentDist{NodeID: targetNode, Version: 0}
Expand Down Expand Up @@ -1139,6 +1141,7 @@ func (suite *TaskSuite) TestSegmentTaskStale() {
ID: targetNode,
CollectionID: suite.collection,
Segments: map[int64]*querypb.SegmentDist{},
Channel: channel.ChannelName,
}
for _, segment := range suite.loadSegments[1:] {
view.Segments[segment] = &querypb.SegmentDist{NodeID: targetNode, Version: 0}
Expand Down

0 comments on commit 0bd2617

Please sign in to comment.