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

session: support leader-and-follower for tidb_replica_read #14761

Merged
merged 12 commits into from Feb 14, 2020

Conversation

hicqu
Copy link
Contributor

@hicqu hicqu commented Feb 13, 2020

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.

Signed-off-by: qupeng <qupeng@pingcap.com>
if len(candidates) == 0 {
return r.workTiKVIdx
} else {
return int32(seed) % int32(len(candidates))
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Contributor Author

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>
Copy link
Collaborator

@lysu lysu left a 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

@lysu lysu added component/tikv status/LGT1 Indicates that a PR has LGTM 1. type/enhancement labels Feb 13, 2020
@hicqu
Copy link
Contributor Author

hicqu commented Feb 13, 2020

/run-all-tests

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 14, 2020
tiancaiamao
tiancaiamao previously approved these changes Feb 14, 2020
@tiancaiamao
Copy link
Contributor

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 14, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Feb 14, 2020

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Feb 14, 2020

@hicqu merge failed.

Signed-off-by: qupeng <qupeng@pingcap.com>
@tiancaiamao
Copy link
Contributor

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Feb 14, 2020

/run-all-tests

@tiancaiamao tiancaiamao removed the request for review from lzmhhh123 February 14, 2020 07:01
@tiancaiamao
Copy link
Contributor

/rebuild

@tiancaiamao tiancaiamao merged commit f71425b into pingcap:master Feb 14, 2020
@hicqu hicqu deleted the leader-follower-read branch February 14, 2020 07:38
@@ -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'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lysu @hicqu Seems the comment is not correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants