Skip to content

Commit

Permalink
Limit max shard num to 64 (milvus-io#19776)
Browse files Browse the repository at this point in the history
Signed-off-by: longjiquan <jiquan.long@zilliz.com>

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
  • Loading branch information
longjiquan authored Oct 14, 2022
1 parent 8c9c167 commit cb51d41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/rootcoord/constrant.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ const (
globalIDAllocatorSubPath = "gid"
globalTSOAllocatorKey = "timestamp"
globalTSOAllocatorSubPath = "tso"

maxShardNum = 64
)
4 changes: 4 additions & 0 deletions internal/rootcoord/create_collection_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
11 changes: 11 additions & 0 deletions internal/rootcoord/create_collection_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit cb51d41

Please sign in to comment.