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: add backoff mechanism for gRPC client #7863

Closed
wants to merge 12 commits into from

Conversation

CabinfeverB
Copy link
Member

@CabinfeverB CabinfeverB commented Mar 1, 2024

What problem does this PR solve?

Issue Number: Close #8047

What is changed and how does it work?

  1. introduce the RPCClinet interface
  2. introduce the BakcofferClinet
  3. the default strategy of BakcoffClinet is that it will unlimitedly retry on leader change error.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Copy link
Contributor

ti-chi-bot bot commented Mar 1, 2024

[REVIEW NOTIFICATION]

This pull request has not been approved.

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.

Copy link
Contributor

ti-chi-bot bot commented Mar 1, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 1, 2024
@ti-chi-bot ti-chi-bot bot requested review from rleungx and Yisaer March 1, 2024 02:14
@ti-chi-bot ti-chi-bot bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 1, 2024
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 29, 2024
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Merging #7863 (9b95c1c) into master (2b8116e) will decrease coverage by 0.40%.
Report is 12 commits behind head on master.
The diff coverage is 7.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7863      +/-   ##
==========================================
- Coverage   77.31%   76.91%   -0.40%     
==========================================
  Files         468      469       +1     
  Lines       60867    61221     +354     
==========================================
+ Hits        47058    47088      +30     
- Misses      10273    10595     +322     
- Partials     3536     3538       +2     
Flag Coverage Δ
unittests 76.91% <7.60%> (-0.40%) ⬇️

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

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 9, 2024

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: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@CabinfeverB CabinfeverB marked this pull request as ready for review April 10, 2024 03:19
@ti-chi-bot ti-chi-bot bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-linked-issue labels Apr 10, 2024
@CabinfeverB CabinfeverB removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 10, 2024
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@JmPotato JmPotato removed the request for review from Yisaer April 11, 2024 05:55
Comment on lines +39 to +45
if err == errs.ErrClientTSOStreamClosed {
return true
}
errMsg := err.Error()
return strings.Contains(errMsg, errs.NotLeaderErr) ||
strings.Contains(errMsg, errs.MismatchLeaderErr) ||
strings.Contains(errMsg, errs.NotServedErr)
Copy link
Member

Choose a reason for hiding this comment

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

Better unify the checking method in the same way.

@@ -100,7 +100,7 @@ func (s *Service) Tso(stream tsopb.TSO_TsoServer) error {
start := time.Now()
// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
return status.Errorf(codes.Unknown, "server not started")
return ErrNotStarted
Copy link
Member

Choose a reason for hiding this comment

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

This will change codes.Unknown to codes.Unavailable, perhaps it is necessary to evaluate whether there are side effects.

@@ -568,7 +568,7 @@ func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error {
start := time.Now()
// TSO uses leader lease to determine validity. No need to check leader here.
if s.IsClosed() {
return status.Errorf(codes.Unknown, "server not started")
return ErrNotStarted
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

if err := req.bo.ExecWithoutReset(ctx, func() error {
return c.dispatchTSORequestWithFastRetry(req)
}); err != nil {
req.tryDone(err)
Copy link
Member

Choose a reason for hiding this comment

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

This retry might be meaningless if the req.tryDone(err) has been called elsewhere before retrying. We might need to drain it first.

@@ -154,6 +144,25 @@ type Client interface {
GCClient
// ResourceManagerClient manages resource group metadata and token assignment.
ResourceManagerClient
}

// Client is a PD (Placement Driver) RPC client.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Client is a PD (Placement Driver) RPC client.
// Client is a PD (Placement Driver) client.


// baseBackoffClient is a base RPCClient that retries requests using the given backoffer.
// It does not support backoff for GetTSAsync and GetLocalTSAsync.
// baseBackoffClient is mostly used for mock PD client.
Copy link
Member

Choose a reason for hiding this comment

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

what does for mock PD client. mean? can you show a scenario? :)

Copy link
Contributor

ti-chi-bot bot commented Apr 12, 2024

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.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 12, 2024
@CabinfeverB
Copy link
Member Author

It's work that needs to be done, but I don't have time to finish it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce the backoff mechanism for gRPC client
3 participants