Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: you06 <you1474600@gmail.com>

update

Signed-off-by: you06 <you1474600@gmail.com>

fix test

Signed-off-by: you06 <you1474600@gmail.com>

fix test

Signed-off-by: you06 <you1474600@gmail.com>
  • Loading branch information
you06 committed Aug 15, 2023
1 parent a1ee1da commit 233bf4f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (state *accessKnownLeader) next(bo *retry.Backoffer, selector *replicaSelec
// a request. So, before the new leader is elected, we should not send requests
// to the unreachable old leader to avoid unnecessary timeout.
if liveness != reachable || leader.isExhausted(maxReplicaAttempt) {
selector.state = &tryFollower{leaderIdx: state.leaderIdx, lastIdx: state.leaderIdx}
selector.state = &tryFollower{leaderIdx: state.leaderIdx, lastIdx: state.leaderIdx, fromOnNotLeader: true}
return nil, stateChanged{}
}
if selector.busyThreshold > 0 {
Expand All @@ -369,15 +369,15 @@ func (state *accessKnownLeader) onSendFailure(bo *retry.Backoffer, selector *rep
return
}
if liveness != reachable || selector.targetReplica().isExhausted(maxReplicaAttempt) {
selector.state = &tryFollower{leaderIdx: state.leaderIdx, lastIdx: state.leaderIdx}
selector.state = &tryFollower{leaderIdx: state.leaderIdx, lastIdx: state.leaderIdx, fromOnNotLeader: true}
}
if liveness != reachable {
selector.invalidateReplicaStore(selector.targetReplica(), cause)
}
}

func (state *accessKnownLeader) onNoLeader(selector *replicaSelector) {
selector.state = &tryFollower{leaderIdx: state.leaderIdx, lastIdx: state.leaderIdx}
selector.state = &tryFollower{leaderIdx: state.leaderIdx, lastIdx: state.leaderIdx, fromOnNotLeader: true}
}

// tryFollower is the state where we cannot access the known leader
Expand Down Expand Up @@ -656,14 +656,13 @@ func (state *accessFollower) next(bo *retry.Backoffer, selector *replicaSelector
if selector.targetIdx < 0 {
leader := selector.replicas[state.leaderIdx]
leaderEpochStale := leader.isEpochStale()
leaderInvalid := leaderEpochStale || leader.isExhausted(1)
leaderInvalid := leaderEpochStale || state.IsLeaderExhausted(leader)
if len(state.option.labels) > 0 {
logutil.Logger(bo.GetCtx()).Warn("unable to find stores with given labels",
zap.Uint64("region", selector.region.GetID()),
zap.Bool("leader-invalid", leaderInvalid),
zap.Any("labels", state.option.labels))
}
if leaderInvalid {
if leaderInvalid {
// In stale-read, the request will fallback to leader after the local follower failure.
// If the leader is also unavailable, we can fallback to the follower and use replica-read flag again,
Expand Down

0 comments on commit 233bf4f

Please sign in to comment.