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: support getting region with buckets #4699

Merged
merged 7 commits into from
Mar 7, 2022

Conversation

youjiali1995
Copy link
Contributor

What problem does this PR solve?

Issue Number: Close #4698

What is changed and how it works?

Update [kvproto](https://github.com/pingcap/kvproto/pull/865) and PD client to support getting region with buckets.

Check List

Tests

  • No code

Code changes

Side effects

Related changes

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 3, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bufferflies
  • nolouch

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 Mar 3, 2022
@ti-chi-bot ti-chi-bot requested review from JmPotato and rleungx March 3, 2022 06:15
@youjiali1995
Copy link
Contributor Author

@bufferflies PTAL

@youjiali1995 youjiali1995 force-pushed the update-kvproto-for-buckets branch 2 times, most recently from 870337d to 0f5b1f5 Compare March 3, 2022 06:45
Signed-off-by: youjiali1995 <[email protected]>
@youjiali1995 youjiali1995 force-pushed the update-kvproto-for-buckets branch from 0f5b1f5 to e6dbfeb Compare March 3, 2022 07:23
client/client.go Outdated
@@ -76,13 +77,13 @@ type Client interface {
// taking care of region change.
// Also it may return nil if PD finds no Region for the key temporarily,
// client should retry later.
GetRegion(ctx context.Context, key []byte) (*Region, error)
GetRegion(ctx context.Context, key []byte, needBuckets bool) (*Region, error)
Copy link
Member

Choose a reason for hiding this comment

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

Is it a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Another way is to add GetRegionAndBucket()/GetPrevRegionAndBucket()/GetRegionAndBucketByID(), but there are many places the Client interface is implemented for a mock client, it's also a breaking change and doesn't reduce the workload. Since the main(maybe the only one) user of PD client is client-go and TiDB, I think we can choose either way to utilize the new interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we use the option pattern. Or can we put the option into context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I will use the option pattern.

@bufferflies
Copy link
Contributor

how about add some unit test for needBuckets is true?

@youjiali1995
Copy link
Contributor Author

how about add some unit test for needBuckets is true?

I don't know how to do it when the server doesn't support buckets now. I depend on you to test it...

Signed-off-by: youjiali1995 <[email protected]>
@youjiali1995 youjiali1995 force-pushed the update-kvproto-for-buckets branch from 722fea3 to 4bf8d46 Compare March 3, 2022 08:27
Signed-off-by: youjiali1995 <[email protected]>
@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #4699 (8135954) into master (7e4cf2e) will increase coverage by 0.01%.
The diff coverage is 76.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4699      +/-   ##
==========================================
+ Coverage   74.96%   74.97%   +0.01%     
==========================================
  Files         284      284              
  Lines       27877    27888      +11     
==========================================
+ Hits        20898    20910      +12     
- Misses       5106     5113       +7     
+ Partials     1873     1865       -8     
Flag Coverage Δ
unittests 74.97% <76.47%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
client/client.go 67.44% <76.47%> (-1.34%) ⬇️
pkg/errs/errs.go 75.00% <0.00%> (-25.00%) ⬇️
server/tso/local_allocator.go 64.86% <0.00%> (-13.52%) ⬇️
server/schedulers/shuffle_hot_region.go 55.55% <0.00%> (-10.11%) ⬇️
pkg/etcdutil/etcdutil.go 82.35% <0.00%> (-2.36%) ⬇️
server/config/persist_options.go 92.48% <0.00%> (-1.13%) ⬇️
server/cluster/coordinator.go 74.17% <0.00%> (-0.95%) ⬇️
server/encryptionkm/key_manager.go 72.90% <0.00%> (-0.80%) ⬇️
server/grpc_service.go 51.10% <0.00%> (-0.68%) ⬇️
... and 11 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 7e4cf2e...8135954. Read the comment docs.

@youjiali1995
Copy link
Contributor Author

@disksing @bufferflies PTAL again, thanks!

go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
Copy link
Contributor

Choose a reason for hiding this comment

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

why degrade it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

go mod tidy did it.

Copy link
Contributor

@bufferflies bufferflies left a comment

Choose a reason for hiding this comment

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

the rest LGTM.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 7, 2022
Copy link
Member

@AndreMouche AndreMouche left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link
Member

@AndreMouche: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

LGTM

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.

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot removed the status/LGT1 Indicates that a PR has LGTM 1. label Mar 7, 2022
@ti-chi-bot ti-chi-bot added the status/LGT2 Indicates that a PR has LGTM 2. label Mar 7, 2022
@nolouch
Copy link
Contributor

nolouch commented Mar 7, 2022

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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: 8135954

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 7, 2022
@ti-chi-bot ti-chi-bot merged commit 841fa61 into tikv:master Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Client supports getting region with buckets
7 participants