mirror of https://github.com/tikv/client-go.git
retry stale read as stale if leader is not accessible (#1566)
Signed-off-by: rishabh_mittal <mittalrishabh@gmail.com>
This commit is contained in:
parent
d0d0c9712f
commit
ad5b9e27f3
|
@ -1412,9 +1412,6 @@ func (s *testRegionRequestToThreeStoresSuite) TestDoNotTryUnreachableLeader() {
|
|||
follower, _, _, _ := region.FollowerStorePeer(regionStore, 0, &storeSelectorOp{})
|
||||
|
||||
s.regionRequestSender.client = &fnClient{fn: func(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (response *tikvrpc.Response, err error) {
|
||||
if req.StaleRead && addr == follower.addr {
|
||||
return &tikvrpc.Response{Resp: &kvrpcpb.GetResponse{RegionError: &errorpb.Error{DataIsNotReady: &errorpb.DataIsNotReady{}}}}, nil
|
||||
}
|
||||
return &tikvrpc.Response{Resp: &kvrpcpb.GetResponse{
|
||||
Value: []byte(addr),
|
||||
}}, nil
|
||||
|
|
|
@ -333,7 +333,7 @@ func TestRegionCacheStaleRead(t *testing.T) {
|
|||
leaderRegionValid: true,
|
||||
leaderAsyncReload: util.Some(true),
|
||||
leaderSuccessReplica: []string{"z2", "z3"},
|
||||
leaderSuccessReadType: SuccessFollowerRead,
|
||||
leaderSuccessReadType: SuccessStaleRead,
|
||||
followerRegionValid: true,
|
||||
followerAsyncReload: util.None[bool](),
|
||||
followerSuccessReplica: []string{"z2"},
|
||||
|
|
|
@ -307,8 +307,8 @@ func (s *ReplicaSelectMixedStrategy) next(selector *replicaSelector) *replica {
|
|||
func (s *ReplicaSelectMixedStrategy) canSendReplicaRead(selector *replicaSelector) bool {
|
||||
replicas := selector.replicas
|
||||
replica := replicas[s.leaderIdx]
|
||||
if replica.hasFlag(deadlineErrUsingConfTimeoutFlag) || replica.hasFlag(serverIsBusyFlag) {
|
||||
// don't overwhelm the leader if it is busy
|
||||
if replica.attempts == 0 || replica.hasFlag(deadlineErrUsingConfTimeoutFlag) || replica.hasFlag(serverIsBusyFlag) {
|
||||
// don't do the replica read if leader is not exhausted or leader has timeout or server busy error.
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -2144,7 +2144,7 @@ func TestReplicaReadAccessPathByStaleReadCase(t *testing.T) {
|
|||
beforeRun: func() { /* don't resetStoreState */ },
|
||||
expect: &accessPathResult{
|
||||
accessPath: []string{
|
||||
"{addr: store3, replica-read: true, stale-read: false}",
|
||||
"{addr: store3, replica-read: false, stale-read: true}",
|
||||
},
|
||||
respErr: "",
|
||||
respRegionError: fakeEpochNotMatch,
|
||||
|
|
Loading…
Reference in New Issue