-
Notifications
You must be signed in to change notification settings - Fork 727
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
client: use ServiceClient for discovery #7611
client: use ServiceClient for discovery #7611
Conversation
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
// GetServiceClient returns the leader/primary ServiceClient if it is healthy. | ||
func (c *pdServiceDiscovery) GetServiceClient() ServiceClient { | ||
leaderClient := c.getLeaderServiceClient() | ||
if c.option.enableForwarding && !leaderClient.Available() { |
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.
What if the leaderClient is nil?
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.
leaderClient will never be nil. If there is no leader in resp, it will return leader address doesn't exist
when updateMember
.
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.
The name is confusing to me. lol
if addr == oldLeader { | ||
return nil | ||
oldLeader := c.getLeaderServiceClient() | ||
if addr == oldLeader.GetAddress() && oldLeader.GetClientConn() != nil { |
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.
Will the oldLeader become nil?
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.
Yes, so GetClientConn()
will check nil.
} else { | ||
changed = true | ||
conn, err := c.GetOrCreateGRPCConn(addr) | ||
follower := newPDServiceClient(addr, leader.GetClientUrls()[0], conn, false) |
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.
leader?
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.
Yes, it will save the address of leader for forward.
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.
Is it possible len(GetClientUrls)==0?
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.
No, it will return before here
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7611 +/- ##
=======================================
Coverage 74.77% 74.77%
=======================================
Files 459 459
Lines 50577 50615 +38
=======================================
+ Hits 37820 37849 +29
- Misses 9402 9414 +12
+ Partials 3355 3352 -3
Flags with carried forward coverage won't be shown. Click here to find out more. |
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
add manual test @rleungx |
func (c *pdServiceDiscovery) checkFollowerHealth(ctx context.Context) { | ||
c.followers.Range(func(key, value any) bool { | ||
// To ensure that the leader's healthy check is not delayed, shorten the duration. | ||
ctx, cancel := context.WithTimeout(ctx, MemberHealthCheckInterval/3) |
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.
why not c.option.timeout
?
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.
MemberHealthCheckInterval
is shorter than defaultPDTimeout
/merge |
@CabinfeverB: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: b2c0b16
|
@CabinfeverB: Your PR was out of date, I have automatically updated it for you. If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: ref #7576
What is changed and how does it work?
Check List
Tests
replace pd client with this PR in TiDB. Kill pd leader pd-0, qps drops to zero during 2s.
compare to v7.5.0
HA behavior is consistent.
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note