-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
session: support leader-and-follower for tidb_replica_read #14761
Conversation
Signed-off-by: qupeng <qupeng@pingcap.com>
store/tikv/region_cache.go
Outdated
if len(candidates) == 0 { | ||
return r.workTiKVIdx | ||
} else { | ||
return int32(seed) % int32(len(candidates)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stores
value are [leader, tiflash, tiflash, follower, follower]
seed
be 2, len(candidates)
be 3 and this method will return idx = 2
then r.getStorePeer
will return a tiflash node in AnyStorePeer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or stores value are [leader, follower(fail), follower(fail), follower(ok), follower(ok)]
have same problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. PTAL.
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please fix CI
/run-all-tests |
LGTM |
/merge |
/run-all-tests |
@hicqu merge failed. |
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
/merge |
/run-all-tests |
/rebuild |
@@ -93,13 +93,14 @@ const ( | |||
ReplicaReadLeader ReplicaReadType = 1 << iota | |||
// ReplicaReadFollower stands for 'read from follower'. | |||
ReplicaReadFollower | |||
// ReplicaReadLearner stands for 'read from learner'. | |||
ReplicaReadLearner | |||
// ReplicaReadMixed stands for 'read from leader and follower and learner'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…4761) Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng qupeng@pingcap.com
What problem does this PR solve?
Currently there is no option to support load balance for TiKV peers, we can only read from leader or followers, not both.
What is changed and how it works?
Support leader-and-follower for tidb_replica_read, which is a simple load balance strategy in all peers of a given region.
Check List
Tests
Unit test
Code changes
Has exported variable/fields change
Side effects
Related changes
Need to cherry-pick to release-4.0-beta.
Release note
support leader-and-follower for tidb_replica_read.