Skip to content

Commit

Permalink
tikv: fix panic after sending fail with ambiguous errors (#17211) (#1…
Browse files Browse the repository at this point in the history
…7379)

* tikv: fix panic after sending fail with ambiguous errors (#17211)

* fix compile

Co-authored-by: lysu <sulifx@gmail.com>
  • Loading branch information
sre-bot and lysu authored Jun 8, 2020
1 parent 86211f0 commit 1e8aded
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions store/tikv/client_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (c *batchCommandsClient) send(request *tikvpb.BatchCommandsRequest, entries
logutil.Logger(context.Background()).Info(
"sending batch commands meets error",
zap.String("target", c.target),
zap.Uint64s("requestIDs", request.RequestIds),
zap.Error(err),
)
c.failPendingRequests(err)
Expand Down Expand Up @@ -339,10 +340,10 @@ func (c *batchCommandsClient) batchRecvLoop(cfg config.TiKVClient, tikvTransport
for i, requestID := range resp.GetRequestIds() {
value, ok := c.batched.Load(requestID)
if !ok {
// There shouldn't be any unknown responses because if the old entries
// are cleaned by `failPendingRequests`, the stream must be re-created
// so that old responses will be never received.
panic("batchRecvLoop receives a unknown response")
// this maybe caused by batchCommandsClient#send meets ambiguous error that request has be sent to TiKV but still report a error.
// then TiKV will send response back though stream and reach here.
logutil.Logger(context.Background()).Warn("batchRecvLoop receives outdated response", zap.Uint64("requestID", requestID))
continue
}
entry := value.(*batchCommandsEntry)
if atomic.LoadInt32(&entry.canceled) == 0 {
Expand Down

0 comments on commit 1e8aded

Please sign in to comment.