enhance: Skip update index for L0 segment (#34099) (#34280)

pr: #34280
try to update index for l0 segment, will failed by `index not found`

This PR skip update index for l0 segment

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
wei liu 2024-07-01 16:32:07 +08:00 committed by GitHub
parent 3af0d91f80
commit 92b7eebb53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 39 additions and 17 deletions

View File

@ -43,12 +43,12 @@ type BalanceChecker struct {
nodeManager *session.NodeManager
normalBalanceCollectionsCurrentRound typeutil.UniqueSet
scheduler task.Scheduler
targetMgr *meta.TargetManager
targetMgr meta.TargetManagerInterface
getBalancerFunc GetBalancerFunc
}
func NewBalanceChecker(meta *meta.Meta,
targetMgr *meta.TargetManager,
targetMgr meta.TargetManagerInterface,
nodeMgr *session.NodeManager,
scheduler task.Scheduler,
getBalancerFunc GetBalancerFunc,

View File

@ -38,7 +38,7 @@ type ChannelChecker struct {
*checkerActivation
meta *meta.Meta
dist *meta.DistributionManager
targetMgr *meta.TargetManager
targetMgr meta.TargetManagerInterface
nodeMgr *session.NodeManager
getBalancerFunc GetBalancerFunc
}
@ -46,7 +46,7 @@ type ChannelChecker struct {
func NewChannelChecker(
meta *meta.Meta,
dist *meta.DistributionManager,
targetMgr *meta.TargetManager,
targetMgr meta.TargetManagerInterface,
nodeMgr *session.NodeManager,
getBalancerFunc GetBalancerFunc,
) *ChannelChecker {

View File

@ -42,7 +42,7 @@ type CheckerController struct {
manualCheckChs map[utils.CheckerType]chan struct{}
meta *meta.Meta
dist *meta.DistributionManager
targetMgr *meta.TargetManager
targetMgr meta.TargetManagerInterface
broker meta.Broker
nodeMgr *session.NodeManager
balancer balance.Balance
@ -56,7 +56,7 @@ type CheckerController struct {
func NewCheckerController(
meta *meta.Meta,
dist *meta.DistributionManager,
targetMgr *meta.TargetManager,
targetMgr meta.TargetManagerInterface,
nodeMgr *session.NodeManager,
scheduler task.Scheduler,
broker meta.Broker,
@ -68,7 +68,7 @@ func NewCheckerController(
utils.ChannelChecker: NewChannelChecker(meta, dist, targetMgr, nodeMgr, getBalancerFunc),
utils.SegmentChecker: NewSegmentChecker(meta, dist, targetMgr, nodeMgr, getBalancerFunc),
utils.BalanceChecker: NewBalanceChecker(meta, targetMgr, nodeMgr, scheduler, getBalancerFunc),
utils.IndexChecker: NewIndexChecker(meta, dist, broker, nodeMgr),
utils.IndexChecker: NewIndexChecker(meta, dist, broker, nodeMgr, targetMgr),
utils.LeaderChecker: NewLeaderChecker(meta, dist, targetMgr, nodeMgr),
}

View File

@ -23,6 +23,7 @@ import (
"github.com/samber/lo"
"go.uber.org/zap"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/proto/indexpb"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/querycoordv2/meta"
@ -43,6 +44,8 @@ type IndexChecker struct {
dist *meta.DistributionManager
broker meta.Broker
nodeMgr *session.NodeManager
targetMgr meta.TargetManagerInterface
}
func NewIndexChecker(
@ -50,6 +53,7 @@ func NewIndexChecker(
dist *meta.DistributionManager,
broker meta.Broker,
nodeMgr *session.NodeManager,
targetMgr meta.TargetManagerInterface,
) *IndexChecker {
return &IndexChecker{
checkerActivation: newCheckerActivation(),
@ -57,6 +61,7 @@ func NewIndexChecker(
dist: dist,
broker: broker,
nodeMgr: nodeMgr,
targetMgr: targetMgr,
}
}
@ -112,6 +117,13 @@ func (c *IndexChecker) checkReplica(ctx context.Context, collection *meta.Collec
if roNodeSet.Contain(segment.Node) {
continue
}
// skip update index for l0 segment
segmentInTarget := c.targetMgr.GetSealedSegment(collection.GetCollectionID(), segment.GetID(), meta.CurrentTargetFirst)
if segmentInTarget == nil || segmentInTarget.GetLevel() == datapb.SegmentLevel_L0 {
continue
}
missing := c.checkSegment(segment, indexInfos)
if len(missing) > 0 {
targets[segment.GetID()] = missing

View File

@ -26,6 +26,7 @@ import (
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
"github.com/milvus-io/milvus/internal/metastore/kv/querycoord"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/proto/indexpb"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/querycoordv2/meta"
@ -40,11 +41,12 @@ import (
type IndexCheckerSuite struct {
suite.Suite
kv kv.MetaKv
checker *IndexChecker
meta *meta.Meta
broker *meta.MockBroker
nodeMgr *session.NodeManager
kv kv.MetaKv
checker *IndexChecker
meta *meta.Meta
broker *meta.MockBroker
nodeMgr *session.NodeManager
targetMgr *meta.MockTargetManager
}
func (suite *IndexCheckerSuite) SetupSuite() {
@ -73,7 +75,15 @@ func (suite *IndexCheckerSuite) SetupTest() {
distManager := meta.NewDistributionManager()
suite.broker = meta.NewMockBroker(suite.T())
suite.checker = NewIndexChecker(suite.meta, distManager, suite.broker, suite.nodeMgr)
suite.targetMgr = meta.NewMockTargetManager(suite.T())
suite.checker = NewIndexChecker(suite.meta, distManager, suite.broker, suite.nodeMgr, suite.targetMgr)
suite.targetMgr.EXPECT().GetSealedSegment(mock.Anything, mock.Anything, mock.Anything).RunAndReturn(func(cid, sid int64, i3 int32) *datapb.SegmentInfo {
return &datapb.SegmentInfo{
ID: sid,
Level: datapb.SegmentLevel_L1,
}
}).Maybe()
}
func (suite *IndexCheckerSuite) TearDownTest() {

View File

@ -39,14 +39,14 @@ type LeaderChecker struct {
*checkerActivation
meta *meta.Meta
dist *meta.DistributionManager
target *meta.TargetManager
target meta.TargetManagerInterface
nodeMgr *session.NodeManager
}
func NewLeaderChecker(
meta *meta.Meta,
dist *meta.DistributionManager,
target *meta.TargetManager,
target meta.TargetManagerInterface,
nodeMgr *session.NodeManager,
) *LeaderChecker {
return &LeaderChecker{

View File

@ -43,7 +43,7 @@ type SegmentChecker struct {
*checkerActivation
meta *meta.Meta
dist *meta.DistributionManager
targetMgr *meta.TargetManager
targetMgr meta.TargetManagerInterface
nodeMgr *session.NodeManager
getBalancerFunc GetBalancerFunc
}
@ -51,7 +51,7 @@ type SegmentChecker struct {
func NewSegmentChecker(
meta *meta.Meta,
dist *meta.DistributionManager,
targetMgr *meta.TargetManager,
targetMgr meta.TargetManagerInterface,
nodeMgr *session.NodeManager,
getBalancerFunc GetBalancerFunc,
) *SegmentChecker {