diff --git a/ddl/ddl_worker.go b/ddl/ddl_worker.go index c0dac3437c..6a26a2295f 100644 --- a/ddl/ddl_worker.go +++ b/ddl/ddl_worker.go @@ -474,11 +474,12 @@ func (w *worker) handleDDLJobQueue(d *ddlCtx) error { err = w.finishDDLJob(t, job) return errors.Trace(err) } - if runJobErr != nil && !job.IsRollingback() { + if runJobErr != nil && !job.IsRollingback() && !job.IsRollbackDone() { // If the running job meets an error // and the job state is rolling back, it means that we have already handled this error. // Some DDL jobs (such as adding indexes) may need to update the table info and the schema version, // then shouldn't discard the KV modification. + // And the job state is rollback done, it means the job was already finished, also shouldn't discard too. // Otherwise, we should discard the KV modification when running job. txn.Discard() }