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

grpc_service: add ManuallyChangePeer and ManuallyChangeMultiPeers. #8266

Closed
wants to merge 6 commits into from

Conversation

LykxSassinator
Copy link
Contributor

@LykxSassinator LykxSassinator commented Jun 6, 2024

What problem does this PR solve?

Issue Number: Ref tikv/tikv#15292 proto: pingcap/kvproto#1250

What is changed and how does it work?

Make `grpc_service` support manually add / remove peers by `ManuallyChangePeer` and `ManuallyChangeMultiPeers`.

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

Add extra apis `ManuallyChangePeer` and `ManuallyChangeMultiPeers` for `grpc_service` to support manually add / remove peers.

make `grpc_service` support manually add / remove peers by `ManuallyChangePeer` and `ManuallyChangeMultiPeers`.

Signed-off-by: lucasliang <[email protected]>
Copy link
Contributor

ti-chi-bot bot commented Jun 6, 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.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-triage-completed dco-signoff: yes Indicates the PR's author has signed the dco. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 6, 2024
@ti-chi-bot ti-chi-bot bot requested review from HuSharp and rleungx June 6, 2024 11:47
@ti-chi-bot ti-chi-bot bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 6, 2024
@LykxSassinator
Copy link
Contributor Author

/cc @nolouch

@ti-chi-bot ti-chi-bot bot requested a review from nolouch June 6, 2024 11:47
@@ -2,6 +2,8 @@ module github.com/tikv/pd/client

go 1.21

replace github.com/pingcap/kvproto => github.com/LykxSassinator/kvproto v0.0.0-20240605160713-4dfe4594d6ca
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be cleared after pingcap/kvproto#1250 is merged.

@@ -6,6 +6,7 @@ go 1.21
// kvproto at the same time. You can run `go mod tidy` to make it replaced with go-mod style specification.
// After the PR to kvproto is merged, remember to comment this out and run `go mod tidy`.
// replace github.com/pingcap/kvproto => github.com/$YourPrivateRepo $YourPrivateBranch
replace github.com/pingcap/kvproto => github.com/LykxSassinator/kvproto v0.0.0-20240605160713-4dfe4594d6ca
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto.

@@ -3,6 +3,7 @@ module github.com/tikv/pd/tools
go 1.21

replace (
github.com/pingcap/kvproto => github.com/LykxSassinator/kvproto v0.0.0-20240605160713-4dfe4594d6ca
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto.

@@ -3000,6 +3001,78 @@ func (s *GrpcServer) GetExternalTimestamp(ctx context.Context, request *pdpb.Get
}, nil
}

// ManuallyChangePeer implements gRPC PDServer.
func (s *GrpcServer) ManuallyChangePeer(ctx context.Context, request *pdpb.ChangePeerRequest) (*pdpb.ChangePeerResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Any input about the RPC name? @nolouch @rleungx

Copy link
Contributor

@nolouch nolouch Jun 12, 2024

Choose a reason for hiding this comment

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

Can we only report the purpose then PD generates operators, like call interface as "ReportDamagedPeer"?

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 u mean using GetDamagedRegionsId?

Not appropriate. The DamagedRegionsId just records the abnormal region, and it's used to delete all of the peers of this region.

But what we need now is "add / remove" a single peer.

Copy link
Contributor

@nolouch nolouch Jun 13, 2024

Choose a reason for hiding this comment

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

I mean the TiKV tells PD which peer is damaged or needs to be cleaned. then PD will log it(better with the
caller source) and add an operator to add/remove it.

Do not directly guide PD on how to do it, tell PD your purpose, and then PD makes the decisions. it prevents some unknown source from abusing it.

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 just needs a simple way to let PD trigger the operator on add or remove peer here. And we've already have Restful API used for add & remove peer, gRPC API is intended to be used as the same purpose here.

Copy link
Contributor

ti-chi-bot bot commented Jun 11, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign lhy1024 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@@ -133,6 +134,11 @@ type RPCClient interface {
// SetExternalTimestamp sets external timestamp
SetExternalTimestamp(ctx context.Context, timestamp uint64) error

// ManuallyChangePeer manually changes the peer of a region.
ManuallyChangePeer(ctx context.Context, regionID uint64, changeType eraftpb.ConfChangeType, peer *metapb.Peer) error
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary? Why not let TiKV handle it? If we are going to use RPC to solve the snapshot problem, we still can not ensure that the operator is executed successfully.

Copy link
Contributor Author

@LykxSassinator LykxSassinator Jun 12, 2024

Choose a reason for hiding this comment

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

It's used to make the operation on add peer / remove peer managed by PD uniformly.

If let TiKV handle it directly, the scheduling on add peer or remove peer will not be perceived by PD, and the check of the scheduler cannot be validated by the store limit and other checking mechanisms.

As for

ensure that the operator is executed successfully.

TiKV will retry the remove peer RPC if the operator does not make senses until this peer is cleared.

Copy link
Contributor

ti-chi-bot bot commented Jun 13, 2024

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456, multiple issues should use full syntax for each issue and be separated by a comma, like: Issue Number: close #123, ref #456.

📖 For more info, you can check the "Linking issues" section in the CONTRIBUTING.md.

@LykxSassinator
Copy link
Contributor Author

This pr can be closed as this RPC is not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

4 participants