mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Fix max partition number don't work (#22216)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>
This commit is contained in:
parent
15220f32e5
commit
d9ca06eb4e
@ -2,6 +2,7 @@ package rootcoord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
pb "github.com/milvus-io/milvus/internal/proto/etcdpb"
|
||||
|
||||
@ -40,6 +41,12 @@ func (t *createPartitionTask) Execute(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
cfgMaxPartitionNum := Params.RootCoordCfg.MaxPartitionNum.GetAsInt()
|
||||
if len(t.collMeta.Partitions) >= cfgMaxPartitionNum {
|
||||
return fmt.Errorf("partition number (%d) exceeds max configuration (%d), collection: %s",
|
||||
len(t.collMeta.Partitions), cfgMaxPartitionNum, t.collMeta.Name)
|
||||
}
|
||||
|
||||
partID, err := t.core.idAllocator.AllocOne()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -64,6 +64,23 @@ func Test_createPartitionTask_Execute(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("create too many partitions", func(t *testing.T) {
|
||||
cfgMaxPartitionNum := Params.RootCoordCfg.MaxPartitionNum.GetAsInt()
|
||||
partitions := make([]*model.Partition, 0, cfgMaxPartitionNum)
|
||||
for i := 0; i < cfgMaxPartitionNum; i++ {
|
||||
partitions = append(partitions, &model.Partition{})
|
||||
}
|
||||
collectionName := funcutil.GenRandomStr()
|
||||
partitionName := funcutil.GenRandomStr()
|
||||
coll := &model.Collection{Name: collectionName, Partitions: partitions}
|
||||
task := &createPartitionTask{
|
||||
collMeta: coll,
|
||||
Req: &milvuspb.CreatePartitionRequest{CollectionName: collectionName, PartitionName: partitionName},
|
||||
}
|
||||
err := task.Execute(context.Background())
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("failed to allocate partition id", func(t *testing.T) {
|
||||
collectionName := funcutil.GenRandomStr()
|
||||
partitionName := funcutil.GenRandomStr()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user