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

mcs: support forwarding requests for tso server #6130

Merged
merged 20 commits into from
Mar 16, 2023
Merged

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Mar 9, 2023

What problem does this PR solve?

Issue Number: Ref #5836

What is changed and how does it work?

  1. support forwarding requests for tso server when api server is disable for tso
  2. add switch in api server for tso
  3. add test cluster for api server

Check List

Tests

  • Unit test

Release note

None.

Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 9, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • 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.

@lhy1024
Copy link
Contributor Author

lhy1024 commented Mar 9, 2023

cc @binshi-bing @rleungx

server/grpc_service.go Outdated Show resolved Hide resolved
tests/mcs/tso/server_test.go Outdated Show resolved Hide resolved
Signed-off-by: lhy1024 <admin@liudos.us>
@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Patch coverage: 82.53% and project coverage change: +0.11 🎉

Comparison is base (266c021) 74.31% compared to head (21bfd68) 74.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6130      +/-   ##
==========================================
+ Coverage   74.31%   74.42%   +0.11%     
==========================================
  Files         393      393              
  Lines       38353    38446      +93     
==========================================
+ Hits        28502    28614     +112     
+ Misses       7317     7288      -29     
- Partials     2534     2544      +10     
Flag Coverage Δ
unittests 74.42% <82.53%> (+0.11%) ⬆️

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

Impacted Files Coverage Δ
pkg/mcs/tso/server/server.go 51.46% <ø> (+0.66%) ⬆️
pkg/tso/allocator_manager.go 65.80% <ø> (-0.71%) ⬇️
pkg/utils/apiutil/serverapi/middleware.go 63.07% <0.00%> (+1.53%) ⬆️
server/api/tso.go 50.00% <ø> (ø)
server/api/member.go 53.12% <60.00%> (+0.74%) ⬆️
server/server.go 75.76% <74.28%> (+1.55%) ⬆️
server/grpc_service.go 51.68% <85.95%> (+2.48%) ⬆️
tests/mcs/testutil.go 100.00% <100.00%> (ø)

... and 26 files with indirect coverage changes

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 in Codecov by Sentry.
📢 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 Mar 10, 2023
Copy link
Contributor

@binshi-bing binshi-bing left a comment

Choose a reason for hiding this comment

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

left some comments

pkg/mcs/tso/server/server.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 10, 2023
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
@@ -222,33 +247,38 @@ type tsoRequest struct {
stream pdpb.PD_TsoServer
}

func (s *GrpcServer) dispatchTSORequest(ctx context.Context, request *tsoRequest, forwardedHost string, doneCh <-chan struct{}, errCh chan<- error) {
func (s *GrpcServer) dispatchTSORequest(ctx context.Context, request *tsoRequest, forwardedHost string, doneCh <-chan struct{}, errCh chan<- error, workingMCS bool) {
Copy link
Member

Choose a reason for hiding this comment

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

How about using a clearer name instead of workingMCS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a good idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

The difference inside of dispatchTSORequest is actually about which protocolbuf to use, pdpb or tsopb? How about 'tsoProto bool'. The tso service itself needs to use this framework too.

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

… avoid panic

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024
Copy link
Contributor Author

lhy1024 commented Mar 10, 2023

cc@binshi-bing @rleungx

server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Outdated Show resolved Hide resolved
server/grpc_service.go Show resolved Hide resolved
done := make(chan struct{})
ctx, cancel := context.WithTimeout(s.ctx, defaultTSOProxyTimeout)
go checkStream(ctx, cancel, done)
forwardStream, err := tsopb.NewTSOClient(client).Tso(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

What if the primary changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will change by

ok, forwardedHost, err := s.GetServicePrimaryAddr(ctx, "tso")

Copy link
Member

Choose a reason for hiding this comment

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

How about the original stream, will it be closed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

original stream? with pdpb proto?

Copy link
Member

Choose a reason for hiding this comment

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

If we create a stream to A, after that, B becomes primary. Then, we create a stream to B. What about A now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its behaviour will be similar with other stream in clientConns

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but do we need to consider that?

Copy link
Contributor Author

@lhy1024 lhy1024 Mar 15, 2023

Choose a reason for hiding this comment

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

The current number of streams is directly related to the TSO server, the current number is not much, I will add a TODO first. and do we need to think about the EOF issue, do we keep a TODO too?

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
Comment on lines 379 to 380
KeyspaceId: utils.DefaultKeySpaceGroupID,
KeyspaceGroupId: utils.DefaultKeySpaceGroupID,
Copy link
Member

Choose a reason for hiding this comment

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

Do we need them now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just filled it with default value

Copy link
Member

Choose a reason for hiding this comment

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

I think there is no need to do it for now.

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 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 Mar 14, 2023
done := make(chan struct{})
ctx, cancel := context.WithTimeout(s.ctx, defaultTSOProxyTimeout)
go checkStream(ctx, cancel, done)
forwardStream, err := tsopb.NewTSOClient(client).Tso(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to create a stream here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will cache it until forward-host changed

Comment on lines +379 to +380
KeyspaceId: utils.DefaultKeySpaceID,
KeyspaceGroupId: utils.DefaultKeySpaceGroupID,
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need these two for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only filled it

Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 16, 2023
Copy link
Contributor

@binshi-bing binshi-bing 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

@binshi-bing: 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.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 16, 2023
@ti-chi-bot
Copy link
Member

@lhy1024: PR needs rebase.

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.

1 similar comment
@ti-chi-bot
Copy link
Member

@lhy1024: PR needs rebase.

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.

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024 lhy1024 removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Mar 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: 21bfd68

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

5 participants