From e73bdbe17dff247c52e4582b2bfd1acec778135a Mon Sep 17 00:00:00 2001 From: bigsheeper Date: Mon, 14 Nov 2022 21:03:09 +0800 Subject: [PATCH] Disk quota only checks healthy segments (#20574) Signed-off-by: bigsheeper Signed-off-by: bigsheeper --- internal/datacoord/meta.go | 16 +++++++++++----- internal/metrics/datacoord_metrics.go | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/datacoord/meta.go b/internal/datacoord/meta.go index aa46b9b164..ef379a1280 100644 --- a/internal/datacoord/meta.go +++ b/internal/datacoord/meta.go @@ -209,17 +209,23 @@ func (m *meta) GetNumRowsOfCollection(collectionID UniqueID) int64 { return ret } -// GetTotalBinlogSize returns the total size (bytes) of all segments in cluster. +// GetTotalBinlogSize returns the total size (bytes) of healthy segments in cluster. func (m *meta) GetTotalBinlogSize() int64 { m.RLock() defer m.RUnlock() - var ret int64 + var totalHealthySize int64 segments := m.segments.GetSegments() + sizes := make(map[commonpb.SegmentState]int64) for _, segment := range segments { - ret += segment.getSegmentSize() + if isSegmentHealthy(segment) { + totalHealthySize += segment.getSegmentSize() + } + sizes[segment.GetState()] += segment.getSegmentSize() } - metrics.DataCoordStoredBinlogSize.WithLabelValues().Set(float64(ret)) - return ret + for state, size := range sizes { + metrics.DataCoordStoredBinlogSize.WithLabelValues(state.String()).Set(float64(size)) + } + return totalHealthySize } // AddSegment records segment info, persisting info into kv store diff --git a/internal/metrics/datacoord_metrics.go b/internal/metrics/datacoord_metrics.go index c30508b36c..ee80670ad6 100644 --- a/internal/metrics/datacoord_metrics.go +++ b/internal/metrics/datacoord_metrics.go @@ -92,8 +92,8 @@ var ( Namespace: milvusNamespace, Subsystem: typeutil.DataCoordRole, Name: "stored_binlog_size", - Help: "binlog size of all collections/segments", - }, []string{}) + Help: "binlog size of segments", + }, []string{segmentStateLabelName}) /* hard to implement, commented now DataCoordSegmentSizeRatio = prometheus.NewHistogramVec(