Skip to content

Commit

Permalink
store/tikv: fix region error handling. (pingcap#2192)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored and coocood committed Dec 7, 2016
1 parent 3793632 commit 90c61f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions store/tikv/mock-tikv/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ func newRPCHandler(cluster *Cluster, mvccStore *MvccStore, storeID uint64) *rpcH
}

func (h *rpcHandler) handleRequest(req *kvrpcpb.Request) *kvrpcpb.Response {
resp := &kvrpcpb.Response{
Type: req.Type,
}
var resp kvrpcpb.Response
if err := h.checkContext(req.GetContext()); err != nil {
resp.RegionError = err
return resp
return &resp
}
switch req.GetType() {
case kvrpcpb.MessageType_CmdGet:
Expand All @@ -75,7 +73,8 @@ func (h *rpcHandler) handleRequest(req *kvrpcpb.Request) *kvrpcpb.Response {
case kvrpcpb.MessageType_CmdRawDelete:
resp.CmdRawDeleteResp = h.onRawDelete(req.CmdRawDeleteReq)
}
return resp
resp.Type = req.Type
return &resp
}

func (h *rpcHandler) checkContext(ctx *kvrpcpb.Context) *errorpb.Error {
Expand Down
1 change: 1 addition & 0 deletions store/tikv/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (s *RegionRequestSender) SendKVReq(req *kvrpcpb.Request, regionID RegionVer
if retry {
continue
}
return resp, nil
}

if resp.GetType() != req.GetType() {
Expand Down

0 comments on commit 90c61f0

Please sign in to comment.