From 4b53a7fc05f23cfcedb3efac86a9bb31a24630ac Mon Sep 17 00:00:00 2001 From: Yusup Date: Tue, 28 Sep 2021 13:52:20 +0000 Subject: [PATCH] Fix GetIndexByName (#8780) Signed-off-by: Yusup --- internal/rootcoord/meta_table.go | 20 ++++++++++++++++---- internal/rootcoord/task.go | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/internal/rootcoord/meta_table.go b/internal/rootcoord/meta_table.go index 8de656dad4..00d23037c3 100644 --- a/internal/rootcoord/meta_table.go +++ b/internal/rootcoord/meta_table.go @@ -811,7 +811,10 @@ func (mt *MetaTable) DropIndex(collName, fieldName, indexName string, ts typeuti collID, ok := mt.collName2ID[collName] if !ok { - return 0, false, fmt.Errorf("collection name = %s not exist", collName) + collID, ok = mt.collAlias2ID[collName] + if !ok { + return 0, false, fmt.Errorf("collection name = %s not exist", collName) + } } collMeta, ok := mt.collID2Meta[collID] if !ok { @@ -933,7 +936,10 @@ func (mt *MetaTable) GetFieldSchema(collName string, fieldName string) (schemapb func (mt *MetaTable) unlockGetFieldSchema(collName string, fieldName string) (schemapb.FieldSchema, error) { collID, ok := mt.collName2ID[collName] if !ok { - return schemapb.FieldSchema{}, fmt.Errorf("collection %s not found", collName) + collID, ok = mt.collAlias2ID[collName] + if !ok { + return schemapb.FieldSchema{}, fmt.Errorf("collection %s not found", collName) + } } collMeta, ok := mt.collID2Meta[collID] if !ok { @@ -987,7 +993,10 @@ func (mt *MetaTable) GetNotIndexedSegments(collName string, fieldName string, id } collID, ok := mt.collName2ID[collName] if !ok { - return nil, schemapb.FieldSchema{}, fmt.Errorf("collection %s not found", collName) + collID, ok = mt.collAlias2ID[collName] + if !ok { + return nil, schemapb.FieldSchema{}, fmt.Errorf("collection %s not found", collName) + } } collMeta, ok := mt.collID2Meta[collID] if !ok { @@ -1091,7 +1100,10 @@ func (mt *MetaTable) GetIndexByName(collName, indexName string) (pb.CollectionIn collID, ok := mt.collName2ID[collName] if !ok { - return pb.CollectionInfo{}, nil, fmt.Errorf("collection %s not found", collName) + collID, ok = mt.collAlias2ID[collName] + if !ok { + return pb.CollectionInfo{}, nil, fmt.Errorf("collection %s not found", collName) + } } collMeta, ok := mt.collID2Meta[collID] if !ok { diff --git a/internal/rootcoord/task.go b/internal/rootcoord/task.go index 5309a97bde..7393ad8412 100644 --- a/internal/rootcoord/task.go +++ b/internal/rootcoord/task.go @@ -274,6 +274,8 @@ func (t *DropCollectionReqTask) Execute(ctx context.Context) error { return fmt.Errorf("TSO alloc fail, error = %w", err) } + aliases := t.core.MetaTable.ListAliases(collMeta.ID) + // use lambda function here to guarantee all resources to be released dropCollectionFn := func() error { // lock for ddl operation @@ -329,6 +331,20 @@ func (t *DropCollectionReqTask) Execute(ctx context.Context) error { // error doesn't matter here t.core.proxyClientManager.InvalidateCollectionMetaCache(ctx, &req) + for _, alias := range aliases { + req = proxypb.InvalidateCollMetaCacheRequest{ + Base: &commonpb.MsgBase{ + MsgType: 0, //TODO, msg type + MsgID: 0, //TODO, msg id + Timestamp: ts, + SourceID: t.core.session.ServerID, + }, + DbName: t.Req.DbName, + CollectionName: alias, + } + t.core.proxyClientManager.InvalidateCollectionMetaCache(ctx, &req) + } + // Update DDOperation in etcd return t.core.setDdMsgSendFlag(true) }