mirror of https://github.com/milvus-io/milvus.git
enhance: [2.4] add the skip auto id and partition key check config (#32597)
/kind improvement issue: https://github.com/milvus-io/milvus/issues/32591 pr: #32592 Signed-off-by: SimFG <bang.fu@zilliz.com>pull/32669/head^2
parent
05c14d4c21
commit
5da6db9252
|
@ -1203,7 +1203,12 @@ func checkPrimaryFieldData(schema *schemapb.CollectionSchema, result *milvuspb.M
|
|||
var primaryFieldData *schemapb.FieldData
|
||||
if inInsert {
|
||||
// when checkPrimaryFieldData in insert
|
||||
if !primaryFieldSchema.AutoID {
|
||||
|
||||
skipAutoIDCheck := Params.ProxyCfg.SkipAutoIDCheck.GetAsBool() &&
|
||||
primaryFieldSchema.AutoID &&
|
||||
typeutil.IsPrimaryFieldDataExist(insertMsg.GetFieldsData(), primaryFieldSchema)
|
||||
|
||||
if !primaryFieldSchema.AutoID || skipAutoIDCheck {
|
||||
primaryFieldData, err = typeutil.GetPrimaryFieldData(insertMsg.GetFieldsData(), primaryFieldSchema)
|
||||
if err != nil {
|
||||
log.Info("get primary field data failed", zap.String("collectionName", insertMsg.CollectionName), zap.Error(err))
|
||||
|
@ -1252,7 +1257,7 @@ func checkPrimaryFieldData(schema *schemapb.CollectionSchema, result *milvuspb.M
|
|||
}
|
||||
|
||||
func getPartitionKeyFieldData(fieldSchema *schemapb.FieldSchema, insertMsg *msgstream.InsertMsg) (*schemapb.FieldData, error) {
|
||||
if len(insertMsg.GetPartitionName()) > 0 {
|
||||
if len(insertMsg.GetPartitionName()) > 0 && !Params.ProxyCfg.SkipPartitionKeyCheck.GetAsBool() {
|
||||
return nil, errors.New("not support manually specifying the partition names if partition key mode is used")
|
||||
}
|
||||
|
||||
|
|
|
@ -1002,6 +1002,8 @@ type proxyConfig struct {
|
|||
RetryTimesOnReplica ParamItem `refreshable:"true"`
|
||||
RetryTimesOnHealthCheck ParamItem `refreshable:"true"`
|
||||
PartitionNameRegexp ParamItem `refreshable:"true"`
|
||||
SkipAutoIDCheck ParamItem `refreshable:"true"`
|
||||
SkipPartitionKeyCheck ParamItem `refreshable:"true"`
|
||||
|
||||
AccessLog AccessLogConfig
|
||||
|
||||
|
@ -1320,6 +1322,22 @@ please adjust in embedded Milvus: false`,
|
|||
}
|
||||
p.PartitionNameRegexp.Init(base.mgr)
|
||||
|
||||
p.SkipAutoIDCheck = ParamItem{
|
||||
Key: "proxy.skipAutoIDCheck",
|
||||
Version: "2.4.1",
|
||||
DefaultValue: "false",
|
||||
Doc: "switch for whether proxy shall skip auto id check when inserting data",
|
||||
}
|
||||
p.SkipAutoIDCheck.Init(base.mgr)
|
||||
|
||||
p.SkipPartitionKeyCheck = ParamItem{
|
||||
Key: "proxy.skipPartitionKeyCheck",
|
||||
Version: "2.4.1",
|
||||
DefaultValue: "false",
|
||||
Doc: "switch for whether proxy shall skip partition key check when inserting data",
|
||||
}
|
||||
p.SkipPartitionKeyCheck.Init(base.mgr)
|
||||
|
||||
p.GracefulStopTimeout = ParamItem{
|
||||
Key: "proxy.gracefulStopTimeout",
|
||||
Version: "2.3.7",
|
||||
|
|
|
@ -170,6 +170,14 @@ func TestComponentParam(t *testing.T) {
|
|||
|
||||
params.Save("proxy.gracefulStopTimeout", "100")
|
||||
assert.Equal(t, 100*time.Second, Params.GracefulStopTimeout.GetAsDuration(time.Second))
|
||||
|
||||
assert.False(t, Params.SkipAutoIDCheck.GetAsBool())
|
||||
params.Save("proxy.skipAutoIDCheck", "true")
|
||||
assert.True(t, Params.SkipAutoIDCheck.GetAsBool())
|
||||
|
||||
assert.False(t, Params.SkipPartitionKeyCheck.GetAsBool())
|
||||
params.Save("proxy.skipPartitionKeyCheck", "true")
|
||||
assert.True(t, Params.SkipPartitionKeyCheck.GetAsBool())
|
||||
})
|
||||
|
||||
// t.Run("test proxyConfig panic", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue