Skip to content
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: Global index tests for ADD PARTITION #58030

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion pkg/ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func checkAddPartition(jobCtx *jobContext, job *model.Job) (*model.TableInfo, *m
return tblInfo, partInfo, []model.PartitionDefinition{}, nil
}

// TODO: Move this into reorganize partition!
func (w *worker) onAddTablePartition(jobCtx *jobContext, job *model.Job) (ver int64, _ error) {
args, err := model.GetTablePartitionArgs(job)
if err != nil {
Expand Down Expand Up @@ -134,6 +133,22 @@ func (w *worker) onAddTablePartition(jobCtx *jobContext, job *model.Job) (ver in
return ver, errors.Trace(err)
}

failpoint.Inject("addPartCancel1", func(val failpoint.Value) {
if val.(bool) {
job.State = model.JobStateCancelled
err = errors.New("Injected error by addPartCancel1")
failpoint.Return(ver, err)
}
})

failpoint.Inject("addPartFail1", func(val failpoint.Value) {
if val.(bool) {
job.ErrorCount += variable.GetDDLErrorCountLimit() / 2
err = errors.New("Injected error by addPartFail1")
failpoint.Return(ver, err)
}
})

// move the adding definition into tableInfo.
updateAddingPartitionInfo(partInfo, tblInfo)
tblInfo.Partition.DDLState = model.StateReplicaOnly
Expand Down Expand Up @@ -164,6 +179,14 @@ func (w *worker) onAddTablePartition(jobCtx *jobContext, job *model.Job) (ver in
return ver, errors.Trace(err)
}

failpoint.Inject("addPartCancel2", func(val failpoint.Value) {
if val.(bool) {
job.State = model.JobStateCancelled
err = errors.New("Injected error by addPartCancel2")
failpoint.Return(ver, err)
}
})

ids := getIDs([]*model.TableInfo{tblInfo})
for _, p := range tblInfo.Partition.AddingDefinitions {
ids = append(ids, p.ID)
Expand All @@ -173,6 +196,14 @@ func (w *worker) onAddTablePartition(jobCtx *jobContext, job *model.Job) (ver in
return ver, err
}

failpoint.Inject("addPartFail2", func(val failpoint.Value) {
if val.(bool) {
job.ErrorCount += variable.GetDDLErrorCountLimit() / 2
err = errors.New("Injected error by addPartFail2")
failpoint.Return(ver, err)
}
})

// none -> replica only
job.SchemaState = model.StateReplicaOnly
case model.StateReplicaOnly:
Expand Down Expand Up @@ -219,12 +250,29 @@ func (w *worker) onAddTablePartition(jobCtx *jobContext, job *model.Job) (ver in

preSplitAndScatter(w.sess.Context, jobCtx.store, tblInfo, addingDefinitions)

failpoint.Inject("addPartFail3", func(val failpoint.Value) {
if val.(bool) {
job.ErrorCount += variable.GetDDLErrorCountLimit() / 2
err = errors.New("Injected error by addPartFail3")
failpoint.Return(ver, err)
}
})

tblInfo.Partition.DDLState = model.StateNone
tblInfo.Partition.DDLAction = model.ActionNone
ver, err = updateVersionAndTableInfo(jobCtx, job, tblInfo, true)
if err != nil {
return ver, errors.Trace(err)
}

failpoint.Inject("addPartFail4", func(val failpoint.Value) {
if val.(bool) {
job.ErrorCount += variable.GetDDLErrorCountLimit() / 2
err = errors.New("Injected error by addPartFail4")
failpoint.Return(ver, err)
}
})

addPartitionEvent := notifier.NewAddPartitionEvent(tblInfo, partInfo)
err = asyncNotifyEvent(jobCtx, addPartitionEvent, job, noSubJob, w.sess)
if err != nil {
Expand Down
Loading