From c3d53eb1bf9a54390d14917904e36005fa20dcf2 Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 20 Mar 2024 10:09:08 +0800 Subject: [PATCH] enhance: Remove metrics when target removed (#31399) See also #31390 --------- Signed-off-by: Congqi Xia --- internal/querycoordv2/meta/target_manager.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/querycoordv2/meta/target_manager.go b/internal/querycoordv2/meta/target_manager.go index fcf55ff88f..a957943552 100644 --- a/internal/querycoordv2/meta/target_manager.go +++ b/internal/querycoordv2/meta/target_manager.go @@ -278,6 +278,16 @@ func (mgr *TargetManager) RemoveCollection(collectionID int64) { log.Info("remove collection from targets", zap.Int64("collectionID", collectionID)) + current := mgr.current.getCollectionTarget(collectionID) + if current != nil { + for channelName := range current.GetAllDmChannels() { + metrics.QueryCoordCurrentTargetCheckpointUnixSeconds.DeleteLabelValues( + fmt.Sprint(paramtable.GetNodeID()), + channelName, + ) + } + } + mgr.current.removeCollectionTarget(collectionID) mgr.next.removeCollectionTarget(collectionID) }