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 : check cluster id and fix data inconsistency #36672

Closed
wants to merge 17 commits into from
Closed

Lightning : check cluster id and fix data inconsistency #36672

wants to merge 17 commits into from

Conversation

AricSu
Copy link
Contributor

@AricSu AricSu commented Jul 28, 2022

Issue Number: close #36653

What problem does this PR solve?

avoid table data inconsistency with table index.

What is changed and how it works?

  1. get cluster id from pd addr of config using /pd/api/v1/cluster;
  2. get pd addr from tidb using select STATUS_ADDRESS from information_schema.cluster_info where type='pd' limit 1;
  3. get cluster id from pd addr of queried from tidb;
  4. compare result of the two value,if it's equal,it will continue.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

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

None

@ti-chi-bot
Copy link
Member

[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 added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 28, 2022
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 28, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jul 28, 2022

br/pkg/pdutil/pd.go Outdated Show resolved Hide resolved
return errors.Trace(err)
}
if id != clusterId {
return errors.Errorf("Failed to match the cluster ID, please check whether pd-addr and status-port")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return errors.Errorf("Failed to match the cluster ID, please check whether pd-addr and status-port")
return errors.Errorf("Failed to match the cluster ID (`%s` from PD, `%s` from TiDB), please check whether pd-addr and status-port are correct", id, clusterId)

br/pkg/pdutil/pd.go Outdated Show resolved Hide resolved
Comment on lines 284 to 285
const queryTiDB = "select substring(type,8) from METRICS_SCHEMA.PD_CLUSTER_METADATA limit 1;"
tidbRow := db.QueryRowContext(ctx, queryTiDB)
Copy link
Contributor

Choose a reason for hiding this comment

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

one potential issue is that this won't work if PD has not enabled their Prometheus port.

Copy link
Contributor Author

@AricSu AricSu Jul 29, 2022

Choose a reason for hiding this comment

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

i have changed the comparing way of cluster id as description.

AricSu and others added 5 commits July 29, 2022 01:48
Co-authored-by: kennytm <kennytm@gmail.com>
Co-authored-by: kennytm <kennytm@gmail.com>
i changed the comparing way of cluster id.
1. get cluster id from pd addr of config using `/pd/api/v1/cluster`;
2. get pd addr from tidb using `select STATUS_ADDRESS from information_schema.cluster_info where type='pd' limit 1;`
3. get cluster id from pd addr of queried from tidb;
4. compare result of the two value,if it's equal,it will continue.
i changed the comparing way of cluster id.
1. get cluster id from pd addr of config using `/pd/api/v1/cluster`;
2. get pd addr from tidb using `select STATUS_ADDRESS from information_schema.cluster_info where type='pd' limit 1;`
3. get cluster id from pd addr of queried from tidb;
4. compare result of the two value,if it's equal,it will continue.
update strconv.Iota to strconv.FormatInt
@AricSu
Copy link
Contributor Author

AricSu commented Jul 28, 2022

/run-build

@AricSu
Copy link
Contributor Author

AricSu commented Aug 1, 2022

/close

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightning imports data to non-destination cluster and leads to index inconsistency with data
5 participants