Skip to content

Commit

Permalink
fix TestIsRetryRequestFlagWithRegionError
Browse files Browse the repository at this point in the history
Signed-off-by: zyguan <[email protected]>
  • Loading branch information
zyguan committed Jan 26, 2025
1 parent d6ce406 commit 0b6c751
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,24 @@ func (s *sendReqState) next(
}

s.vars.rpcCtx, s.vars.resp = nil, nil
if !req.IsRetryRequest && s.vars.sendTimes > 0 {
req.IsRetryRequest = true
}

s.vars.rpcCtx, s.vars.err = s.getRPCContext(bo, req, regionID, et, opts...)
if s.vars.err != nil {
return true
}

if _, err := util.EvalFailpoint("invalidCacheAndRetry"); err == nil {
// cooperate with tikvclient/setGcResolveMaxBackoff
if c := bo.GetCtx().Value("injectedBackoff"); c != nil {
s.vars.regionErr = &errorpb.Error{EpochNotMatch: &errorpb.EpochNotMatch{}}
s.vars.resp, s.vars.err = tikvrpc.GenRegionErrorResp(req, s.vars.regionErr)
return true
}
}

if s.vars.rpcCtx == nil {
// TODO(youjiali1995): remove it when using the replica selector for all requests.
// If the region is not found in cache, it must be out
Expand Down Expand Up @@ -826,14 +838,6 @@ func (s *sendReqState) next(
logutil.Eventf(bo.GetCtx(), "send %s request to region %d at %s", req.Type, regionID.id, s.vars.rpcCtx.Addr)
s.storeAddr = s.vars.rpcCtx.Addr

if _, err := util.EvalFailpoint("beforeSendReqToRegion"); err == nil {
if hook := bo.GetCtx().Value("sendReqToRegionHook"); hook != nil {
h := hook.(func(*tikvrpc.Request))
h(req)
}
}

req.IsRetryRequest = s.vars.sendTimes > 0
req.Context.ClusterId = s.vars.rpcCtx.ClusterID
if req.InputRequestSource != "" && s.replicaSelector != nil {
patchRequestSource(req, s.replicaSelector.replicaType())
Expand All @@ -848,6 +852,13 @@ func (s *sendReqState) next(
}
}

if _, err := util.EvalFailpoint("beforeSendReqToRegion"); err == nil {
if hook := bo.GetCtx().Value("sendReqToRegionHook"); hook != nil {
h := hook.(func(*tikvrpc.Request))
h(req)
}
}

// judge the store limit switch.
if limit := kv.StoreLimit.Load(); limit > 0 {
if s.vars.err = s.getStoreToken(s.vars.rpcCtx.Store, limit); s.vars.err != nil {
Expand Down

0 comments on commit 0b6c751

Please sign in to comment.