diff --git a/internal/querycoordv2/job/job_release.go b/internal/querycoordv2/job/job_release.go index b5f7de892452a..8dcf4466f6785 100644 --- a/internal/querycoordv2/job/job_release.go +++ b/internal/querycoordv2/job/job_release.go @@ -112,8 +112,6 @@ func (job *ReleaseCollectionJob) Execute() error { proxyutil.SetMsgType(commonpb.MsgType_ReleaseCollection)) waitCollectionReleased(job.dist, job.checkerController, req.GetCollectionID()) - metrics.QueryCoordNumCollections.WithLabelValues().Dec() - metrics.QueryCoordNumPartitions.WithLabelValues().Sub(float64(len(toRelease))) metrics.QueryCoordReleaseCount.WithLabelValues(metrics.TotalLabel).Inc() metrics.QueryCoordReleaseCount.WithLabelValues(metrics.SuccessLabel).Inc() return nil @@ -196,7 +194,6 @@ func (job *ReleasePartitionJob) Execute() error { log.Warn("failed to remove replicas", zap.Error(err)) } job.targetObserver.ReleaseCollection(req.GetCollectionID()) - metrics.QueryCoordNumCollections.WithLabelValues().Dec() // try best discard cache // shall not affect releasing if failed job.proxyManager.InvalidateCollectionMetaCache(job.ctx, @@ -216,6 +213,5 @@ func (job *ReleasePartitionJob) Execute() error { job.targetObserver.ReleasePartition(req.GetCollectionID(), toRelease...) waitCollectionReleased(job.dist, job.checkerController, req.GetCollectionID(), toRelease...) } - metrics.QueryCoordNumPartitions.WithLabelValues().Sub(float64(len(toRelease))) return nil } diff --git a/internal/querycoordv2/meta/collection_manager.go b/internal/querycoordv2/meta/collection_manager.go index 124feb3e871da..7fa23b1cea264 100644 --- a/internal/querycoordv2/meta/collection_manager.go +++ b/internal/querycoordv2/meta/collection_manager.go @@ -591,6 +591,7 @@ func (m *CollectionManager) UpdateLoadPercent(ctx context.Context, partitionID i newCollection.RecoverTimes = 0 metrics.QueryCoordNumCollections.WithLabelValues().Set(float64(len(lo.Values(m.collections)))) + metrics.QueryCoordNumPartitions.WithLabelValues().Set(float64(len(m.partitions))) elapsed := time.Since(newCollection.CreatedAt) metrics.QueryCoordLoadLatency.WithLabelValues().Observe(float64(elapsed.Milliseconds())) eventlog.Record(eventlog.NewRawEvt(eventlog.Level_Info, fmt.Sprintf("Collection %d loaded", newCollection.CollectionID))) @@ -616,6 +617,8 @@ func (m *CollectionManager) RemoveCollection(ctx context.Context, collectionID t delete(m.collectionPartitions, collectionID) } metrics.CleanQueryCoordMetricsWithCollectionID(collectionID) + metrics.QueryCoordNumPartitions.WithLabelValues().Set(float64(len(m.partitions))) + metrics.QueryCoordNumCollections.WithLabelValues().Set(float64(len(lo.Values(m.collections)))) return nil } @@ -627,7 +630,9 @@ func (m *CollectionManager) RemovePartition(ctx context.Context, collectionID ty m.rwmutex.Lock() defer m.rwmutex.Unlock() - return m.removePartition(ctx, collectionID, partitionIDs...) + err := m.removePartition(ctx, collectionID, partitionIDs...) + metrics.QueryCoordNumPartitions.WithLabelValues().Set(float64(len(m.partitions))) + return err } func (m *CollectionManager) removePartition(ctx context.Context, collectionID typeutil.UniqueID, partitionIDs ...typeutil.UniqueID) error {