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
Conversation
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
[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 The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Skipping CI for Draft Pull Request. |
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>
Codecov Report
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
Flags with carried forward coverage won't be shown. Click here to find out more. |
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>
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
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? :)
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. |
It's work that needs to be done, but I don't have time to finish it |
What problem does this PR solve?
Issue Number: Close #8047
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note