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-stream: implement restore command #31821

Merged
merged 30 commits into from
Feb 11, 2022

Conversation

3pointer
Copy link
Contributor

@3pointer 3pointer commented Jan 19, 2022

What problem does this PR solve?

Issue Number: close #31975

Problem Summary:

  1. implement restore command for stream.
  2. only use table id rewrite rule to perform rewrite.

What is changed and how it works?

  1. add new command br stream restore.
  2. collect meta files and data files from stream backup.
  3. collect the rewrite rule for each data file.

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • YuJuncen
  • joccau

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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 19, 2022
@3pointer 3pointer added component/br This issue is related to BR of TiDB. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 19, 2022
@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 20, 2022
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 21, 2022
@3pointer
Copy link
Contributor Author

3pointer commented Feb 8, 2022

/run-check_dev

@YuJuncen
Copy link
Contributor

YuJuncen commented Feb 9, 2022

/run-integration-br-tests

I have found that with this PR, BR may fail with ChecksumMismatch, because rewrite rule not found:

[2022/02/09 14:20:12.471 +08:00] [WARN] [import.go:444] ["download file skipped"] 
[files="{total=1,files=\"[1_124_41_09fa3589bc1c6a7130c4128b9743212d4989bbc28a4f4f2cb8eecbeeb08425e7_1644387040240_write.sst]\",totalKVs=775255,totalBytes=78180884,totalSize=26541360}"] 
[region="{ID=122,startKey=7480000000000000FF475F728000000000FF34100A0000000000FA,endKey=7480000000000000FF475F728000000000FF3FE60E0000000000FA,epoch=\"conf_ver:1 version:71 \",peers=\"id:123 store_id:1 \"}"] 
[startKey=7480000000000000FF475F728000000000FF34100A0000000000FA] 
[endKey=7480000000000000FF475F728000000000FF3FE60E0000000000FA] 
[file-simple-start=7480000000000000475F72800000000034100A] 
[file-simple-end=7480000000000000475F7280000000003FE60E] 
[error="[BR:KV:ErrKVRewriteRuleNotFound]rewrite rule not found"]

I'm not sure why... FYI

@3pointer
Copy link
Contributor Author

3pointer commented Feb 9, 2022

/run-integration-br-tests

I have found that with this PR, BR may fail with ChecksumMismatch, because rewrite rule not found:

I'm not sure why... FYI

fixed in bd114c5...

@3pointer
Copy link
Contributor Author

3pointer commented Feb 9, 2022

/run-integration-br-tests

1 similar comment
@YuJuncen
Copy link
Contributor

YuJuncen commented Feb 9, 2022

/run-integration-br-tests

@3pointer
Copy link
Contributor Author

3pointer commented Feb 9, 2022

failed to start tiflash is a known issue.

@3pointer
Copy link
Contributor Author

3pointer commented Feb 9, 2022

/run-integration-br-tests

@3pointer
Copy link
Contributor Author

3pointer commented Feb 9, 2022

failed to start tiflash is a known issue.

I guess maybe we should update br-stream with master branch to fix br_tiflash case...

// Rewrites a raw key and returns a encoded key.
// Rewrites an encoded key and returns a encoded key.
func rewriteEncodedKey(key []byte, rewriteRules *RewriteRules) ([]byte, *import_sstpb.RewriteRule) {
if rewriteRules == nil {
Copy link
Member

@joccau joccau Feb 10, 2022

Choose a reason for hiding this comment

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

func rewriteEncodedKey(key []byte, rewriteRules *RewriteRules) ([]byte, *import_sstpb.RewriteRule) {
if rewriteRules == nil || len(key) == 0 {
return key, nil
}
_, rawKey, _ := codec.DecodeBytes(key, nil)
return rewriteRawkey(rawKey, rewriteRules)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@joccau joccau left a comment

Choose a reason for hiding this comment

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

LGTM

@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 Feb 10, 2022
@joccau
Copy link
Member

joccau commented Feb 10, 2022

/run-check_dev

@3pointer
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: cb93ae1

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 10, 2022
@3pointer
Copy link
Contributor Author

/run-mysql-test

@3pointer
Copy link
Contributor Author

/run-check_dev

@3pointer
Copy link
Contributor Author

/run-mysql-test

3 similar comments
@3pointer
Copy link
Contributor Author

/run-mysql-test

@3pointer
Copy link
Contributor Author

/run-mysql-test

@3pointer
Copy link
Contributor Author

/run-mysql-test

@3pointer 3pointer merged commit 66ba596 into pingcap:br-stream Feb 11, 2022
3pointer added a commit to 3pointer/tidb that referenced this pull request Feb 22, 2022
* add restore command

* coarse implement restore
3pointer added a commit to 3pointer/tidb that referenced this pull request Mar 9, 2022
* add restore command

* coarse implement restore
3pointer added a commit that referenced this pull request Mar 21, 2022
* add restore command

* coarse implement restore
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. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ 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.

4 participants