From e661aba09b98e9b5d9618df3f13cf6f8f0bc9669 Mon Sep 17 00:00:00 2001 From: xufei Date: Fri, 10 May 2024 13:50:59 +0800 Subject: [PATCH] cherry pick #1108 Signed-off-by: xufei --- tikvrpc/tikvrpc.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tikvrpc/tikvrpc.go b/tikvrpc/tikvrpc.go index ccae4ab1c7..e4ae98c5bf 100644 --- a/tikvrpc/tikvrpc.go +++ b/tikvrpc/tikvrpc.go @@ -897,6 +897,16 @@ type getRegionError interface { GetRegionError() *errorpb.Error } +func isResponseOKToNotImplGetRegionError(resp interface{}) bool { + switch resp.(type) { + case *MPPStreamResponse, *mpp.CancelTaskResponse, *mpp.IsAliveResponse, + *mpp.DispatchTaskResponse, *BatchCopStreamResponse, *tikvpb.BatchCommandsEmptyResponse: + return true + default: + return false + } +} + // GetRegionError returns the RegionError of the underlying concrete response. func (resp *Response) GetRegionError() (*errorpb.Error, error) { if resp.Resp == nil { @@ -904,7 +914,7 @@ func (resp *Response) GetRegionError() (*errorpb.Error, error) { } err, ok := resp.Resp.(getRegionError) if !ok { - if _, isEmpty := resp.Resp.(*tikvpb.BatchCommandsEmptyResponse); isEmpty { + if isResponseOKToNotImplGetRegionError(resp.Resp) { return nil, nil } return nil, errors.Errorf("invalid response type %v", resp)