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

client, tests: make client check if the cluster ID matches #5281

Merged
merged 2 commits into from
Jul 7, 2022

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Jul 6, 2022

Signed-off-by: JmPotato ghzpotato@gmail.com

What problem does this PR solve?

Issue Number: Close #5278.

What is changed and how does it work?

Let the client check if the cluster ID matches during the initialization and updating.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
@JmPotato JmPotato added the component/client Client logic. label Jul 6, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 6, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Jul 6, 2022
@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #5281 (ae0b365) into master (de5cf5b) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #5281      +/-   ##
==========================================
+ Coverage   75.63%   75.65%   +0.01%     
==========================================
  Files         310      310              
  Lines       30718    30730      +12     
==========================================
+ Hits        23234    23249      +15     
- Misses       5483     5492       +9     
+ Partials     2001     1989      -12     
Flag Coverage Δ
unittests 75.65% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
client/client.go 68.51% <ø> (-0.11%) ⬇️
client/base_client.go 82.03% <100.00%> (+2.65%) ⬆️
pkg/dashboard/keyvisual/input/core.go 0.00% <0.00%> (-33.34%) ⬇️
server/schedulers/shuffle_hot_region.go 55.55% <0.00%> (-10.11%) ⬇️
server/tso/local_allocator.go 64.86% <0.00%> (-6.76%) ⬇️
server/id/id.go 76.19% <0.00%> (-4.77%) ⬇️
server/schedule/labeler/rules.go 87.50% <0.00%> (-2.28%) ⬇️
server/storage/hot_region_storage.go 78.14% <0.00%> (-1.10%) ⬇️
server/region_syncer/server.go 86.41% <0.00%> (-1.09%) ⬇️
server/cluster/coordinator.go 70.45% <0.00%> (-0.59%) ⬇️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de5cf5b...ae0b365. Read the comment docs.


// Check the cluster ID.
if err == nil && members.GetHeader().GetClusterId() != c.clusterID {
err = errs.ErrClientUpdateMember.FastGenByArgs("cluster id does not match")
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use "errors.WithStack(errUnmatchedClusterID)"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's because errUnmatchedClusterID is an error that will be returned to the upper caller, e.g, the TiDB. So it's not wrapped by the errs definition. However, in this function, it's an error that will be logged out, so it's necessary to wrap it first.

@crelax
Copy link

crelax commented Jul 7, 2022

Hi, may I ask what's the expected behavior if some PD addresses are not connectable?

@JmPotato
Copy link
Member Author

JmPotato commented Jul 7, 2022

Hi, may I ask what's the expected behavior if some PD addresses are not connectable?

I didn't add special handling logic for this because it's hard to tell if "unreachable" is a temporary state or a permanent error from the client's point of view. Given the availability, as long as there is a working PD address in it, then I think the client is ready to start. It is unacceptable to deny the entire service just because of an unreachable URL.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 7, 2022
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 7, 2022
@JmPotato
Copy link
Member Author

JmPotato commented Jul 7, 2022

/merge

@ti-chi-bot
Copy link
Member

@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: ae0b365

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 7, 2022
@ti-chi-bot ti-chi-bot merged commit 0c3303e into tikv:master Jul 7, 2022
@JmPotato JmPotato deleted the client_check_cluster_id branch July 7, 2022 04:36
@crelax
Copy link

crelax commented Jul 7, 2022

Hi, may I ask what's the expected behavior if some PD addresses are not connectable?

I didn't add special handling logic for this because it's hard to tell if "unreachable" is a temporary state or a permanent error from the client's point of view. Given the availability, as long as there is a working PD address in it, then I think the client is ready to start. It is unacceptable to deny the entire service just because of an unreachable URL.

Got it. Thx for the explanation!

CabinfeverB pushed a commit to CabinfeverB/pd that referenced this pull request Jul 14, 2022
close tikv#5278

Let the client check if the cluster ID matches during the initialization and updating.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
CabinfeverB pushed a commit to CabinfeverB/pd that referenced this pull request Jul 14, 2022
close tikv#5278

Let the client check if the cluster ID matches during the initialization and updating.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
ethercflow pushed a commit to ethercflow/pd that referenced this pull request Jul 15, 2022
close tikv#5278

Let the client check if the cluster ID matches during the initialization and updating.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/client Client logic. release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lacking legality checks for pdAddrs in pd.NewClientWithContext()
6 participants