From 8858fcb40af256a794bb4cc7efef303d933ee6f3 Mon Sep 17 00:00:00 2001 From: jaime Date: Tue, 4 Jun 2024 20:09:54 +0800 Subject: [PATCH] fix: fix loaded entity num is inaccurate (#33521) issue: #33520 Signed-off-by: jaime --- internal/querynodev2/metrics_info.go | 8 ++++---- pkg/metrics/querynode_metrics.go | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/querynodev2/metrics_info.go b/internal/querynodev2/metrics_info.go index c41d12ed7ef6d..b4c50a5d1b9fb 100644 --- a/internal/querynodev2/metrics_info.go +++ b/internal/querynodev2/metrics_info.go @@ -103,11 +103,12 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error } minTsafeChannel, minTsafe := node.tSafeManager.Min() - collections := node.manager.Collection.List() - nodeID := fmt.Sprint(node.GetNodeID()) + metrics.QueryNodeNumEntities.Reset() + metrics.QueryNodeEntitiesSize.Reset() + var totalGrowingSize int64 growingSegments := node.manager.Segment.GetBy(segments.WithType(segments.SegmentTypeGrowing)) growingGroupByCollection := lo.GroupBy(growingSegments, func(seg segments.Segment) int64 { @@ -125,6 +126,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error growingGroupByPartition := lo.GroupBy(growingSegments, func(seg segments.Segment) int64 { return seg.Partition() }) + for _, segs := range growingGroupByPartition { numEntities := lo.SumBy(segs, func(seg segments.Segment) int64 { return seg.RowNum() @@ -136,7 +138,6 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error fmt.Sprint(segment.Collection()), fmt.Sprint(segment.Partition()), segments.SegmentTypeGrowing.String(), - fmt.Sprint(len(segment.Indexes())), ).Set(float64(numEntities)) } @@ -166,7 +167,6 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error fmt.Sprint(segment.Collection()), fmt.Sprint(segment.Partition()), segments.SegmentTypeSealed.String(), - fmt.Sprint(len(segment.Indexes())), ).Set(float64(numEntities)) } diff --git a/pkg/metrics/querynode_metrics.go b/pkg/metrics/querynode_metrics.go index d64c3cbb29869..2aa8e13c8a0da 100644 --- a/pkg/metrics/querynode_metrics.go +++ b/pkg/metrics/querynode_metrics.go @@ -370,7 +370,6 @@ var ( collectionIDLabelName, partitionIDLabelName, segmentStateLabelName, - indexCountLabelName, }) QueryNodeEntitiesSize = prometheus.NewGaugeVec(