Skip to content

Commit

Permalink
Merge branch 'master' into feat-branch-reorg-part-master-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Feb 9, 2023
2 parents ae0e1a7 + 3b0a512 commit f081d66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions kv/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const (
ReplicaReadClosestAdaptive
// ReplicaReadLearner stands for 'read from learner'.
ReplicaReadLearner
// ReplicaReadPreferLeader stands for 'read from leader and auto-turn to followers if leader is abnormal'.
ReplicaReadPreferLeader
)

// IsFollowerRead checks if follower is going to be used to read data.
Expand Down
4 changes: 3 additions & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ var defaultSysVars = []*SysVar{
s.NoopFuncsMode = TiDBOptOnOffWarn(val)
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBReplicaRead, Value: "leader", Type: TypeEnum, PossibleValues: []string{"leader", "follower", "leader-and-follower", "closest-replicas", "closest-adaptive", "learner"}, SetSession: func(s *SessionVars, val string) error {
{Scope: ScopeGlobal | ScopeSession, Name: TiDBReplicaRead, Value: "leader", Type: TypeEnum, PossibleValues: []string{"leader", "prefer-leader", "follower", "leader-and-follower", "closest-replicas", "closest-adaptive", "learner"}, SetSession: func(s *SessionVars, val string) error {
if strings.EqualFold(val, "follower") {
s.SetReplicaRead(kv.ReplicaReadFollower)
} else if strings.EqualFold(val, "leader-and-follower") {
Expand All @@ -1814,6 +1814,8 @@ var defaultSysVars = []*SysVar{
s.SetReplicaRead(kv.ReplicaReadClosestAdaptive)
} else if strings.EqualFold(val, "learner") {
s.SetReplicaRead(kv.ReplicaReadLearner)
} else if strings.EqualFold(val, "prefer-leader") {
s.SetReplicaRead(kv.ReplicaReadPreferLeader)
}
return nil
}},
Expand Down
2 changes: 2 additions & 0 deletions store/driver/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func GetTiKVReplicaReadType(t kv.ReplicaReadType) storekv.ReplicaReadType {
return storekv.ReplicaReadMixed
case kv.ReplicaReadLearner:
return storekv.ReplicaReadLearner
case kv.ReplicaReadPreferLeader:
return storekv.ReplicaReadPreferLeader
}
return 0
}

0 comments on commit f081d66

Please sign in to comment.