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

br: Compatibility problem between br and TiDB for DDLs about attribute in Incremental Backup #29360

Merged
merged 9 commits into from
Nov 4, 2021

Conversation

joccau
Copy link
Member

@joccau joccau commented Nov 2, 2021

What problem does this PR solve?

Because TiDB V5.3.0 support TableAttributes and TablePartitionAttributes.
Incremental Backup need skip these DDLs to be compatible with previous br versions.

Issue Number: close #29359

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Manual test (add detailed scripts or steps below)
Test steps
  • Make full backup in the cluster of v5.3.0-alpha TiKV with v5.3.0-alpha br
  • Do DDL sql alter table t attributes ”merge_option=allow”
  • Make incremental backup in the cluster of V5.3.0
  • Make full restore in the cluster of v5.0.0 TiKV with v5.0.0 br
  • Make incremental restore in the cluster of V5.0.0
All of above steps succeed

Release note

Incremental Backup need skip DDLs about attribute for compatibility

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 2, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • 3pointer
  • kennytm

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 Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 2, 2021
@joccau
Copy link
Member Author

joccau commented Nov 2, 2021

/cc @kennytm @3pointer @YuJuncen

@joccau
Copy link
Member Author

joccau commented Nov 2, 2021

/sig migrate

@joccau
Copy link
Member Author

joccau commented Nov 2, 2021

/component br

@ti-chi-bot ti-chi-bot added the component/br This issue is related to BR of TiDB. label Nov 2, 2021
@kennytm
Copy link
Contributor

kennytm commented Nov 2, 2021

This solution will always skip the attributes even in 5.3 backup → 5.3 restore scenario. I don't think it is a good long-term solution (maybe not even good as a short-term solution).

The ideal way is to copy what pingcap/parser#1287 has done. However, BR fetches the DDL query from the *model.Job structure, whose Query string is filled in using the statement's OriginText() 😱, so fixing Restore() isn't gonna help.

tidb/ddl/ddl.go

Lines 542 to 543 in fff946c

// Get a global job ID and put the DDL job in the queue.
job.Query, _ = ctx.Value(sessionctx.QueryString).(string)

se.SetValue(sessionctx.QueryString, s.OriginText())

(will changing OriginText() to Restore() going to introduce subtle breakages?)

@3pointer
Copy link
Contributor

3pointer commented Nov 3, 2021

This solution will always skip the attributes even in 5.3 backup → 5.3 restore scenario. I don't think it is a good long-term solution (maybe not even good as a short-term solution).

The ideal way is to copy what pingcap/parser#1287 has done. However, BR fetches the DDL query from the *model.Job structure, whose Query string is filled in using the statement's OriginText() 😱, so fixing Restore() isn't gonna help.

tidb/ddl/ddl.go

Lines 542 to 543 in fff946c

// Get a global job ID and put the DDL job in the queue.
job.Query, _ = ctx.Value(sessionctx.QueryString).(string)

se.SetValue(sessionctx.QueryString, s.OriginText())

(will changing OriginText() to Restore() going to introduce subtle breakages?)

another alternative is we handle the parser error during restore, we build a white list and skip some errors in white list

@YuJuncen
Copy link
Contributor

YuJuncen commented Nov 3, 2021

@kennytm I guess we can parse and the restore the query with format.RestoreTiDBSpecialComment when replaying the DDL job?

(Or just do the procedure when we backing up?)

@joccau
Copy link
Member Author

joccau commented Nov 3, 2021

This solution will always skip the attributes even in 5.3 backup → 5.3 restore scenario. I don't think it is a good long-term solution (maybe not even good as a short-term solution).
The ideal way is to copy what pingcap/parser#1287 has done. However, BR fetches the DDL query from the *model.Job structure, whose Query string is filled in using the statement's OriginText() 😱, so fixing Restore() isn't gonna help.

tidb/ddl/ddl.go

Lines 542 to 543 in fff946c

// Get a global job ID and put the DDL job in the queue.
job.Query, _ = ctx.Value(sessionctx.QueryString).(string)

se.SetValue(sessionctx.QueryString, s.OriginText())

(will changing OriginText() to Restore() going to introduce subtle breakages?)

another alternative is we handle the parser error during restore, we build a white list and skip some errors in white list

we should fix it in v5.0.0 with the method of "skip some errors in white list when restore", and do nothing in v5.3.0.

@joccau joccau changed the title br: Incremental Backup need skip DDLs about attribute for compatibility br: Compatibility problem between br and TiDB for DDLs about attribute in Incremental Backup Nov 3, 2021
@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2021
@joccau
Copy link
Member Author

joccau commented Nov 4, 2021

/unhold

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2021
@kennytm
Copy link
Contributor

kennytm commented Nov 4, 2021

IMO either we claim that the 5.3 backup won't work on 5.0, or make the 5.3 output compatible with 5.0. Any solution requiring changing 5.0 is no good, why would the user upgrade the existing 5.0 cluster.

@joccau
Copy link
Member Author

joccau commented Nov 4, 2021

/run-integration-br-test

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

rest lgtm

you might need a test case 🤔.

br/pkg/backup/client.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 4, 2021
Signed-off-by: joccau <zak.zhao@pingcap.com>
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 4, 2021
@joccau
Copy link
Member Author

joccau commented Nov 4, 2021

/run-integration-br-test

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 4, 2021
@YuJuncen
Copy link
Contributor

YuJuncen commented Nov 4, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 91cbade

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 4, 2021
@ti-chi-bot ti-chi-bot merged commit d80efa5 into pingcap:master Nov 4, 2021
@joccau
Copy link
Member Author

joccau commented Nov 5, 2021

/cherrypick release-5.3

@joccau joccau deleted the fix-skipDDL-attribute branch November 5, 2021 02:36
@rleungx
Copy link
Member

rleungx commented Nov 5, 2021

/label needs-cherry-pick-5.3

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 label Nov 5, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Nov 5, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.3 in PR #29493

ti-chi-bot pushed a commit that referenced this pull request Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/br This issue is related to BR of TiDB. needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

br: Incremental restore failed to execute DDL which contains tableAttributes in the cluster v5.0
7 participants