diff --git a/pkg/ddl/partition.go b/pkg/ddl/partition.go index 43bcd1a785..10bc704e00 100644 --- a/pkg/ddl/partition.go +++ b/pkg/ddl/partition.go @@ -2507,9 +2507,12 @@ func (w *worker) onTruncateTablePartition(jobCtx *jobContext, job *model.Job) (i return ver, errors.Trace(dbterror.ErrPartitionMgmtOnNonpartitioned) } - if job.IsRollingback() { - return convertTruncateTablePartitionJob2RollbackJob(jobCtx, job, dbterror.ErrCancelledDDLJob, tblInfo) - } + /* + if job.IsRollingback() { + return convertTruncateTablePartitionJob2RollbackJob(jobCtx, job, dbterror.ErrCancelledDDLJob, tblInfo) + } + + */ failpoint.Inject("truncatePartCancel1", func(val failpoint.Value) { if val.(bool) { @@ -2581,6 +2584,8 @@ func (w *worker) onTruncateTablePartition(jobCtx *jobContext, job *model.Job) (i failpoint.Return(ver, err) } }) + // To see what happens if duplicate + job.FinishTableJob(model.JobStateDone, model.StateNone, ver, tblInfo) // For the truncatePartitionEvent oldDefinitions = pi.DroppingDefinitions newDefinitions = make([]model.PartitionDefinition, 0, len(oldIDs)) diff --git a/pkg/ddl/rollingback.go b/pkg/ddl/rollingback.go index 2960f109b6..3109e04fc0 100644 --- a/pkg/ddl/rollingback.go +++ b/pkg/ddl/rollingback.go @@ -316,6 +316,7 @@ func rollingbackExchangeTablePartition(jobCtx *jobContext, job *model.Job) (ver return ver, errors.Trace(err) } +/* func rollingbackTruncateTablePartition(jobCtx *jobContext, job *model.Job) (ver int64, err error) { tblInfo, err := GetTableInfoAndCancelFaultJob(jobCtx.metaMut, job, job.SchemaID) if err != nil { @@ -351,6 +352,8 @@ func convertTruncateTablePartitionJob2RollbackJob(jobCtx *jobContext, job *model return ver, errors.Trace(otherwiseErr) } +*/ + func convertAddTablePartitionJob2RollbackJob(jobCtx *jobContext, job *model.Job, otherwiseErr error, tblInfo *model.TableInfo) (ver int64, err error) { addingDefinitions := tblInfo.Partition.AddingDefinitions partNames := make([]string, 0, len(addingDefinitions)) @@ -625,10 +628,13 @@ func convertJob2RollbackJob(w *worker, jobCtx *jobContext, job *model.Job) (ver ver, err = rollingbackTruncateTable(jobCtx, job) case model.ActionModifyColumn: ver, err = rollingbackModifyColumn(jobCtx, job) - case model.ActionDropForeignKey: + case model.ActionDropForeignKey, model.ActionTruncateTablePartition: ver, err = cancelOnlyNotHandledJob(job, model.StatePublic) - case model.ActionTruncateTablePartition: - ver, err = rollingbackTruncateTablePartition(jobCtx, job) + /* + case model.ActionTruncateTablePartition: + ver, err = rollingbackTruncateTablePartition(jobCtx, job) + + */ case model.ActionRebaseAutoID, model.ActionShardRowID, model.ActionAddForeignKey, model.ActionRenameTable, model.ActionRenameTables, model.ActionModifyTableCharsetAndCollate, diff --git a/pkg/meta/model/job.go b/pkg/meta/model/job.go index 0f70cdf1d2..fb4819344b 100644 --- a/pkg/meta/model/job.go +++ b/pkg/meta/model/job.go @@ -735,10 +735,13 @@ func (job *Job) IsRollbackable() bool { case ActionAddTablePartition: return job.SchemaState == StateNone || job.SchemaState == StateReplicaOnly case ActionDropColumn, ActionDropSchema, ActionDropTable, ActionDropSequence, - ActionDropForeignKey, ActionDropTablePartition: + ActionDropForeignKey, ActionDropTablePartition, ActionTruncateTablePartition: return job.SchemaState == StatePublic - case ActionTruncateTablePartition: - return job.SchemaState == StatePublic || job.SchemaState == StateWriteOnly + /* + case ActionTruncateTablePartition: + return job.SchemaState == StatePublic || job.SchemaState == StateWriteOnly + + */ case ActionRebaseAutoID, ActionShardRowID, ActionTruncateTable, ActionAddForeignKey, ActionRenameTable, ActionRenameTables, ActionModifyTableCharsetAndCollate,