Skip to content

Commit

Permalink
Don't invalid region when first round cause by deadlineErr when using…
Browse files Browse the repository at this point in the history
… config timeout tikv#1177

Signed-off-by: crazycs520 <[email protected]>
  • Loading branch information
crazycs520 committed Feb 23, 2024
1 parent 6721d36 commit fa1d849
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,12 @@ func (state *accessFollower) next(bo *retry.Backoffer, selector *replicaSelector
}
return nil, stateChanged{}
}
for _, r := range selector.replicas {
if r.deadlineErrUsingConfTimeout {
// when meet deadline exceeded error, do fast retry without invalidate region cache.
return nil, nil
}
}
metrics.TiKVReplicaSelectorFailureCounter.WithLabelValues("exhausted").Inc()
selector.invalidateRegion()
return nil, nil
Expand Down
22 changes: 22 additions & 0 deletions internal/locate/replica_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ func TestReplicaReadAccessPathByCase(t *testing.T) {
}
s.True(s.runCaseAndCompare(ca))

// Don't invalid region in accessFollower, since leader meets deadlineExceededErr.
ca = replicaSelectorAccessPathCase{
reqType: tikvrpc.CmdGet,
readType: kv.ReplicaReadMixed,
staleRead: false,
timeout: time.Second,
label: nil,
accessErr: []RegionErrorType{ServerIsBusyErr, ServerIsBusyErr, DeadLineExceededErr},
expect: &accessPathResult{
accessPath: []string{
"{addr: store1, replica-read: true, stale-read: false}",
"{addr: store2, replica-read: true, stale-read: false}",
"{addr: store3, replica-read: true, stale-read: false}"},
respErr: "",
respRegionError: fakeEpochNotMatch,
backoffCnt: 0,
backoffDetail: []string{},
regionIsValid: true,
},
}
s.True(s.runCaseAndCompare(ca))

// Don't invalid region in tryFollowers, since leader meets deadlineExceededErr.
ca = replicaSelectorAccessPathCase{
reqType: tikvrpc.CmdGet,
Expand Down

0 comments on commit fa1d849

Please sign in to comment.