mirror of https://github.com/milvus-io/milvus.git
fix: set CollectionID field for AlterCollection request (#30814)
issue: https://github.com/milvus-io/milvus/issues/30800 --------- Signed-off-by: sunby <sunbingyi1992@gmail.com>pull/30941/head
parent
4863765521
commit
eb0cfe3e84
|
@ -881,6 +881,12 @@ func (t *alterCollectionTask) PreExecute(ctx context.Context) error {
|
|||
t.Base.MsgType = commonpb.MsgType_AlterCollection
|
||||
t.Base.SourceID = paramtable.GetNodeID()
|
||||
|
||||
collectionID, err := globalMetaCache.GetCollectionID(ctx, t.GetDbName(), t.CollectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.CollectionID = collectionID
|
||||
if hasMmapProp(t.Properties...) || hasLazyLoadProp(t.Properties...) {
|
||||
loaded, err := isCollectionLoaded(ctx, t.queryCoord, t.CollectionID)
|
||||
if err != nil {
|
||||
|
|
|
@ -3602,20 +3602,39 @@ func TestClusteringKey(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAlterCollectionCheckLoaded(t *testing.T) {
|
||||
rc := NewRootCoordMock()
|
||||
rc.state.Store(commonpb.StateCode_Healthy)
|
||||
qc := &mocks.MockQueryCoordClient{}
|
||||
InitMetaCache(context.Background(), rc, qc, nil)
|
||||
collectionName := "test_alter_collection_check_loaded"
|
||||
createColReq := &milvuspb.CreateCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_DropCollection,
|
||||
MsgID: 100,
|
||||
Timestamp: 100,
|
||||
},
|
||||
DbName: dbName,
|
||||
CollectionName: collectionName,
|
||||
Schema: nil,
|
||||
ShardsNum: 1,
|
||||
}
|
||||
rc.CreateCollection(context.Background(), createColReq)
|
||||
resp, err := rc.DescribeCollection(context.Background(), &milvuspb.DescribeCollectionRequest{CollectionName: collectionName})
|
||||
assert.NoError(t, err)
|
||||
|
||||
qc.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(&querypb.ShowCollectionsResponse{
|
||||
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
||||
CollectionIDs: []int64{1},
|
||||
CollectionIDs: []int64{resp.CollectionID},
|
||||
InMemoryPercentages: []int64{100},
|
||||
}, nil)
|
||||
task := &alterCollectionTask{
|
||||
AlterCollectionRequest: &milvuspb.AlterCollectionRequest{
|
||||
Base: &commonpb.MsgBase{},
|
||||
CollectionID: 1,
|
||||
Properties: []*commonpb.KeyValuePair{{Key: common.MmapEnabledKey, Value: "true"}},
|
||||
Base: &commonpb.MsgBase{},
|
||||
CollectionName: collectionName,
|
||||
Properties: []*commonpb.KeyValuePair{{Key: common.MmapEnabledKey, Value: "true"}},
|
||||
},
|
||||
queryCoord: qc,
|
||||
}
|
||||
err := task.PreExecute(context.Background())
|
||||
err = task.PreExecute(context.Background())
|
||||
assert.Equal(t, merr.Code(merr.ErrCollectionLoaded), merr.Code(err))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue