Skip to content

Commit

Permalink
remove unuse code
Browse files Browse the repository at this point in the history
  • Loading branch information
x-shadow-man committed Nov 17, 2022
1 parent e524c74 commit cba2577
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions ddl/modify_column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ func TestModifyColumnTypeWithWarnings(t *testing.T) {
// TestModifyColumnTypeWhenInterception is to test modifying column type with warnings intercepted by
// reorg timeout, not owner error and so on.
func TestModifyColumnTypeWhenInterception(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
store, _ := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -853,42 +853,10 @@ func TestModifyColumnTypeWhenInterception(t *testing.T) {
// Make the regions scale like: [1, 1024), [1024, 2048), [2048, 3072), [3072, 4096]
tk.MustQuery("split table t between(0) and (4096) regions 4")

d := dom.DDL()
hook := &ddl.TestDDLCallback{}
var checkMiddleWarningCount bool
var checkMiddleAddedCount bool
// Since the `DefTiDBDDLReorgWorkerCount` is 4, every worker will be assigned with one region
// for the first time. Here we mock the insert failure/reorg timeout in region [2048, 3072)
// which will lead next handle be set to 2048 and partial warnings be stored into ddl job.
// Since the existence of reorg batch size, only the last reorg batch [2816, 3072) of kv
// range [2048, 3072) fail to commit, the rest of them all committed successfully. So the
// addedCount and warnings count in the job are all equal to `4096 - reorg batch size`.
// In the next round of this ddl job, the last reorg batch will be finished.
var middleWarningsCount = int64(defaultBatchSize*4 - defaultReorgBatchSize)
onJobUpdatedExportedFunc := func(job *model.Job) {
if job.SchemaState == model.StateWriteReorganization || job.SnapshotVer != 0 {
if len(job.ReorgMeta.WarningsCount) == len(job.ReorgMeta.Warnings) {
for _, v := range job.ReorgMeta.WarningsCount {
if v == middleWarningsCount {
checkMiddleWarningCount = true
}
}
}
if job.RowCount == middleWarningsCount {
checkMiddleAddedCount = true
}
}
}
hook.OnJobUpdatedExported.Store(&onJobUpdatedExportedFunc)
d.SetHook(hook)
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/ddl/MockReorgTimeoutInOneRegion", `return(true)`))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/ddl/MockReorgTimeoutInOneRegion"))
}()
tk.MustExec("alter table t modify column b decimal(3,1)")
require.True(t, checkMiddleWarningCount)
require.True(t, checkMiddleAddedCount)

res := tk.MustQuery("show warnings")
require.Len(t, res.Rows(), 1)
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1292 4096 warnings with this error code, first warning: Truncated incorrect DECIMAL value: '11.22'"))
}

0 comments on commit cba2577

Please sign in to comment.