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

lightning: fix pd http request using old address #45680

Merged
merged 13 commits into from Aug 1, 2023

Conversation

lichunzhu
Copy link
Contributor

@lichunzhu lichunzhu commented Jul 31, 2023

What problem does this PR solve?

Issue Number: close #43436

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test

Side effects

  • None

Documentation

  • None

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

lightning: fix the problem that lightning can work if all pd in its address is scaled

@ti-chi-bot ti-chi-bot bot added release-note-none needs-cherry-pick-release-6.5 needs-cherry-pick-release-7.1 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 31, 2023
@tiprow
Copy link

tiprow bot commented Jul 31, 2023

Hi @lichunzhu. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@codecov
Copy link

codecov bot commented Jul 31, 2023

Codecov Report

Merging #45680 (52a4250) into master (cede736) will increase coverage by 0.0044%.
Report is 14 commits behind head on master.
The diff coverage is 10.8695%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #45680        +/-   ##
================================================
+ Coverage   73.2119%   73.2164%   +0.0044%     
================================================
  Files          1265       1269         +4     
  Lines        389939     391382      +1443     
================================================
+ Hits         285482     286556      +1074     
- Misses        86154      86441       +287     
- Partials      18303      18385        +82     
Flag Coverage Δ
integration 78.1388% <ø> (?)
unit 73.2079% <10.8695%> (-0.0041%) ⬇️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0359% <ø> (-0.0059%) ⬇️
br 52.0071% <14.7058%> (-0.0004%) ⬇️

@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 31, 2023
@@ -122,7 +123,13 @@ func GetTiKVModeSwitcher(logger *zap.Logger) (local.TiKVModeSwitcher, error) {
if err != nil {
return nil, err
}
return NewTiKVModeSwitcher(tls, tidbCfg.Path, logger), nil
tlsOpt := tls.ToPDSecurityOption()
pdCli, err := pd.NewClientWithContext(ctx, []string{tidbCfg.Path}, tlsOpt)
Copy link
Contributor

Choose a reason for hiding this comment

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

requires close

@@ -294,6 +295,10 @@ func NewImportControllerWithPauser(
if err != nil {
return nil, err
}
pdCli, err := pd.NewClientWithContext(ctx, []string{cfg.TiDB.PdAddr}, tls.ToPDSecurityOption())
Copy link
Contributor

Choose a reason for hiding this comment

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

not closed?

Copy link
Contributor

Choose a reason for hiding this comment

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

other places too, seems not close anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

already addressed in f163612
PTAL again

@lance6716
Copy link
Contributor

rest lgtm. Please address existing comments

@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 Jul 31, 2023
@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 Jul 31, 2023
@lichunzhu
Copy link
Contributor Author

/test check-dev2

@tiprow
Copy link

tiprow bot commented Jul 31, 2023

@lichunzhu: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

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.

@lichunzhu
Copy link
Contributor Author

/test check-dev2

@tiprow
Copy link

tiprow bot commented Jul 31, 2023

@lichunzhu: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

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.

@tiprow
Copy link

tiprow bot commented Aug 1, 2023

@lichunzhu: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

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.

@lichunzhu
Copy link
Contributor Author

/retest

2 similar comments
@lichunzhu
Copy link
Contributor Author

/retest

@lichunzhu
Copy link
Contributor Author

/retest

@lance6716
Copy link
Contributor

/lgtm

@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716

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
Copy link

ti-chi-bot bot commented Aug 1, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-01 06:31:17.354936762 +0000 UTC m=+166961.297285286: ☑️ agreed by D3Hunter.
  • 2023-08-01 09:38:26.536072868 +0000 UTC m=+178190.478421391: ☑️ agreed by lance6716.

@lichunzhu
Copy link
Contributor Author

/run-br-integration-tests

@ti-chi-bot ti-chi-bot bot merged commit 9c213aa into pingcap:master Aug 1, 2023
16 of 22 checks passed
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 1, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 1, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@lichunzhu
Copy link
Contributor Author

/cherry-pick release-7.3

@ti-chi-bot
Copy link
Member

@lichunzhu: new pull request created to branch release-7.3: #45737.

In response to this:

/cherry-pick release-7.3

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.

@lichunzhu
Copy link
Contributor Author

/run-br-integration-test

@lichunzhu lichunzhu deleted the fixLightningAutoSync branch August 1, 2023 13:57
@mittalrishabh
Copy link
Contributor

This PR seems incomplete to me. Why we are not using leader during scatter and split in client.go.

@lance6716
Copy link
Contributor

This PR seems incomplete to me. Why we are not using leader during scatter and split in client.go.

Hi, do you mean

func sendSplitRegionRequest(ctx context.Context, c *pdClient, regionInfo *RegionInfo,
keys [][]byte, splitErrors *error, retry int) (bool, *kvrpcpb.SplitRegionResponse, error) {
var peer *metapb.Peer
// scanRegions may return empty Leader in https://github.com/tikv/pd/blob/v4.0.8/server/grpc_service.go#L524
// so wee also need check Leader.Id != 0
if regionInfo.Leader != nil && regionInfo.Leader.Id != 0 {
peer = regionInfo.Leader

We have used the region leader from given regionInfo

@mittalrishabh
Copy link
Contributor

mittalrishabh commented Sep 10, 2023

This PR seems incomplete to me. Why we are not using leader during scatter and split in client.go.

Hi, do you mean

func sendSplitRegionRequest(ctx context.Context, c *pdClient, regionInfo *RegionInfo,
keys [][]byte, splitErrors *error, retry int) (bool, *kvrpcpb.SplitRegionResponse, error) {
var peer *metapb.Peer
// scanRegions may return empty Leader in https://github.com/tikv/pd/blob/v4.0.8/server/grpc_service.go#L524
// so wee also need check Leader.Id != 0
if regionInfo.Leader != nil && regionInfo.Leader.Id != 0 {
peer = regionInfo.Leader

We have used the region leader from given regionInfo

Never mind. I misinterpreted. I suppose any grpc request through pd client goes to leader. This PR is for http request only. Is that right ?

@lance6716
Copy link
Contributor

lance6716 commented Sep 11, 2023

Yes. The PD client interface https://github.com/tikv/pd/blob/d031342b4e104a3ba21812253ad84f5576aea994/client/client.go#L79 will internally choose current leader to send the request (or send to followers when network partition https://github.com/tikv/pd/blob/d031342b4e104a3ba21812253ad84f5576aea994/client/client.go#L804)

But in some usage we don't use the Client interface, for example, we want to peek the leader address and use HTTP API. That's the scope of this PR and #46726 .

And I have opened issue tikv/pd#7063 at PD repo to discuss about the usability of Client interface. Welcome to discuss in the new issue. This PR is closed and no other developers will notice our discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightning does not use auto-sync and fails when the PD cluster address changed
7 participants