fix context leak in BatchDelete (#704)

Signed-off-by: Ping Yu <yuping@pingcap.com>
This commit is contained in:
Ping Yu 2023-02-15 15:57:57 +08:00 committed by GitHub
parent 95ebf6a863
commit b3c491995e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -750,9 +750,9 @@ func (c *Client) sendBatchReq(bo *retry.Backoffer, keys [][]byte, options *rawOp
singleResp, ok := <-ches
if ok {
if singleResp.Error != nil {
cancel()
if firstError == nil {
firstError = errors.WithStack(singleResp.Error)
cancel()
}
} else if cmdType == tikvrpc.CmdRawBatchGet {
cmdResp := singleResp.Resp.(*kvrpcpb.RawBatchGetResponse)
@ -761,6 +761,9 @@ func (c *Client) sendBatchReq(bo *retry.Backoffer, keys [][]byte, options *rawOp
}
}
if firstError == nil {
cancel()
}
return resp, firstError
}