fix retry on unimplemented rpc error (#27639)

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
pull/27615/head
wei liu 2023-10-16 10:50:09 +08:00 committed by GitHub
parent 5785756d31
commit 7aa862c0ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -110,7 +110,8 @@ type ClientBase[T interface {
func NewClientBase[T interface {
GetComponentStates(ctx context.Context, in *milvuspb.GetComponentStatesRequest, opts ...grpc.CallOption) (*milvuspb.ComponentStates, error)
}](config *paramtable.GrpcClientConfig, serviceName string) *ClientBase[T] {
}](config *paramtable.GrpcClientConfig, serviceName string,
) *ClientBase[T] {
return &ClientBase[T]{
ClientMaxRecvSize: config.ClientMaxRecvSize.GetAsInt(),
ClientMaxSendSize: config.ClientMaxSendSize.GetAsInt(),
@ -368,6 +369,10 @@ func (c *ClientBase[T]) checkErr(ctx context.Context, err error) (needRetry, nee
// canceled or deadline exceeded
return true, c.needResetCancel()
}
if funcutil.IsGrpcErr(err, codes.Unimplemented) {
return false, false
}
return true, true
case IsServerIDMismatchErr(err):
fallthrough

View File

@ -309,6 +309,21 @@ func TestClientBase_Recall(t *testing.T) {
})
}
func TestClientBase_CheckError(t *testing.T) {
base := ClientBase[*mockClient]{}
base.grpcClient = &mockClient{}
base.MaxAttempts = 1
ctx := context.Background()
retry, reset := base.checkErr(ctx, status.Errorf(codes.Canceled, "fake context canceled"))
assert.True(t, retry)
assert.True(t, reset)
retry, reset = base.checkErr(ctx, status.Errorf(codes.Unimplemented, "fake context canceled"))
assert.False(t, retry)
assert.False(t, reset)
}
type server struct {
helloworld.UnimplementedGreeterServer
reqCounter uint