Skip to content

Commit

Permalink
save work (#1108)
Browse files Browse the repository at this point in the history
Signed-off-by: xufei <[email protected]>
  • Loading branch information
windtalker authored Jan 10, 2024
1 parent c7d29aa commit c8c2904
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tikvrpc/tikvrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,14 +982,24 @@ type getRegionError interface {
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.
func (resp *Response) GetRegionError() (*errorpb.Error, error) {
if resp.Resp == nil {
return nil, nil
}
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)
Expand Down

0 comments on commit c8c2904

Please sign in to comment.