Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replica-read request with mixed strategy and with label, should be able to retry all remain replicas #1183

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/locate/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,8 @@ func (state *accessFollower) next(bo *retry.Backoffer, selector *replicaSelector
// If the leader is also unavailable, we can fallback to the follower and use replica-read flag again,
// The remote follower not tried yet, and the local follower can retry without stale-read flag.
// If leader tried and received deadline exceeded error, try follower.
if state.isStaleRead || leader.deadlineErrUsingConfTimeout {
// If has labels, some followers's labels may not match, then can't be candidate, need to try follower.
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
if state.isStaleRead || leader.deadlineErrUsingConfTimeout || len(state.option.labels) > 0 {
selector.state = &tryFollower{
leaderIdx: state.leaderIdx,
lastIdx: state.leaderIdx,
Expand Down
23 changes: 22 additions & 1 deletion internal/locate/replica_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type accessPathResult struct {
regionIsValid bool
}

func TestReplicaReadStaleReadAccessPathByCase(t *testing.T) {
func TestReplicaReadAccessPathByCase(t *testing.T) {
s := new(testReplicaSelectorSuite)
s.SetupTest(t)
defer s.TearDownTest()
Expand Down Expand Up @@ -282,6 +282,27 @@ func TestReplicaReadStaleReadAccessPathByCase(t *testing.T) {
},
}
s.True(s.runCaseAndCompare(ca))

ca = replicaSelectorAccessPathCase{
reqType: tikvrpc.CmdGet,
readType: kv.ReplicaReadMixed,
staleRead: false,
timeout: time.Second,
label: &metapb.StoreLabel{Key: "id", Value: "2"},
accessErr: []RegionErrorType{DeadLineExceededErr, ServerIsBusyErr},
expect: &accessPathResult{
accessPath: []string{
"{addr: store2, replica-read: true, stale-read: false}",
"{addr: store1, replica-read: true, stale-read: false}",
"{addr: store3, replica-read: true, stale-read: false}"},
respErr: "",
respRegionError: nil,
backoffCnt: 1,
backoffDetail: []string{"tikvServerBusy+1"},
regionIsValid: true,
},
}
s.True(s.runCaseAndCompare(ca))
}
func (s *testReplicaSelectorSuite) runCaseAndCompare(ca2 replicaSelectorAccessPathCase) bool {
ca2.run(s)
Expand Down
Loading