-
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, meta: clean the jobs in adding index queue #6161
Conversation
ddl/ddl_worker.go
Outdated
job.State = model.JobStateRollingback | ||
job.Args = []interface{}{indexInfo.Name} | ||
// If add index job rollbacks, its work is the same as drop index job do. | ||
// When it's not in None state, the next state can be delete only 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.
Maybe this way is more friendly for reader? // When it's not in "None" state, the next state can be "delete only" state.
620c88f
to
d0e3bab
Compare
/run-all-tests |
a5d87d9
to
adce88d
Compare
/run-all-tests |
Please fix CI @zimulala |
/run-integration-common-test |
@@ -91,7 +91,6 @@ func checkHistoryJob(c *C, job *model.Job) { | |||
} | |||
|
|||
func checkHistoryJobArgs(c *C, ctx sessionctx.Context, id int64, args *historyJobArgs) { | |||
c.Assert(ctx.NewTxn(), IsNil) |
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.
why remove?
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.
Make TestCleanJobs
stable.
I want to get schema version and check history job's schema version in a transaction.
ddl/ddl_worker.go
Outdated
return errors.Trace(err) | ||
} | ||
indexInfo := findIndexByName(indexName.L, tblInfo.Indices) | ||
job.State = model.JobStateRollingback |
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.
why not use ddl.convert2RollbackJob ?
log.Infof("[ddl] cleaning job %v in the adding index queue.", job) | ||
|
||
// The types of these jobs must be ActionAddIndex. | ||
if job.SchemaState == model.StatePublic || job.SchemaState == model.StateNone { |
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 have to rollback or cancel the add index ddl job? What about enqueueing these jobs to default job list
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.
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 just put all the add index jobs at the end of the default list, what the worst-case result would be?
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.
@coocood
Added an index that should not be added.
e.g.
original order: drop column col1 -> add index idx1(col1) should be failed
-> add column col1
current order: drop column col1 -> add column col1 -> add index idx1(col1) successful
@zimulala |
@@ -221,6 +221,7 @@ LOOP: | |||
case <-ticker.C: | |||
d.Stop() | |||
d.start(context.Background()) | |||
time.Sleep(time.Millisecond * 20) |
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.
Why add sleep?
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.
Because we add check add index list
, it makes processing the first job a bit slower.
meta/meta.go
Outdated
mDDLJobHistoryKey = []byte("DDLJobHistory") | ||
mDDLJobReorgKey = []byte("DDLJobReorg") | ||
mDDLJobListKey = []byte("DDLJobList") | ||
mAddIdxDDLJobListKey = []byte("AddIdxDDLJobList") |
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 DDLJobAddIdxList
?
ddl/ddl_worker.go
Outdated
@@ -191,7 +193,7 @@ func (d *ddl) getHistoryDDLJob(id int64) (*model.Job, error) { | |||
return job, errors.Trace(err) | |||
} | |||
|
|||
func (d *ddl) handleDDLJobQueue() error { | |||
func (d *ddl) handleDDLJobQueue(shouldCleanJobs *bool) 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.
Add a comment for the new parameter.
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.
Use return value to control the outer for loop.
c1515e7
to
f5c4444
Compare
ddl/ddl_worker.go
Outdated
if err != nil { | ||
log.Errorf("[ddl] handle ddl job err %v", errors.ErrorStack(err)) | ||
} else { | ||
shouldCleanJobs = !isCleaned |
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's possible that the shouldCleanJobs
is false, but isCleaned
return false, then we will clean job again.
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 err is nil, can we safely set shouldCleanJobs to false?
Then we can remove the bool return value.
LGTM |
1 similar comment
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.
rest LGTM
ddl/ddl_worker.go
Outdated
continue | ||
} | ||
|
||
// When the job not in "none" state, we need to rollback it. |
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.
"none" and "public" ?
ddl/ddl_worker.go
Outdated
@@ -52,6 +52,8 @@ func (d *ddl) onDDLWorker() { | |||
metrics.PanicCounter.WithLabelValues(metrics.LabelDDL).Inc() | |||
} | |||
}() | |||
|
|||
shouldCleanJobs := true |
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.
may add a comment for this to explain why we need 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.
LGTM
/run-all-tests |
/integration-common-test |
/run-integration-common-test |
We will initially support the parallel DDL. So we will introduce the adding index queue.
This PR deals with the compatibility when the user chooses to downgrade.