From 010d8362ad0e3918697734838ff32726d466d719 Mon Sep 17 00:00:00 2001 From: aoiasd <45024769+aoiasd@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:20:44 +0800 Subject: [PATCH] fix: datanode L0 segment num wrong (#29050) relate: https://github.com/milvus-io/milvus/issues/27675 Signed-off-by: aoiasd --- internal/datacoord/meta.go | 3 ++- internal/datacoord/services.go | 2 +- pkg/metrics/datacoord_metrics.go | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/datacoord/meta.go b/internal/datacoord/meta.go index 632a449d1b..7eb1e8ddff 100644 --- a/internal/datacoord/meta.go +++ b/internal/datacoord/meta.go @@ -116,7 +116,7 @@ func (m *meta) reloadFromKV() error { numStoredRows := int64(0) for _, segment := range segments { m.segments.SetSegment(segment.ID, NewSegmentInfo(segment)) - metrics.DataCoordNumSegments.WithLabelValues(segment.State.String(), segment.GetLevel().String()).Inc() + metrics.DataCoordNumSegments.WithLabelValues(segment.GetState().String(), segment.GetLevel().String()).Inc() if segment.State == commonpb.SegmentState_Flushed { numStoredRows += segment.NumOfRows @@ -481,6 +481,7 @@ func CreateL0Operator(collectionID, partitionID, segmentID int64, channel string Level: datapb.SegmentLevel_L0, }, } + modPack.metricMutation.addNewSeg(commonpb.SegmentState_Growing, datapb.SegmentLevel_L0, 0) } return true } diff --git a/internal/datacoord/services.go b/internal/datacoord/services.go index 5eb392a534..8ee6a3f6b6 100644 --- a/internal/datacoord/services.go +++ b/internal/datacoord/services.go @@ -503,7 +503,7 @@ func (s *Server) SaveBinlogPaths(ctx context.Context, req *datapb.SaveBinlogPath if req.GetFlushed() { if req.GetSegLevel() == datapb.SegmentLevel_L0 { - metrics.DataCoordSizeStoredL0Segment.WithLabelValues().Observe(calculateL0SegmentSize(req.GetField2StatslogPaths())) + metrics.DataCoordSizeStoredL0Segment.WithLabelValues(fmt.Sprint(req.GetCollectionID())).Observe(calculateL0SegmentSize(req.GetField2StatslogPaths())) metrics.DataCoordRateStoredL0Segment.WithLabelValues().Inc() } else { // because segmentMananger only manage growing segment diff --git a/pkg/metrics/datacoord_metrics.go b/pkg/metrics/datacoord_metrics.go index 033992ca6e..45ab48e3ba 100644 --- a/pkg/metrics/datacoord_metrics.go +++ b/pkg/metrics/datacoord_metrics.go @@ -75,15 +75,18 @@ var ( prometheus.HistogramOpts{ Namespace: milvusNamespace, Subsystem: typeutil.DataCoordRole, - Name: "store_l0_segment_size", + Name: "store_level0_segment_size", Help: "stored l0 segment size", - }, []string{}) + Buckets: buckets, + }, []string{ + collectionIDLabelName, + }) DataCoordRateStoredL0Segment = prometheus.NewCounterVec( prometheus.CounterOpts{ Namespace: milvusNamespace, Subsystem: typeutil.DataCoordRole, - Name: "store_l0_segment_rate", + Name: "store_level0_segment_rate", Help: "stored l0 segment rate", }, []string{})