Limit max shard num to 64 (#19776)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
pull/19714/head
Jiquan Long 2022-10-14 14:51:23 +08:00 committed by GitHub
parent 8c9c1672ae
commit cb51d410a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -6,4 +6,6 @@ const (
globalIDAllocatorSubPath = "gid"
globalTSOAllocatorKey = "timestamp"
globalTSOAllocatorSubPath = "tso"
maxShardNum = 64
)

View File

@ -50,6 +50,10 @@ func (t *createCollectionTask) validate() error {
return err
}
if t.Req.GetShardsNum() >= maxShardNum {
return fmt.Errorf("shard num (%d) exceeds limit (%d)", t.Req.GetShardsNum(), maxShardNum)
}
return nil
}

View File

@ -40,6 +40,17 @@ func Test_createCollectionTask_validate(t *testing.T) {
assert.Error(t, err)
})
t.Run("shard num exceeds limit", func(t *testing.T) {
task := createCollectionTask{
Req: &milvuspb.CreateCollectionRequest{
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateCollection},
ShardsNum: maxShardNum + 1,
},
}
err := task.validate()
assert.Error(t, err)
})
t.Run("normal case", func(t *testing.T) {
task := createCollectionTask{
Req: &milvuspb.CreateCollectionRequest{