-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: add restore deleted table #7937
Conversation
9580377
to
a2e67cb
Compare
/run-all-tests |
/run-unit-test |
784949e
to
0704d54
Compare
Hi, @crazycs520 , |
0704d54
to
72b921d
Compare
1449460
to
27ee708
Compare
/rebuild |
61e8680
to
bb4f1ed
Compare
db_partition_test |
/run-all-tests |
/run-all-tests |
LGTM. |
/run-all-tests |
1 similar comment
/run-all-tests |
@zimulala PTAL again. |
/run-all-tests |
/run-unit-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to consider ServerStatusInTrans
like other DDLs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-unit-test |
What problem does this PR solve?
Add
admin restore table by job job_id
to restore the deleted table.related proposal: #7383
related parser PR: pingcap/parser#85, pingcap/parser#172
What is changed ?
Add a new ddl type job:
restore table
to do restore.the function of
restore table
almost as same ascreate table
ddl.But still a little bit different:
restore table
don't do split table region.restore table
will rebase the table auto id with the original table autoID.restore table usage
Scenario 1
If you drop table by mistake, you can use
admin restore table [table_name]
to restore the table.Eg:
Scenario 2
If you drop table
t
by mistable, then create a new tablet
, then drop the new tablet
, now, if you useadmin restore table t
, It will restore the new tablet
, not the ole tablet
. But how to restore the old tablet
? You can useadmin restore table by job [drop_table_job_ID]
.Eg:
Watch out
If you drop table
t
multiple time, then useadmin recover table by job [ID]
with the old drop job ID, there will have some problem when you write.Eg:
summary
Normally recommend use
admin restore table [table_name]
to restore table.admin restore table by job [ID]
is only for the Scenario 2.How it works ?
This is done through the following steps:
StartTS
to get a snapshot infoSchema before drop table.table meta
bytable_id
in snapshot infoSchema, if not found, returnErrTableIDNotExists
.table meta
tocreate table
( recover table ). the table_id is still the original table id. Return if encounter any error.gc_delete_range
table bydrop table job's id
andtable_id
.But Change Settings and undo Settings will make the problem more complicated.
Check List
Tests
Code changes
Side effects
Related changes
This change is