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

server: refactor the independent service check #8738

Merged
merged 4 commits into from
Oct 25, 2024

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Oct 22, 2024

What problem does this PR solve?

Issue Number: ref #8477.

What is changed and how does it work?

This is a part of #8517.

Check List

Tests

  • Unit test

Release note

None.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 22, 2024
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 74.24242% with 17 lines in your changes missing coverage. Please review.

Project coverage is 75.66%. Comparing base (0402e15) to head (4d6164a).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8738      +/-   ##
==========================================
+ Coverage   70.10%   75.66%   +5.55%     
==========================================
  Files         517      460      -57     
  Lines       79983    72107    -7876     
==========================================
- Hits        56076    54557    -1519     
+ Misses      20339    14056    -6283     
+ Partials     3568     3494      -74     
Flag Coverage Δ
unittests 75.66% <74.24%> (+5.55%) ⬆️

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

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.

the rest LGTM

if name == constant.TSOServiceName {
return true
}
return s.cluster.IsServiceIndependent(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check whether cluster is nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

no need

forwardedHost, ok := s.GetServicePrimaryAddr(stream.Context(), constant.TSOServiceName)
if !ok || len(forwardedHost) == 0 {
tsoStreamErr = errors.WithStack(ErrNotFoundTSOAddr)
forwardCtx, cancelForward, forwardStream, lastForwardedHost, tsoStreamErr, err = s.handleTSOForwarding(forwardCtx, forwardStream, stream, server, request, tsDeadlineCh, lastForwardedHost, cancelForward)
Copy link
Contributor

Choose a reason for hiding this comment

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

There are so many incoming and returning parameters here

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. But I don't find a better way to avoid it.

Copy link
Member

Choose a reason for hiding this comment

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

Is there any benefit after wraping handleTSOForwarding?

Copy link
Member Author

Choose a reason for hiding this comment

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

for upcoming PR

Count: tsopbResp.GetCount(),
Timestamp: tsopbResp.GetTimestamp(),
}
if server != nil {
Copy link
Member

Choose a reason for hiding this comment

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

when should server be nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

We receive both stream pdpb.PD_TsoServer and server *tsoServer as the parameters.

Copy link
Member

Choose a reason for hiding this comment

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

Server seems that will not be nil?🤔

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lhy1024, okJiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-25 02:44:30.36009298 +0000 UTC m=+578271.056883597: ☑️ agreed by lhy1024.
  • 2024-10-25 03:33:57.116545097 +0000 UTC m=+581237.813335702: ☑️ agreed by okJiang.

@rleungx
Copy link
Member Author

rleungx commented Oct 25, 2024

/retest

@ti-chi-bot ti-chi-bot bot merged commit 988c9a3 into tikv:master Oct 25, 2024
25 checks passed
@rleungx rleungx deleted the refactor-independent branch October 25, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants