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

ddl: Support flashback schema #37438

Merged
merged 11 commits into from
Oct 19, 2022
Merged

Conversation

erwadba
Copy link
Contributor

@erwadba erwadba commented Aug 29, 2022

What problem does this PR solve?

Issue Number: close #20463

Problem Summary:

What is changed and how it works?

1.Add RecoverSchemaInfo struct contains SchemaInfo and TableInfo.
2.Add recoverSchema code logical like the recovertable .

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
mysql> drop database m;
Query OK, 0 rows affected (0.43 sec)
mysql> create database m;
Query OK, 0 rows affected (0.20 sec)
mysql> use m;
Database changed
mysql> CREATE TABLE t(id int PRIMARY KEY AUTO_INCREMENT, c int);
Query OK, 0 rows affected (0.19 sec)
mysql> INSERT INTO t(c) VALUES (1);
Query OK, 1 row affected (0.03 sec)
mysql> INSERT INTO t(c) VALUES (2);
Query OK, 1 row affected (0.01 sec)
mysql> drop database m;
Query OK, 0 rows affected (0.42 sec)
mysql> flashback database m;
Query OK, 0 rows affected (0.97 sec)
mysql> use m ;
Database changed
mysql> select * from t;
+----+------+
| id | c    |
+----+------+
|  1 |    1 |
|  2 |    2 |
+----+------+
2 rows in set (0.01 sec)
mysql>

Side effects

  • N/A

Documentation

  • N/A

Release note

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

Add support `flashback database` command.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 29, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Defined2014
  • xhebox

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 the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 29, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Aug 29, 2022

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 29, 2022
@erwadba erwadba mentioned this pull request Aug 29, 2022
3 tasks
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 29, 2022

@xhebox xhebox self-requested a review August 29, 2022 07:54
// RecoverSchema implements the DDL interface.
func (d Checker) RecoverSchema(ctx sessionctx.Context, recoverSchemaInfo *ddl.RecoverSchemaInfo) (err error) {
//TODO implement me
panic("implement me")
Copy link
Member

Choose a reason for hiding this comment

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

@lance6716 Could you give some descriptions/suggestions on the semantic of RecoverSchema of Checker/SchemaTracker?

I can see that some tools integration tests failed because of this: https://github.com/pingcap/tidb/runs/8089302161

Copy link
Contributor

Choose a reason for hiding this comment

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

Can return nil. Because SchemaTracker is used to track MySQL DDL, and MySQL will not generate RecoverSchema.

Copy link
Contributor

Choose a reason for hiding this comment

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

Dumpling tests have started to fail several days ago, not related to Checker/SchemaTracker

Copy link
Member

Choose a reason for hiding this comment

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

Dumpling tests have started to fail several days ago, not related to Checker/SchemaTracker

Got it, thanks for the update.

ddl/table.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 1, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 2, 2022
ddl/schematracker/checker.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 7, 2022
ddl/schema.go Outdated
recoverSchemaInfo *RecoverSchemaInfo
recoverSchemaCheckFlag int64
)
const checkFlagIndexInJobArgs = 1 // The index of `recoverSchemaCheckFlag` in job arg list.
Copy link
Member

Choose a reason for hiding this comment

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

Please change it to global level so that it could be shared by different functions(like this one and onRecoverTable).

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. PTAL ,Thx~

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2022
@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 Oct 13, 2022
@Defined2014
Copy link
Contributor

Defined2014 commented Oct 13, 2022

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.2 out of 3 committers have signed the CLA.✅ erwadba✅ Defined2014❌ root

root seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@erwadba Seems had some root related commits, maybe you could rebase this PR and update the commit author.

maybe could use script below

git filter-branch --force --env-filter '
if [ "$GIT_AUTHOR_NAME" = "root" ]
then
export GIT_AUTHOR_NAME="erwadba"
export GIT_AUTHOR_EMAIL="erwadba@hotmail.com"
fi
' 826c15c8..HEAD

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@xhebox
Copy link
Contributor

xhebox commented Oct 19, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 25e0bc4

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 19, 2022
@Defined2014
Copy link
Contributor

/run-build

@Defined2014
Copy link
Contributor

/run-unit-test

@ti-chi-bot ti-chi-bot merged commit 300d9e7 into pingcap:master Oct 19, 2022
@Defined2014
Copy link
Contributor

Hi @erwadba, could you add a doc for this feature, just like https://docs.pingcap.com/zh/tidb/stable/sql-statement-flashback-table#flashback-table do.

@erwadba erwadba deleted the support_flashback_schema branch February 22, 2023 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. 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.

FLASHBACK DATABASE command in feature
7 participants