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

*: fix member race problem #6070

Merged
merged 4 commits into from Mar 6, 2023
Merged

*: fix member race problem #6070

merged 4 commits into from Mar 6, 2023

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Mar 2, 2023

What problem does this PR solve?

Issue Number: Ref #6069.

What is changed and how does it work?

#5310 did some changes to the header but for GetMembers, we may encounter a kind of situation: The server hasn't served but the request is coming. Because the cluster id could not be initialized, there might be a data race when reading/writing the cluster id.

Check List

Tests

  • Unit test

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 2, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato

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.

@rleungx
Copy link
Member Author

rleungx commented Mar 2, 2023

@HuSharp PTAL

return &pdpb.GetMembersResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, err.Error()),
}, nil
return nil, status.Errorf(codes.Unknown, err.Error())
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 TiKV may relays on this error to retry, changing it to a gRPC error seems will change the behavior.

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, updated.

Copy link
Member

@JmPotato JmPotato left a comment

Choose a reason for hiding this comment

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

Basically LGTM.

@@ -102,7 +102,12 @@ func (s *GrpcServer) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb
members, err := s.Server.GetMembers()
if err != nil {
return &pdpb.GetMembersResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, err.Error()),
Header: &pdpb.ResponseHeader{
Error: &pdpb.Error{
Copy link
Member

Choose a reason for hiding this comment

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

Will the missing cluster ID field be a problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

I distinguish the two situations in the original s.Server.GetMembers().

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 2, 2023
@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.05 ⚠️

Comparison is base (c40e319) 74.00% compared to head (63f7b4c) 73.96%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6070      +/-   ##
==========================================
- Coverage   74.00%   73.96%   -0.05%     
==========================================
  Files         383      383              
  Lines       37874    37882       +8     
==========================================
- Hits        28030    28018      -12     
- Misses       7386     7400      +14     
- Partials     2458     2464       +6     
Flag Coverage Δ
unittests 73.96% <100.00%> (-0.05%) ⬇️

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

Impacted Files Coverage Δ
server/grpc_service.go 49.12% <100.00%> (+0.36%) ⬆️
server/server.go 75.00% <100.00%> (+0.09%) ⬆️
pkg/mcs/discovery/register.go 53.48% <0.00%> (-18.61%) ⬇️
pkg/utils/metricutil/metricutil.go 82.75% <0.00%> (-10.35%) ⬇️
...erver/config/service_middleware_persist_options.go 91.66% <0.00%> (-8.34%) ⬇️
pkg/storage/endpoint/meta.go 63.63% <0.00%> (-4.55%) ⬇️
pkg/tso/local_allocator.go 71.62% <0.00%> (-4.06%) ⬇️
server/schedule/labeler/labeler.go 76.77% <0.00%> (-3.88%) ⬇️
server/schedule/schedulers/shuffle_hot_region.go 56.66% <0.00%> (-3.34%) ⬇️
pkg/utils/etcdutil/etcdutil.go 78.04% <0.00%> (-2.44%) ⬇️
... and 14 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.

Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
@rleungx rleungx requested a review from HuSharp March 3, 2023 07:02
@ti-chi-bot
Copy link
Member

@HuSharp: 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:

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

@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:

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.

@rleungx
Copy link
Member Author

rleungx commented Mar 6, 2023

/run-check-issue-triage-complete

@rleungx
Copy link
Member Author

rleungx commented Mar 6, 2023

/merge

@ti-chi-bot
Copy link
Member

@rleungx: 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

@rleungx: /merge in this pull request requires 2 approval(s).

In response to this:

/merge

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.

@rleungx rleungx added the require-LGT1 Indicates that the PR requires an LGTM. label Mar 6, 2023
@rleungx
Copy link
Member Author

rleungx commented Mar 6, 2023

/merge

@ti-chi-bot
Copy link
Member

@rleungx: 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: f696bce

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 6, 2023
@ti-chi-bot
Copy link
Member

@rleungx: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 merged commit 312e5b4 into tikv:master Mar 6, 2023
18 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #6091.

ti-chi-bot added a commit that referenced this pull request Mar 6, 2023
ref #5310, ref #6069, ref #6070

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: Ryan Leung <rleungx@gmail.com>
@rleungx rleungx deleted the fix-race9 branch May 17, 2023 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.5 release-note-none require-LGT1 Indicates that the PR requires an LGTM. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants