-
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
Changes from 1 commit
d4b7f76
4ab6e53
f04d7b9
0691d40
99a6ee4
d539d8d
c419f8f
eee54ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,8 +106,10 @@ func onDropForeignKey(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ err | |
} | ||
// Finish this job. | ||
job.FinishTableJob(model.JobStateDone, model.StateNone, ver, tblInfo) | ||
job.SchemaState = fkInfo.State | ||
return ver, nil | ||
default: | ||
job.SchemaState = fkInfo.State | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
return ver, dbterror.ErrInvalidDDLState.GenWithStackByArgs("foreign key", fkInfo.State) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -647,33 +647,30 @@ func onDropIndex(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ error) { | |
if err != nil { | ||
return ver, errors.Trace(err) | ||
} | ||
job.SchemaState = model.StateWriteOnly | ||
case model.StateWriteOnly: | ||
// write only -> delete only | ||
indexInfo.State = model.StateDeleteOnly | ||
ver, err = updateVersionAndTableInfo(d, t, job, tblInfo, originalState != indexInfo.State) | ||
if err != nil { | ||
return ver, errors.Trace(err) | ||
} | ||
job.SchemaState = model.StateDeleteOnly | ||
case model.StateDeleteOnly: | ||
// delete only -> reorganization | ||
indexInfo.State = model.StateDeleteReorganization | ||
ver, err = updateVersionAndTableInfo(d, t, job, tblInfo, originalState != indexInfo.State) | ||
if err != nil { | ||
return ver, errors.Trace(err) | ||
} | ||
job.SchemaState = model.StateDeleteReorganization | ||
case model.StateDeleteReorganization: | ||
// reorganization -> absent | ||
indexInfo.State = model.StateNone | ||
if len(dependentHiddenCols) > 0 { | ||
firstHiddenOffset := dependentHiddenCols[0].Offset | ||
for i := 0; i < len(dependentHiddenCols); i++ { | ||
// Set this column's offset to the last and reset all following columns' offsets. | ||
adjustColumnInfoInDropColumn(tblInfo, firstHiddenOffset) | ||
} | ||
} | ||
|
||
newIndices := make([]*model.IndexInfo, 0, len(tblInfo.Indices)) | ||
for _, idx := range tblInfo.Indices { | ||
if idx.Name.L != indexInfo.Name.L { | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine because the DDL state is incorrect anyway.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
} | ||
job.SchemaState = indexInfo.State | ||
return ver, errors.Trace(err) | ||
} | ||
|
||
|
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(likedrop 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.