enhance: [GoSDK] Return SchemaMismatch error to retry (#42950)

Related to #39718

After adding field, composing write request may failure and shall
trigger retry with new schema. This PR make composing error returns
SchemaMismatch error to trigger retry policy

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-06-26 10:28:41 +08:00 committed by GitHub
parent be05b653c1
commit 1139ebb964
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -41,7 +41,8 @@ func (c *Client) Insert(ctx context.Context, option InsertOption, callOptions ..
} }
req, err := option.InsertRequest(collection) req, err := option.InsertRequest(collection)
if err != nil { if err != nil {
return collection.UpdateTimestamp, err // return schema mismatch err to retry with newer schema
return collection.UpdateTimestamp, merr.WrapErrCollectionSchemaMisMatch(err)
} }
return collection.UpdateTimestamp, c.callService(func(milvusService milvuspb.MilvusServiceClient) error { return collection.UpdateTimestamp, c.callService(func(milvusService milvuspb.MilvusServiceClient) error {
@ -99,7 +100,8 @@ func (c *Client) Upsert(ctx context.Context, option UpsertOption, callOptions ..
} }
req, err := option.UpsertRequest(collection) req, err := option.UpsertRequest(collection)
if err != nil { if err != nil {
return collection.UpdateTimestamp, err // return schema mismatch err to retry with newer schema
return collection.UpdateTimestamp, merr.WrapErrCollectionSchemaMisMatch(err)
} }
return collection.UpdateTimestamp, c.callService(func(milvusService milvuspb.MilvusServiceClient) error { return collection.UpdateTimestamp, c.callService(func(milvusService milvuspb.MilvusServiceClient) error {
resp, err := milvusService.Upsert(ctx, req, callOptions...) resp, err := milvusService.Upsert(ctx, req, callOptions...)

View File

@ -147,6 +147,12 @@ func (s *WriteSuite) TestInsert() {
s.Run("bad_input", func() { s.Run("bad_input", func() {
collName := fmt.Sprintf("coll_%s", s.randString(6)) collName := fmt.Sprintf("coll_%s", s.randString(6))
s.setupCache(collName, s.schema) s.setupCache(collName, s.schema)
// bs, err := proto.Marshal(s.schema.ProtoMessage())
// s.Require().NoError(err)
s.mock.EXPECT().DescribeCollection(mock.Anything, mock.Anything).Return(&milvuspb.DescribeCollectionResponse{
CollectionName: collName,
Schema: s.schema.ProtoMessage(),
}, nil)
type badCase struct { type badCase struct {
tag string tag string