未验证 提交 3d3289ce 编写于 作者: X Xiaofan 提交者: GitHub

Fix collection metrics leakage (#19944)

Signed-off-by: Nxiaofan-luan <xiaofan.luan@zilliz.com>
Signed-off-by: Nxiaofan-luan <xiaofan.luan@zilliz.com>
上级 f1f30500
......@@ -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),
......
......@@ -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) {
......
......@@ -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
......
......@@ -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{})
......
......@@ -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(),
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册