-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
infoschema: update raw args to make it drop correct table in RENAME TABLE
#44585
infoschema: update raw args to make it drop correct table in RENAME TABLE
#44585
Conversation
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
/retest-required |
RENAME TABLE
@@ -1177,10 +1178,17 @@ func finishJobRenameTable(d *ddlCtx, t *meta.Meta, job *model.Job) (int64, error | |||
job.State = model.JobStateCancelled | |||
return 0, errors.Trace(err) | |||
} | |||
oldRawArgs := job.RawArgs |
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.
Could we add comments for this logic?
@@ -1177,10 +1178,17 @@ func finishJobRenameTable(d *ddlCtx, t *meta.Meta, job *model.Job) (int64, error | |||
job.State = model.JobStateCancelled | |||
return 0, errors.Trace(err) | |||
} | |||
oldRawArgs := job.RawArgs | |||
job.Args[0] = job.SchemaID |
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.
I feel that the effect of create table
in apply is diff.TableID
why do we update job.SchemaID
?
It can make drop the created table in the first apply.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crazycs520, zimulala The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
/run-cherry-picker |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
What problem does this PR solve?
Issue Number: close #43714
Problem Summary:
Reproducible step:
#43341 changes the behavior of
RENAME TABLE
: it takes two schema versions to complete. However,applyDiff()
doesn't handle twoSchemaDiff
s properly. The same table is created twice ininfoschema
, causing the phantom described in #43714.What is changed and how it works?
During applying schema diff, we check if the table already exists before creating a new table. Thus, we can skip the second creation.
Other alternative fixes include
CREATE TABLE
with foreign key does).job.Args
at second step, so that it contains the new schema ID.job.Args
, it is hard to guarantee all the components that relying on this work correctly.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.