@@ -532,12 +532,12 @@ func (state *tryNewProxy) onNoLeader(selector *replicaSelector) {
532
532
type accessFollower struct {
533
533
stateBase
534
534
// If tryLeader is true, the request can also be sent to the leader when !leader.isSlow()
535
- tryLeader bool
536
- isGlobalStaleRead bool
537
- option storeSelectorOp
538
- leaderIdx AccessIndex
539
- lastIdx AccessIndex
540
- learnerOnly bool
535
+ tryLeader bool
536
+ isStaleRead bool
537
+ option storeSelectorOp
538
+ leaderIdx AccessIndex
539
+ lastIdx AccessIndex
540
+ learnerOnly bool
541
541
}
542
542
543
543
func (state * accessFollower ) next (bo * retry.Backoffer , selector * replicaSelector ) (* RPCContext , error ) {
@@ -558,12 +558,10 @@ func (state *accessFollower) next(bo *retry.Backoffer, selector *replicaSelector
558
558
}
559
559
}
560
560
} else {
561
- // Stale Read request will retry the leader or next peer on error,
562
- // if txnScope is global, we will only retry the leader by using the WithLeaderOnly option,
563
- // if txnScope is local, we will retry both other peers and the leader by the strategy of replicaSelector.
564
- if state .isGlobalStaleRead {
561
+ // Stale Read request will retry the leader only by using the WithLeaderOnly option,
562
+ if state .isStaleRead {
565
563
WithLeaderOnly ()(& state .option )
566
- // retry on the leader should not use stale read flag to avoid possible DataIsNotReady error as it always can serve any read
564
+ // retry on the leader should not use stale read flag to avoid possible DataIsNotReady error as it always can serve any read.
567
565
resetStaleRead = true
568
566
}
569
567
state .lastIdx ++
@@ -766,12 +764,12 @@ func newReplicaSelector(
766
764
}
767
765
tryLeader := req .ReplicaReadType == kv .ReplicaReadMixed || req .ReplicaReadType == kv .ReplicaReadPreferLeader
768
766
state = & accessFollower {
769
- tryLeader : tryLeader ,
770
- isGlobalStaleRead : req .IsGlobalStaleRead () ,
771
- option : option ,
772
- leaderIdx : regionStore .workTiKVIdx ,
773
- lastIdx : - 1 ,
774
- learnerOnly : req .ReplicaReadType == kv .ReplicaReadLearner ,
767
+ tryLeader : tryLeader ,
768
+ isStaleRead : req .StaleRead ,
769
+ option : option ,
770
+ leaderIdx : regionStore .workTiKVIdx ,
771
+ lastIdx : - 1 ,
772
+ learnerOnly : req .ReplicaReadType == kv .ReplicaReadLearner ,
775
773
}
776
774
}
777
775
0 commit comments