Fix GetIndexByName (#8780)

Signed-off-by: Yusup <yusup@lsgrep.com>
pull/8629/head
Yusup 2021-09-28 13:52:20 +00:00 committed by GitHub
parent 7f61c1e8ea
commit 4b53a7fc05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 4 deletions

View File

@ -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 {

View File

@ -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)
}