Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
This commit is contained in:
xufei 2024-01-10 14:09:40 +08:00 committed by GitHub
parent c7d29aafa7
commit c8c29046e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -982,6 +982,16 @@ type getRegionError interface {
GetRegionError() *errorpb.Error GetRegionError() *errorpb.Error
} }
func isResponseOKToNotImplGetRegionError(resp interface{}) bool {
switch resp.(type) {
case *MPPStreamResponse, *mpp.CancelTaskResponse, *mpp.IsAliveResponse, *mpp.ReportTaskStatusResponse,
*mpp.DispatchTaskResponse, *BatchCopStreamResponse, *tikvpb.BatchCommandsEmptyResponse:
return true
default:
return false
}
}
// GetRegionError returns the RegionError of the underlying concrete response. // GetRegionError returns the RegionError of the underlying concrete response.
func (resp *Response) GetRegionError() (*errorpb.Error, error) { func (resp *Response) GetRegionError() (*errorpb.Error, error) {
if resp.Resp == nil { if resp.Resp == nil {
@ -989,7 +999,7 @@ func (resp *Response) GetRegionError() (*errorpb.Error, error) {
} }
err, ok := resp.Resp.(getRegionError) err, ok := resp.Resp.(getRegionError)
if !ok { if !ok {
if _, isEmpty := resp.Resp.(*tikvpb.BatchCommandsEmptyResponse); isEmpty { if isResponseOKToNotImplGetRegionError(resp.Resp) {
return nil, nil return nil, nil
} }
return nil, errors.Errorf("invalid response type %v", resp) return nil, errors.Errorf("invalid response type %v", resp)