do not format error when response does not include ExecDetailsV2 (#553)

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
This commit is contained in:
Yilin Chen 2022-07-21 11:16:57 +08:00 committed by GitHub
parent aa9ded37d1
commit e38d2b07de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -437,8 +437,8 @@ func (c *RPCClient) updateTiKVSendReqHistogram(req *tikvrpc.Request, resp *tikvr
counter.(sendReqCounterCacheValue).counter.Inc()
counter.(sendReqCounterCacheValue).timeCounter.Add(secs)
if execDetail, err := resp.GetExecDetailsV2(); err == nil &&
execDetail != nil && execDetail.TimeDetail != nil && execDetail.TimeDetail.TotalRpcWallTimeNs > 0 {
if execDetail := resp.GetExecDetailsV2(); execDetail != nil &&
execDetail.TimeDetail != nil && execDetail.TimeDetail.TotalRpcWallTimeNs > 0 {
latHist, ok := rpcNetLatencyHistCache.Load(storeID)
if !ok {
if len(storeIDStr) == 0 {

View File

@ -931,18 +931,15 @@ type getExecDetailsV2 interface {
}
// GetExecDetailsV2 returns the ExecDetailsV2 of the underlying concrete response.
func (resp *Response) GetExecDetailsV2() (*kvrpcpb.ExecDetailsV2, error) {
func (resp *Response) GetExecDetailsV2() *kvrpcpb.ExecDetailsV2 {
if resp == nil || resp.Resp == nil {
return nil, nil
return nil
}
details, ok := resp.Resp.(getExecDetailsV2)
if !ok {
if _, isEmpty := resp.Resp.(*tikvpb.BatchCommandsEmptyResponse); isEmpty {
return nil, nil
}
return nil, errors.Errorf("invalid response type %v", resp)
return nil
}
return details.GetExecDetailsV2(), nil
return details.GetExecDetailsV2()
}
// CallRPC launches a rpc call.