Skip to content

Commit

Permalink
ddl: fix unstable test TestAddIndexUniqueFailOnDuplicate (#42589)
Browse files Browse the repository at this point in the history
close #42417
  • Loading branch information
tangenta authored Mar 26, 2023
1 parent 9e353e5 commit ea7a37c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ddl/index_modify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,17 +1069,19 @@ func TestAddIndexWithDupIndex(t *testing.T) {
}

func TestAddIndexUniqueFailOnDuplicate(t *testing.T) {
ddl.ResultCounterForTest = &atomic.Int32{}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (a bigint primary key clustered, b int);")
// The subtask execution order is not guaranteed in distributed reorg. We need to disable it first.
tk.MustExec("set @@global.tidb_enable_dist_task = 0;")
tk.MustExec("set @@global.tidb_ddl_reorg_worker_cnt = 1;")
for i := 1; i <= 12; i++ {
tk.MustExec("insert into t values (?, ?)", i, i)
}
tk.MustExec("insert into t values (0, 1);") // Insert a duplicate key.
tk.MustQuery("split table t by (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12);").Check(testkit.Rows("13 1"))
ddl.ResultCounterForTest = &atomic.Int32{}
tk.MustGetErrCode("alter table t add unique index idx (b);", errno.ErrDupEntry)
require.Less(t, int(ddl.ResultCounterForTest.Load()), 6)
ddl.ResultCounterForTest = nil
Expand Down

0 comments on commit ea7a37c

Please sign in to comment.