mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
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>
This commit is contained in:
parent
e46e3a1708
commit
a6606ce9c6
@ -73,7 +73,12 @@ func (t *createCollectionTask) validate(ctx context.Context) error {
|
|||||||
|
|
||||||
// 1. check shard number
|
// 1. check shard number
|
||||||
shardsNum := t.Req.GetShardsNum()
|
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 {
|
if shardsNum > cfgMaxShardNum {
|
||||||
return fmt.Errorf("shard num (%d) exceeds max configuration (%d)", 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) {
|
t.Run("shard num exceeds max configuration", func(t *testing.T) {
|
||||||
// TODO: better to have a `Set` method for ParamItem.
|
// 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{
|
task := createCollectionTask{
|
||||||
Req: &milvuspb.CreateCollectionRequest{
|
Req: &milvuspb.CreateCollectionRequest{
|
||||||
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateCollection},
|
Base: &commonpb.MsgBase{MsgType: commonpb.MsgType_CreateCollection},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user