-
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: delete ranges when rolling back 'add index' #6188
Changes from 1 commit
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 |
---|---|---|
|
@@ -155,6 +155,12 @@ func (d *ddl) finishDDLJob(t *meta.Meta, job *model.Job) (err error) { | |
metrics.DDLWorkerHistogram.WithLabelValues(metrics.WorkerFinishDDLJob, metrics.RetLabel(err)).Observe(time.Since(startTime).Seconds()) | ||
}() | ||
switch job.Type { | ||
case model.ActionAddIndex: | ||
if job.State != model.JobStateRollbackDone { | ||
break | ||
} | ||
// ActionAddIndex needs to delete ranges when it needs to be rolled back. | ||
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. After rolling back an AddIndex operation, we need to use delete-range to delete the half-done index data. |
||
fallthrough | ||
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.
|
||
case model.ActionDropSchema, model.ActionDropTable, model.ActionTruncateTable, model.ActionDropIndex: | ||
if job.Version <= currentVersion { | ||
err = d.delRangeManager.addDelRangeJob(job) | ||
|
@@ -254,9 +260,9 @@ func (d *ddl) handleDDLJobQueue() error { | |
d.hookMu.Unlock() | ||
|
||
// Here means the job enters another state (delete only, write only, public, etc...) or is cancelled. | ||
// If the job is done or still running, we will wait 2 * lease time to guarantee other servers to update | ||
// If the job is done or still running or rolling back, we will wait 2 * lease time to guarantee other servers to update | ||
// the newest schema. | ||
if job.State == model.JobStateRunning || job.State == model.JobStateDone { | ||
if job.IsRunning() || job.IsRollingback() || job.IsDone() { | ||
d.waitSchemaChanged(nil, waitTime, schemaVer) | ||
} | ||
if job.IsSynced() { | ||
|
@@ -417,7 +423,7 @@ func (d *ddl) waitSchemaChanged(ctx context.Context, waitTime time.Duration, lat | |
// So here we get the latest schema version to make sure all servers' schema version update to the latest schema version | ||
// in a cluster, or to wait for 2 * lease time. | ||
func (d *ddl) waitSchemaSynced(job *model.Job, waitTime time.Duration) { | ||
if !job.IsRunning() && !job.IsDone() { | ||
if !job.IsRunning() && !job.IsRollingback() && !job.IsDone() { | ||
return | ||
} | ||
// TODO: Make ctx exits when the d is close. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,6 +395,7 @@ func (d *ddl) onDropIndex(t *meta.Meta, job *model.Job) (ver int64, _ error) { | |
job.FinishTableJob(model.JobStateDone, model.StateNone, ver, tblInfo) | ||
} | ||
job.Args = append(job.Args, indexInfo.ID) | ||
log.Warnf("args %v, ts %v", job.Args, t.StartTS) | ||
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. Remove the |
||
default: | ||
err = ErrInvalidTableState.Gen("invalid table state %v", tblInfo.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.
c3IdxInfo
is more readable.