Skip to content

Commit

Permalink
fix: [2.4] Unify querynode metrics cleanup in collection release (#32805
Browse files Browse the repository at this point in the history
) (#32825)

Cherry-pick from master
pr: #32805 
Related to #32803

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia committed May 8, 2024
1 parent 49b760f commit 311d66c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 36 deletions.
2 changes: 0 additions & 2 deletions internal/querynodev2/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package pipeline
import (
"github.com/milvus-io/milvus/internal/querynodev2/delegator"
base "github.com/milvus-io/milvus/internal/util/pipeline"
"github.com/milvus-io/milvus/pkg/metrics"
"github.com/milvus-io/milvus/pkg/mq/msgdispatcher"
"github.com/milvus-io/milvus/pkg/util/paramtable"
)
Expand All @@ -37,7 +36,6 @@ type pipeline struct {

func (p *pipeline) Close() {
p.StreamPipeline.Close()
metrics.CleanupQueryNodeCollectionMetrics(paramtable.GetNodeID(), p.collectionID)
}

func NewPipeLine(
Expand Down
13 changes: 2 additions & 11 deletions internal/querynodev2/segments/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package segments
import "C"

import (
"fmt"
"sync"
"unsafe"

Expand Down Expand Up @@ -119,16 +118,8 @@ func (m *collectionManager) Unref(collectionID int64, count uint32) bool {
log.Info("release collection due to ref count to 0", zap.Int64("collectionID", collectionID))
delete(m.collections, collectionID)
DeleteCollection(collection)
metrics.QueryNodeEntitiesSize.DeleteLabelValues(
fmt.Sprint(paramtable.GetNodeID()),
fmt.Sprint(collectionID),
SegmentTypeSealed.String(),
)
metrics.QueryNodeEntitiesSize.DeleteLabelValues(
fmt.Sprint(paramtable.GetNodeID()),
fmt.Sprint(collectionID),
SegmentTypeGrowing.String(),
)

metrics.CleanupQueryNodeCollectionMetrics(paramtable.GetNodeID(), collectionID)
return true
}
return false
Expand Down
50 changes: 27 additions & 23 deletions pkg/metrics/querynode_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,27 +756,31 @@ func RegisterQueryNode(registry *prometheus.Registry) {
}

func CleanupQueryNodeCollectionMetrics(nodeID int64, collectionID int64) {
for _, label := range []string{DeleteLabel, InsertLabel} {
QueryNodeConsumerMsgCount.
Delete(
prometheus.Labels{
nodeIDLabelName: fmt.Sprint(nodeID),
msgTypeLabelName: label,
collectionIDLabelName: fmt.Sprint(collectionID),
})

QueryNodeConsumeTimeTickLag.
Delete(
prometheus.Labels{
nodeIDLabelName: fmt.Sprint(nodeID),
msgTypeLabelName: label,
collectionIDLabelName: fmt.Sprint(collectionID),
})
QueryNodeNumEntities.
DeletePartialMatch(
prometheus.Labels{
nodeIDLabelName: fmt.Sprint(nodeID),
collectionIDLabelName: fmt.Sprint(collectionID),
})
}
nodeIDLabel := fmt.Sprint(nodeID)
collectionIDLabel := fmt.Sprint(collectionID)
QueryNodeConsumerMsgCount.
DeletePartialMatch(
prometheus.Labels{
nodeIDLabelName: nodeIDLabel,
collectionIDLabelName: collectionIDLabel,
})

QueryNodeConsumeTimeTickLag.
DeletePartialMatch(
prometheus.Labels{
nodeIDLabelName: nodeIDLabel,
collectionIDLabelName: collectionIDLabel,
})
QueryNodeNumEntities.
DeletePartialMatch(
prometheus.Labels{
nodeIDLabelName: nodeIDLabel,
collectionIDLabelName: collectionIDLabel,
})
QueryNodeEntitiesSize.
DeletePartialMatch(
prometheus.Labels{
nodeIDLabelName: nodeIDLabel,
collectionIDLabelName: collectionIDLabel,
})
}

0 comments on commit 311d66c

Please sign in to comment.