Make progress if any channel/segment was loaded on node (#20775)

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

Signed-off-by: yah01 <yang.cen@zilliz.com>
This commit is contained in:
yah01 2022-12-06 18:29:19 +08:00 committed by GitHub
parent 11e4445ef7
commit 0297ab1a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 21 deletions

View File

@ -183,7 +183,7 @@ func (mgr *LeaderViewManager) GetGrowingSegmentDistByCollectionAndNode(collectio
return segments return segments
} }
// GetSegmentDist returns the list of nodes the given segment on // GetSegmentDist returns the list of nodes the given channel on
func (mgr *LeaderViewManager) GetChannelDist(channel string) []int64 { func (mgr *LeaderViewManager) GetChannelDist(channel string) []int64 {
mgr.rwmutex.RLock() mgr.rwmutex.RLock()
defer mgr.rwmutex.RUnlock() defer mgr.rwmutex.RUnlock()

View File

@ -166,7 +166,9 @@ func (ob *CollectionObserver) observeCollectionLoadStatus(collection *meta.Colle
log.Info("collection targets", log.Info("collection targets",
zap.Int("segmentTargetNum", len(segmentTargets)), zap.Int("segmentTargetNum", len(segmentTargets)),
zap.Int("channelTargetNum", len(channelTargets)), zap.Int("channelTargetNum", len(channelTargets)),
zap.Int("totalTargetNum", targetNum)) zap.Int("totalTargetNum", targetNum),
zap.Int32("replicaNum", collection.GetReplicaNumber()),
)
updated := collection.Clone() updated := collection.Clone()
loadedCount := 0 loadedCount := 0
@ -178,18 +180,14 @@ func (ob *CollectionObserver) observeCollectionLoadStatus(collection *meta.Colle
group := utils.GroupNodesByReplica(ob.meta.ReplicaManager, group := utils.GroupNodesByReplica(ob.meta.ReplicaManager,
collection.GetCollectionID(), collection.GetCollectionID(),
ob.dist.LeaderViewManager.GetChannelDist(channel.GetChannelName())) ob.dist.LeaderViewManager.GetChannelDist(channel.GetChannelName()))
if len(group) >= int(collection.GetReplicaNumber()) { loadedCount += len(group)
loadedCount++
}
} }
subChannelCount := loadedCount subChannelCount := loadedCount
for _, segment := range segmentTargets { for _, segment := range segmentTargets {
group := utils.GroupNodesByReplica(ob.meta.ReplicaManager, group := utils.GroupNodesByReplica(ob.meta.ReplicaManager,
collection.GetCollectionID(), collection.GetCollectionID(),
ob.dist.LeaderViewManager.GetSealedSegmentDist(segment.GetID())) ob.dist.LeaderViewManager.GetSealedSegmentDist(segment.GetID()))
if len(group) >= int(collection.GetReplicaNumber()) { loadedCount += len(group)
loadedCount++
}
} }
if loadedCount > 0 { if loadedCount > 0 {
log.Info("collection load progress", log.Info("collection load progress",
@ -198,7 +196,7 @@ func (ob *CollectionObserver) observeCollectionLoadStatus(collection *meta.Colle
) )
} }
updated.LoadPercentage = int32(loadedCount * 100 / targetNum) updated.LoadPercentage = int32(loadedCount * 100 / targetNum * int(collection.GetReplicaNumber()))
} }
if loadedCount <= ob.collectionLoadedCount[collection.GetCollectionID()] && updated.LoadPercentage != 100 { if loadedCount <= ob.collectionLoadedCount[collection.GetCollectionID()] && updated.LoadPercentage != 100 {
@ -230,9 +228,11 @@ func (ob *CollectionObserver) observePartitionLoadStatus(partition *meta.Partiti
channelTargets := ob.targetMgr.GetDmChannelsByCollection(partition.GetCollectionID(), meta.NextTarget) channelTargets := ob.targetMgr.GetDmChannelsByCollection(partition.GetCollectionID(), meta.NextTarget)
targetNum := len(segmentTargets) + len(channelTargets) targetNum := len(segmentTargets) + len(channelTargets)
log.Info("partition targets", log.Info("partition targets",
zap.Int("segment-target-num", len(segmentTargets)), zap.Int("segmentTargetNum", len(segmentTargets)),
zap.Int("channel-target-num", len(channelTargets)), zap.Int("channelTargetNum", len(channelTargets)),
zap.Int("total-target-num", targetNum)) zap.Int("totalTargetNum", targetNum),
zap.Int32("replicaNum", partition.GetReplicaNumber()),
)
loadedCount := 0 loadedCount := 0
updated := partition.Clone() updated := partition.Clone()
@ -244,25 +244,21 @@ func (ob *CollectionObserver) observePartitionLoadStatus(partition *meta.Partiti
group := utils.GroupNodesByReplica(ob.meta.ReplicaManager, group := utils.GroupNodesByReplica(ob.meta.ReplicaManager,
partition.GetCollectionID(), partition.GetCollectionID(),
ob.dist.LeaderViewManager.GetChannelDist(channel.GetChannelName())) ob.dist.LeaderViewManager.GetChannelDist(channel.GetChannelName()))
if len(group) >= int(partition.GetReplicaNumber()) { loadedCount += len(group)
loadedCount++
}
} }
subChannelCount := loadedCount subChannelCount := loadedCount
for _, segment := range segmentTargets { for _, segment := range segmentTargets {
group := utils.GroupNodesByReplica(ob.meta.ReplicaManager, group := utils.GroupNodesByReplica(ob.meta.ReplicaManager,
partition.GetCollectionID(), partition.GetCollectionID(),
ob.dist.LeaderViewManager.GetSealedSegmentDist(segment.GetID())) ob.dist.LeaderViewManager.GetSealedSegmentDist(segment.GetID()))
if len(group) >= int(partition.GetReplicaNumber()) { loadedCount += len(group)
loadedCount++
}
} }
if loadedCount > 0 { if loadedCount > 0 {
log.Info("partition load progress", log.Info("partition load progress",
zap.Int("subChannelCount", subChannelCount), zap.Int("subChannelCount", subChannelCount),
zap.Int("loadSegmentCount", loadedCount-subChannelCount)) zap.Int("loadSegmentCount", loadedCount-subChannelCount))
} }
updated.LoadPercentage = int32(loadedCount * 100 / targetNum) updated.LoadPercentage = int32(loadedCount * 100 / targetNum * int(partition.GetReplicaNumber()))
} }

View File

@ -199,6 +199,15 @@ func (suite *CollectionObserverSuite) TestObserve() {
time := suite.meta.GetCollection(suite.collections[2]).UpdatedAt time := suite.meta.GetCollection(suite.collections[2]).UpdatedAt
// Not timeout // Not timeout
Params.QueryCoordCfg.LoadTimeoutSeconds = timeout Params.QueryCoordCfg.LoadTimeoutSeconds = timeout
segments := []*datapb.SegmentBinlogs{}
for _, segment := range suite.segments[100] {
segments = append(segments, &datapb.SegmentBinlogs{
SegmentID: segment.GetID(),
InsertChannel: segment.GetInsertChannel(),
})
}
suite.ob.Start(context.Background()) suite.ob.Start(context.Background())
// Collection 100 loaded before timeout, // Collection 100 loaded before timeout,
@ -325,8 +334,12 @@ func (suite *CollectionObserverSuite) load(collection int64) {
}) })
} }
suite.broker.EXPECT().GetRecoveryInfo(mock.Anything, collection, int64(1)).Return(dmChannels, allSegments, nil)
suite.targetMgr.UpdateCollectionNextTargetWithPartitions(collection, int64(1)) partitions := suite.partitions[collection]
for _, partition := range partitions {
suite.broker.EXPECT().GetRecoveryInfo(mock.Anything, collection, partition).Return(dmChannels, allSegments, nil)
}
suite.targetMgr.UpdateCollectionNextTargetWithPartitions(collection, partitions...)
} }
func TestCollectionObserver(t *testing.T) { func TestCollectionObserver(t *testing.T) {