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

Implement tso grpc service include both server side and client side in a basic manner #5986

Merged
merged 9 commits into from Feb 16, 2023

Conversation

binshi-bing
Copy link
Contributor

@binshi-bing binshi-bing commented Feb 14, 2023

What problem does this PR solve?

This change implements tso grpc service include both server side and client side.
The corresponding kvproto pr is here pingcap/kvproto#1053.

Issue Number: Ref #5836

What is changed and how does it work?

This pr is split from "basic implement tso gPRC service #5949".

This pr only implements Tso() rpc. SyncMaxTS, GetDCLocationInfo, SetExternalTimestamp and GetExternalTimestamp rpcs depend on the global tso allocator and some other related data structures which are tightly coupled with pdpb messages, so they can't be used by tso service before further refactor on these data structures. And this pr #5949 is the version which refactors and reuses server/grpc_server.go to avoid duplicate code as much as possible.

Implement the server side of the tso grpc service. 

Check List

Tests

  • Unit test
  • Integration test

Code changes

Side effects

  • Introduced duplicate code. The TSO grpc service implementation doesn't reuse the code in PD grpc service because of two reasons:
    1. Some code are code to reuse because they are mixed with pdpb message types.
    1. For now, it isn't clear for how to refactor the tso related data structures and logic in the pkg/tso.
    1. Minimize the change and refactor in server/grpc_server to avoid introducing bugs into PD path.

Related changes

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 14, 2023

[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
Copy link
Member

Hi @binshi-bing. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 kubernetes/test-infra repository.

@codecov
Copy link

codecov bot commented Feb 14, 2023

Codecov Report

Base: 75.15% // Head: 75.15% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (e6d3d0a) compared to base (645ceeb).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5986   +/-   ##
=======================================
  Coverage   75.15%   75.15%           
=======================================
  Files         362      363    +1     
  Lines       36316    36322    +6     
=======================================
+ Hits        27292    27297    +5     
  Misses       6655     6655           
- Partials     2369     2370    +1     
Flag Coverage Δ
unittests 75.15% <0.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
client/client.go 70.75% <ø> (ø)
client/tso_client.go 0.00% <0.00%> (ø)
pkg/mcs/discovery/register.go 53.48% <0.00%> (-18.61%) ⬇️
pkg/utils/tempurl/tempurl.go 45.00% <0.00%> (-15.00%) ⬇️
pkg/election/leadership.go 75.25% <0.00%> (-5.16%) ⬇️
pkg/utils/etcdutil/etcdutil.go 82.17% <0.00%> (-2.33%) ⬇️
pkg/dashboard/adapter/manager.go 79.31% <0.00%> (-2.30%) ⬇️
server/schedule/labeler/rules.go 87.50% <0.00%> (-2.28%) ⬇️
server/region_syncer/client.go 85.82% <0.00%> (-2.24%) ⬇️
pkg/encryption/key_manager.go 70.11% <0.00%> (-1.60%) ⬇️
... and 16 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2023
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2023
pkg/mcs/tso/server/grpc_service.go Outdated Show resolved Hide resolved
pkg/mcs/tso/server/metrics.go Outdated Show resolved Hide resolved
pkg/mcs/tso/server/server.go Outdated Show resolved Hide resolved
@binshi-bing binshi-bing changed the title Implement tso grpc service include both server side and client side Implement tso grpc service include both server side and client side in a basic manner Feb 15, 2023
@binshi-bing binshi-bing force-pushed the implement-tso-service branch 3 times, most recently from 9006faf to 546b7c9 Compare February 15, 2023 07:25
client/tso_client.go Outdated Show resolved Hide resolved
pkg/mcs/tso/server/server.go Show resolved Hide resolved
pkg/mcs/tso/server/server.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2023
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2023
@binshi-bing binshi-bing force-pushed the implement-tso-service branch 2 times, most recently from d198441 to 1ac5635 Compare February 15, 2023 22:46
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
Remove the rpcs SyncMaxTS, GetDCLocationInfo, SetExternalTimestamp and GetExternalTimestamp for now.
These rpcs depend on the global tso allocator and some other related data structures which depend on pdpb messages, so they can't be used by tso service before futher refactor on these data structures.

Signed-off-by: Bin Shi <binshi.bing@gmail.com>
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
TODO: Refactor and share the TSO streaming framework in the PD client.
The implementation in this change is in a very basic manner and only
for testing and integration purpose -- no batching, no async, no pooling,
no forwarding, no retry and no deliberate error handling.

Signed-off-by: Bin Shi <binshi.bing@gmail.com>
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
.golangci.yml Outdated Show resolved Hide resolved
client/tso_client.go Show resolved Hide resolved
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

Mostly, LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 16, 2023
…tLocalTSWithinKeyspaceAsync() in TSOClient.

Remove the basic implementation of GetTSWithinKeyspace for now and will integrate TSOClient with PDClient's TSO batching/forwarding/async/pooling framework in the next few prs.

Signed-off-by: Bin Shi <binshi.bing@gmail.com>
client/go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
tests/client/go.mod Outdated Show resolved Hide resolved
tests/mcs/go.mod Outdated Show resolved Hide resolved
tools/pd-tso-bench/go.mod Outdated Show resolved Hide resolved
Signed-off-by: Bin Shi <binshi.bing@gmail.com>
Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

we need more tests and remove duplicate code later

@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 Feb 16, 2023
@lhy1024
Copy link
Contributor

lhy1024 commented Feb 16, 2023

/merge

@ti-chi-bot
Copy link
Member

@lhy1024: 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: 4228db8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 16, 2023
@lhy1024
Copy link
Contributor

lhy1024 commented Feb 16, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot merged commit 5302e81 into tikv:master Feb 16, 2023
@binshi-bing binshi-bing deleted the implement-tso-service branch May 25, 2023 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test release-note-none 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.

None yet

5 participants