Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: [2.3] add the skip auto id and partition key check config #32671

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/proxy/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,11 @@ 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))
Expand Down Expand Up @@ -1256,7 +1260,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")
}

Expand Down
19 changes: 19 additions & 0 deletions pkg/util/paramtable/component_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ type proxyConfig struct {
RetryTimesOnHealthCheck ParamItem `refreshable:"true"`
PartitionNameRegexp ParamItem `refreshable:"true"`

SkipAutoIDCheck ParamItem `refreshable:"true"`
SkipPartitionKeyCheck ParamItem `refreshable:"true"`

AccessLog AccessLogConfig

// connection manager
Expand Down Expand Up @@ -1282,6 +1285,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",
Expand Down
8 changes: 8 additions & 0 deletions pkg/util/paramtable/component_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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) {
Expand Down