-
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: validate table info before doing ddl job to avoid load infoschema error #10464
Conversation
/run-all-tests |
1 similar comment
/run-all-tests |
ddl/column.go
Outdated
@@ -242,6 +242,11 @@ func onDropColumn(t *meta.Meta, job *model.Job) (ver int64, _ error) { | |||
colInfo.State = model.StateWriteOnly | |||
// Set this column's offset to the last and reset all following columns' offsets. | |||
adjustColumnInfoInDropColumn(tblInfo, colInfo.Offset) | |||
err = checkTableInfoValid(tblInfo) |
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.
we should check if the tableInfo valid before we overwrite the tableInfo in TiKV.
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.
done. PTAL
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.
We have added check
on line 265, why do it again?
Codecov Report
@@ Coverage Diff @@
## master #10464 +/- ##
================================================
+ Coverage 77.2657% 77.2906% +0.0248%
================================================
Files 413 413
Lines 86979 86986 +7
================================================
+ Hits 67205 67232 +27
+ Misses 14608 14594 -14
+ Partials 5166 5160 -6 |
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
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
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 add it to the operation of add index
?
ddl/column.go
Outdated
@@ -242,6 +242,11 @@ func onDropColumn(t *meta.Meta, job *model.Job) (ver int64, _ error) { | |||
colInfo.State = model.StateWriteOnly | |||
// Set this column's offset to the last and reset all following columns' offsets. | |||
adjustColumnInfoInDropColumn(tblInfo, colInfo.Offset) | |||
err = checkTableInfoValid(tblInfo) |
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.
We have added check
on line 265, why do it again?
@@ -1114,6 +1114,11 @@ func (d *ddl) CreateTableWithLike(ctx sessionctx.Context, ident, referIdent ast. | |||
return errors.Trace(err) | |||
} | |||
|
|||
func checkTableInfoValid(tblInfo *model.TableInfo) error { |
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 add comments for it?
/run-all-tests |
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
What problem does this PR solve?
Validate table info before doing ddl job to avoid load infoschema error.
eg1:
eg2:
What is changed and how it works?
Add check table info in create table and drop column.
Maybe add this check in other public path is better.
Check List
Tests
Code changes
Side effects
Possible performance regression
Related changes
Need to cherry-pick to the release branch