Skip to content

Commit ccbe6fc

Browse files
authored
enhance: [2.4] add param for tuning max VARCHAR length (#38890)
issue: #38882 pr: #38884 Signed-off-by: Patrick Weizhi Xu <[email protected]> (cherry picked from commit 72fecd4)
1 parent 163b258 commit ccbe6fc

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

internal/proxy/task.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,9 @@ func (t *alterCollectionFieldTask) PreExecute(ctx context.Context) error {
11941194
return merr.WrapErrParameterInvalid("%s should be an integer, but got %T", prop.Key, prop.Value)
11951195
}
11961196

1197-
if value > defaultMaxVarCharLength {
1198-
return merr.WrapErrParameterInvalid("%s exceeds the maximum allowed value 65535", prop.Value)
1197+
defaultMaxVarCharLength := Params.ProxyCfg.MaxVarCharLength.GetAsInt64()
1198+
if int64(value) > defaultMaxVarCharLength {
1199+
return merr.WrapErrParameterInvalidMsg("%s exceeds the maximum allowed value %s", prop.Value, strconv.FormatInt(defaultMaxVarCharLength, 10))
11991200
}
12001201
}
12011202
}

internal/proxy/util.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ const (
6363
// enableMultipleVectorFields indicates whether to enable multiple vector fields.
6464
enableMultipleVectorFields = true
6565

66-
defaultMaxVarCharLength = 65535
67-
6866
defaultMaxArrayCapacity = 4096
6967

7068
defaultMaxSearchRequest = 1024
@@ -363,8 +361,10 @@ func validateMaxLengthPerRow(collectionName string, field *schemapb.FieldSchema)
363361
if err != nil {
364362
return err
365363
}
364+
365+
defaultMaxVarCharLength := Params.ProxyCfg.MaxVarCharLength.GetAsInt64()
366366
if maxLengthPerRow > defaultMaxVarCharLength || maxLengthPerRow <= 0 {
367-
return merr.WrapErrParameterInvalidMsg("the maximum length specified for a VarChar should be in (0, 65535]")
367+
return merr.WrapErrParameterInvalidMsg("the maximum length specified for a VarChar should be in (0, %d]", defaultMaxVarCharLength)
368368
}
369369
exist = true
370370
}

pkg/util/paramtable/component_param.go

+9
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ type proxyConfig struct {
13031303
SkipAutoIDCheck ParamItem `refreshable:"true"`
13041304
SkipPartitionKeyCheck ParamItem `refreshable:"true"`
13051305
EnablePublicPrivilege ParamItem `refreshable:"false"`
1306+
MaxVarCharLength ParamItem `refreshable:"false"`
13061307

13071308
AccessLog AccessLogConfig
13081309

@@ -1697,6 +1698,14 @@ please adjust in embedded Milvus: false`,
16971698
}
16981699
p.EnablePublicPrivilege.Init(base.mgr)
16991700

1701+
p.MaxVarCharLength = ParamItem{
1702+
Key: "proxy.maxVarCharLength",
1703+
Version: "2.4.19", // hotfix
1704+
DefaultValue: strconv.Itoa(65535), // 64K
1705+
Doc: "maximum number of characters for a varchar field; this value is overridden by the value in a pre-existing schema if applicable",
1706+
}
1707+
p.MaxVarCharLength.Init(base.mgr)
1708+
17001709
p.GracefulStopTimeout = ParamItem{
17011710
Key: "proxy.gracefulStopTimeout",
17021711
Version: "2.3.7",

0 commit comments

Comments
 (0)