Disk quota only checks healthy segments (#20574)

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
bigsheeper 2022-11-14 21:03:09 +08:00 committed by GitHub
parent 69481471ec
commit e73bdbe17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -209,17 +209,23 @@ func (m *meta) GetNumRowsOfCollection(collectionID UniqueID) int64 {
return ret 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 { func (m *meta) GetTotalBinlogSize() int64 {
m.RLock() m.RLock()
defer m.RUnlock() defer m.RUnlock()
var ret int64 var totalHealthySize int64
segments := m.segments.GetSegments() segments := m.segments.GetSegments()
sizes := make(map[commonpb.SegmentState]int64)
for _, segment := range segments { for _, segment := range segments {
ret += segment.getSegmentSize() if isSegmentHealthy(segment) {
totalHealthySize += segment.getSegmentSize()
}
sizes[segment.GetState()] += segment.getSegmentSize()
} }
metrics.DataCoordStoredBinlogSize.WithLabelValues().Set(float64(ret)) for state, size := range sizes {
return ret metrics.DataCoordStoredBinlogSize.WithLabelValues(state.String()).Set(float64(size))
}
return totalHealthySize
} }
// AddSegment records segment info, persisting info into kv store // AddSegment records segment info, persisting info into kv store

View File

@ -92,8 +92,8 @@ var (
Namespace: milvusNamespace, Namespace: milvusNamespace,
Subsystem: typeutil.DataCoordRole, Subsystem: typeutil.DataCoordRole,
Name: "stored_binlog_size", Name: "stored_binlog_size",
Help: "binlog size of all collections/segments", Help: "binlog size of segments",
}, []string{}) }, []string{segmentStateLabelName})
/* hard to implement, commented now /* hard to implement, commented now
DataCoordSegmentSizeRatio = prometheus.NewHistogramVec( DataCoordSegmentSizeRatio = prometheus.NewHistogramVec(