-
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
ddl: correct the job.SchemaState in DROP cases #34235
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
ddl/index.go
Outdated
@@ -709,6 +706,7 @@ func onDropIndex(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ error) { | |||
default: | |||
err = dbterror.ErrInvalidDDLState.GenWithStackByArgs("index", indexInfo.State) |
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.
If we do this change, do we need to do a return here? Otherwise, there is an error, but also change the schema version?
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 think this is fine because the DDL state is incorrect anyway.
job.SchemaState
is exactly used to show the indexInfo.State
here.
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.
However, this may cause a problem if it is later written to KV (DDL job should be retried).
@@ -527,10 +527,11 @@ func (d *ddl) DropSchema(ctx sessionctx.Context, schema model.CIStr) (err error) | |||
return errors.Trace(infoschema.ErrDatabaseNotExists) |
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 ModifyColumn
, TruncateTable
, ModifySchemaCharsetAndCollate
, DropTablePartition
, ExchangeTablePartition
, SetDefaultValue
, and so on.
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.
Some of them don't even have the concept of schema state(like truncate table
, modify charset/collate
), and some involve non-trivial changes(like drop partition
, modify columns
).
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.
How about ActionDropColumns
?
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.
DropColumns will be removed when multi-schema change is supported.
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.
It should be mentioned in the release note.
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/eee54ce71b06fd0ede417d2d7b00d3ca8d2c7053 |
/run-mysql-test |
ddl/foreign_key.go
Outdated
return ver, nil | ||
default: | ||
job.SchemaState = fkInfo.State |
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.
Here we needn't do this?
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.
Updated.
ddl/index.go
Outdated
@@ -709,6 +706,7 @@ func onDropIndex(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ error) { | |||
default: | |||
err = dbterror.ErrInvalidDDLState.GenWithStackByArgs("index", indexInfo.State) |
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.
However, this may cause a problem if it is later written to KV (DDL job should be retried).
@@ -527,10 +527,11 @@ func (d *ddl) DropSchema(ctx sessionctx.Context, schema model.CIStr) (err error) | |||
return errors.Trace(infoschema.ErrDatabaseNotExists) |
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.
How about ActionDropColumns
?
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
/merge |
This pull request has been accepted and is ready to merge. Commit hash: d539d8d
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: eee54ce
|
TiDB MergeCI notify🔴 Bad News! [1] CI still failing after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #32939
Problem Summary:
This PR is a patch for #34157.
What is changed and how it works?
Check List
Tests
Side effects
In the scenario of the rolling upgrade, if the DDL owner is transferred from an old version of TiDB to a newer one,
admin cancel job
may not work correctly.Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.