mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Check if loaded in Proxy when LoadCollection (#18074)
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
parent
555ebb8ea5
commit
696d747afa
@ -1172,6 +1172,18 @@ func TestProxy(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
||||
|
||||
// load the same collection, test loaded check
|
||||
colInfo, err := globalMetaCache.GetCollectionInfo(ctx, collectionName)
|
||||
assert.NoError(t, err)
|
||||
colInfo.isLoaded = true
|
||||
resp, err = proxy.LoadCollection(ctx, &milvuspb.LoadCollectionRequest{
|
||||
Base: nil,
|
||||
DbName: dbName,
|
||||
CollectionName: collectionName,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
||||
|
||||
// load other collection -> fail
|
||||
resp, err = proxy.LoadCollection(ctx, &milvuspb.LoadCollectionRequest{
|
||||
Base: nil,
|
||||
|
||||
@ -2590,12 +2590,29 @@ func (lct *loadCollectionTask) Execute(ctx context.Context) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check if loaded
|
||||
info, err := globalMetaCache.GetCollectionInfo(ctx, lct.CollectionName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetCollectionInfo failed, collection = %s, err = %s", lct.CollectionName, err)
|
||||
}
|
||||
if info.isLoaded { // TODO: may not be thread safe
|
||||
log.Debug("collection has been loaded",
|
||||
zap.String("role", typeutil.ProxyRole),
|
||||
zap.String("collectionName", lct.CollectionName),
|
||||
zap.Int64("collectionID", collID),
|
||||
zap.Int64("msgID", lct.GetBase().GetMsgID()))
|
||||
lct.result = &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_Success,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
lct.collectionID = collID
|
||||
collSchema, err := globalMetaCache.GetCollectionSchema(ctx, lct.CollectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
request := &querypb.LoadCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_LoadCollection,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user