mirror of https://github.com/milvus-io/milvus.git
fix: check PreCreatedTopic first in shard number validation (#41274)
issue : https://github.com/milvus-io/milvus/issues/41271 Signed-off-by: Xiaowei Shi <shallwe.shih@gmail.com>pull/41358/head
parent
e46e3a1708
commit
a6606ce9c6
|
@ -73,7 +73,12 @@ func (t *createCollectionTask) validate(ctx context.Context) error {
|
|||
|
||||
// 1. check shard number
|
||||
shardsNum := t.Req.GetShardsNum()
|
||||
cfgMaxShardNum := Params.RootCoordCfg.DmlChannelNum.GetAsInt32()
|
||||
var cfgMaxShardNum int32
|
||||
if Params.CommonCfg.PreCreatedTopicEnabled.GetAsBool() {
|
||||
cfgMaxShardNum = int32(len(Params.CommonCfg.TopicNames.GetAsStrings()))
|
||||
} else {
|
||||
cfgMaxShardNum = Params.RootCoordCfg.DmlChannelNum.GetAsInt32()
|
||||
}
|
||||
if shardsNum > cfgMaxShardNum {
|
||||
return fmt.Errorf("shard num (%d) exceeds max configuration (%d)", shardsNum, cfgMaxShardNum)
|
||||
}
|
||||
|
|
|
@ -99,7 +99,12 @@ func Test_createCollectionTask_validate(t *testing.T) {
|
|||
|
||||
t.Run("shard num exceeds max configuration", func(t *testing.T) {
|
||||
// TODO: better to have a `Set` method for ParamItem.
|
||||
cfgMaxShardNum := Params.RootCoordCfg.DmlChannelNum.GetAsInt32()
|
||||
var cfgMaxShardNum int32
|
||||
if Params.CommonCfg.PreCreatedTopicEnabled.GetAsBool() {
|
||||
cfgMaxShardNum = int32(len(Params.CommonCfg.TopicNames.GetAsStrings()))
|
||||
} else {
|
||||
cfgMaxShardNum = Params.RootCoordCfg.DmlChannelNum.GetAsInt32()
|
||||
}
|
||||
task := createCollectionTask{
|
||||
Req: &milvuspb.CreateCollectionRequest{
|
||||
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateCollection},
|
||||
|
|
Loading…
Reference in New Issue