fix: metrics stored_index_files_size is never cleared (#36160)

issue: #36159

Signed-off-by: jaime <yun.zhang@zilliz.com>
This commit is contained in:
jaime 2024-09-13 20:09:15 +08:00 committed by GitHub
parent 58d3200986
commit 22cce44afc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -466,11 +466,13 @@ func (m *meta) GetQuotaInfo() *metricsinfo.DataCoordQuotaMetrics {
return info
}
// GetCollectionIndexFilesSize returns the total index files size of all segment for each collection.
func (m *meta) GetCollectionIndexFilesSize() uint64 {
// SetStoredIndexFileSizeMetric returns the total index files size of all segment for each collection.
func (m *meta) SetStoredIndexFileSizeMetric() uint64 {
m.RLock()
defer m.RUnlock()
var total uint64
metrics.DataCoordStoredIndexFilesSize.Reset()
for _, segmentIdx := range m.indexMeta.GetAllSegIndexes() {
coll, ok := m.collections[segmentIdx.CollectionID]
if ok {

View File

@ -604,7 +604,7 @@ func TestMeta_Basic(t *testing.T) {
t.Run("Test GetCollectionBinlogSize", func(t *testing.T) {
meta := createMeta(&datacoord.Catalog{}, withIndexMeta(createIndexMeta(&datacoord.Catalog{})))
ret := meta.GetCollectionIndexFilesSize()
ret := meta.SetStoredIndexFileSizeMetric()
assert.Equal(t, uint64(0), ret)
meta.collections = map[UniqueID]*collectionInfo{
@ -613,7 +613,7 @@ func TestMeta_Basic(t *testing.T) {
DatabaseName: "db",
},
}
ret = meta.GetCollectionIndexFilesSize()
ret = meta.SetStoredIndexFileSizeMetric()
assert.Equal(t, uint64(11), ret)
})

View File

@ -40,7 +40,7 @@ import (
func (s *Server) getQuotaMetrics() *metricsinfo.DataCoordQuotaMetrics {
info := s.meta.GetQuotaInfo()
// Just generate the metrics data regularly
_ = s.meta.GetCollectionIndexFilesSize()
_ = s.meta.SetStoredIndexFileSizeMetric()
return info
}