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: support pre-split index regions before creating index #57553

Merged
merged 17 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add functional test for index presplit regions with validation checks
  • Loading branch information
tangenta committed Nov 25, 2024
commit abd295c61e4fe09c0dad8a01481e8151a48bff9b
13 changes: 13 additions & 0 deletions tests/realtikvtest/addindextest3/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,24 @@ func TestAddIndexPresplitIndexRegions(t *testing.T) {
checkSplitKeys(tablecodec.TempIndexPrefix|3, 12, true)
tk.MustExec("drop index idx on t;")
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = off;")
}

func TestAddIndexPresplitFunctional(t *testing.T) {
store := realtikvtest.CreateMockStoreAndSetup(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (a int primary key, b int);")

tk.MustGetErrMsg("alter table t add index idx(b) pre_split_regions = (between (0) and (10 * 10000) regions 0);",
"Split index region num should be greater than 0")
tk.MustGetErrMsg("alter table t add index idx(b) pre_split_regions = (between (0) and (10 * 10000) regions 10000);",
"Split index region num exceeded the limit 1000")
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/ddl/mockSplitIndexRegionAndWaitErr", "2*return")
tk.MustExec("alter table t add index idx(b) pre_split_regions = (between (0) and (10 * 10000) regions 3);")

tk.MustExec("drop table t;")
tk.MustExec("create table t (a bigint primary key, b int);")
tk.MustExec("insert into t values (1, 1), (10, 1);")
tk.MustExec("alter table t add index idx(b) pre_split_regions = (between (1) and (2) regions 3);")
tk.MustExec("drop table t;")
}