diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 5c7ec5459f..2f7570d2de 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -110,12 +110,14 @@ func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *p collectionName := request.CollectionName collectionID := request.CollectionID + + var aliasName []string if globalMetaCache != nil { if collectionName != "" { globalMetaCache.RemoveCollection(ctx, collectionName) // no need to return error, though collection may be not cached } if request.CollectionID != UniqueID(0) { - globalMetaCache.RemoveCollectionsByID(ctx, collectionID) + aliasName = globalMetaCache.RemoveCollectionsByID(ctx, collectionID) } } if request.GetBase().GetMsgType() == commonpb.MsgType_DropCollection { @@ -123,6 +125,9 @@ func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *p node.chMgr.removeDMLStream(request.GetCollectionID()) // clean up collection level metrics metrics.CleanupCollectionMetrics(Params.ProxyCfg.GetNodeID(), collectionName) + for _, alias := range aliasName { + metrics.CleanupCollectionMetrics(Params.ProxyCfg.GetNodeID(), alias) + } } logutil.Logger(ctx).Info("complete to invalidate collection meta cache", zap.String("role", typeutil.ProxyRole), diff --git a/internal/proxy/meta_cache.go b/internal/proxy/meta_cache.go index 456254c2e0..a7e6cfc7f4 100644 --- a/internal/proxy/meta_cache.go +++ b/internal/proxy/meta_cache.go @@ -63,7 +63,7 @@ type Cache interface { GetShards(ctx context.Context, withCache bool, collectionName string) (map[string][]nodeInfo, error) ClearShards(collectionName string) RemoveCollection(ctx context.Context, collectionName string) - RemoveCollectionsByID(ctx context.Context, collectionID UniqueID) + RemoveCollectionsByID(ctx context.Context, collectionID UniqueID) []string RemovePartition(ctx context.Context, collectionName string, partitionName string) // GetCredentialInfo operate credential cache @@ -515,14 +515,17 @@ func (m *MetaCache) RemoveCollection(ctx context.Context, collectionName string) delete(m.collInfo, collectionName) } -func (m *MetaCache) RemoveCollectionsByID(ctx context.Context, collectionID UniqueID) { +func (m *MetaCache) RemoveCollectionsByID(ctx context.Context, collectionID UniqueID) []string { m.mu.Lock() defer m.mu.Unlock() + var collNames []string for k, v := range m.collInfo { if v.collID == collectionID { delete(m.collInfo, k) + collNames = append(collNames, k) } } + return collNames } func (m *MetaCache) RemovePartition(ctx context.Context, collectionName, partitionName string) { diff --git a/internal/rootcoord/alter_collection_task.go b/internal/rootcoord/alter_collection_task.go index 959ce5e7a4..85b0b46cc8 100644 --- a/internal/rootcoord/alter_collection_task.go +++ b/internal/rootcoord/alter_collection_task.go @@ -50,9 +50,10 @@ func (a *alterCollectionTask) Execute(ctx context.Context) error { }) redoTask.AddSyncStep(&expireCacheStep{ - baseStep: baseStep{core: a.core}, - collectionID: oldColl.CollectionID, - ts: ts, + baseStep: baseStep{core: a.core}, + collectionNames: []string{oldColl.Name}, + collectionID: oldColl.CollectionID, + ts: ts, }) a.Req.CollectionID = oldColl.CollectionID diff --git a/internal/rootcoord/create_partition_task.go b/internal/rootcoord/create_partition_task.go index 1a8bad30ad..5c608398fd 100644 --- a/internal/rootcoord/create_partition_task.go +++ b/internal/rootcoord/create_partition_task.go @@ -56,7 +56,7 @@ func (t *createPartitionTask) Execute(ctx context.Context) error { undoTask := newBaseUndoTask(t.core.stepExecutor) undoTask.AddStep(&expireCacheStep{ baseStep: baseStep{core: t.core}, - collectionNames: []string{t.Req.GetCollectionName()}, + collectionNames: []string{t.collMeta.Name}, collectionID: t.collMeta.CollectionID, ts: t.GetTs(), }, &nullStep{}) diff --git a/internal/rootcoord/drop_partition_task.go b/internal/rootcoord/drop_partition_task.go index 760d3f5feb..7020023657 100644 --- a/internal/rootcoord/drop_partition_task.go +++ b/internal/rootcoord/drop_partition_task.go @@ -63,7 +63,7 @@ func (t *dropPartitionTask) Execute(ctx context.Context) error { }) redoTask.AddSyncStep(&expireCacheStep{ baseStep: baseStep{core: t.core}, - collectionNames: []string{t.Req.GetCollectionName()}, + collectionNames: []string{t.collMeta.Name}, collectionID: t.collMeta.CollectionID, ts: t.GetTs(), })