Skip to content
Merged
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
29 changes: 29 additions & 0 deletions pkg/ddl/index_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/config/kerneltype"
"github.com/pingcap/tidb/pkg/ddl"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/meta/model"
Expand Down Expand Up @@ -393,6 +394,9 @@ func checkDropDeleteOnly(ctx sessionctx.Context, writeTbl, delTbl table.Table) e
}

func TestAddIndexRowCountUpdate(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -432,3 +436,28 @@ func TestAddIndexRowCountUpdate(t *testing.T) {
}()
tk.MustExec("alter table t add index idx(c2);")
}

func TestFastReOrgAlwaysEnabledOnNextGen(t *testing.T) {
if kerneltype.IsClassic() {
t.Skip("This test is only for next-gen TiDB")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustQuery("select @@global.tidb_ddl_enable_fast_reorg").Equal(testkit.Rows("1"))
require.ErrorContains(t, tk.ExecToErr("set global tidb_ddl_enable_fast_reorg=0"),
"setting tidb_ddl_enable_fast_reorg is not supported in the next generation of TiDB")
}

func TestReadOnlyVarsInNextGen(t *testing.T) {
if kerneltype.IsClassic() {
t.Skip("This test is only for next-gen TiDB")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
require.ErrorContains(t, tk.ExecToErr("set global tidb_max_dist_task_nodes=5"),
"setting tidb_max_dist_task_nodes is not supported in the next generation of TiDB")
require.ErrorContains(t, tk.ExecToErr("set global tidb_ddl_reorg_max_write_speed=5"),
"setting tidb_ddl_reorg_max_write_speed is not supported in the next generation of TiDB")
require.ErrorContains(t, tk.ExecToErr("set global tidb_ddl_disk_quota=5"),
"setting tidb_ddl_disk_quota is not supported in the next generation of TiDB")
}
6 changes: 6 additions & 0 deletions pkg/ddl/index_modify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ func TestAddIndexWithDupIndex(t *testing.T) {
}

func TestAddIndexUniqueFailOnDuplicate(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those tests will disable DXF

}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -1954,6 +1957,9 @@ func TestAddColumnarIndexRollback(t *testing.T) {
}

func TestInsertDuplicateBeforeIndexMerge(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
Expand Down
33 changes: 29 additions & 4 deletions pkg/ddl/ingest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func TestAddIndexIngestGeneratedColumns(t *testing.T) {
}

func TestIngestError(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
Expand Down Expand Up @@ -134,6 +137,9 @@ func TestIngestError(t *testing.T) {
}

func TestAddIndexIngestPanic(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
Expand Down Expand Up @@ -161,6 +167,9 @@ func TestAddIndexIngestPanic(t *testing.T) {
}

func TestAddIndexSetInternalSessions(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
Expand Down Expand Up @@ -417,6 +426,9 @@ func TestMultiSchemaAddIndexMerge(t *testing.T) {
}

func TestAddIndexIngestJobWriteConflict(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
defer ingesttestutil.InjectMockBackendCtx(t, store)()
tk := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -450,6 +462,9 @@ func TestAddIndexIngestJobWriteConflict(t *testing.T) {
}

func TestAddIndexIngestPartitionCheckpoint(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
defer ingesttestutil.InjectMockBackendCtx(t, store)()
tk := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -650,8 +665,13 @@ func TestModifyColumnWithMultipleIndex(t *testing.T) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin`
for _, tc := range testcases {
t.Run(tc.caseName, func(t *testing.T) {
tk.MustExec(fmt.Sprintf("set global tidb_enable_dist_task = %s;", tc.enableDistTask))
tk.MustExec(fmt.Sprintf("set global tidb_ddl_enable_fast_reorg = %s;", tc.enableFastReorg))
if kerneltype.IsNextGen() && tc.enableDistTask == "off" {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
if kerneltype.IsClassic() {
tk.MustExec(fmt.Sprintf("set global tidb_enable_dist_task = %s;", tc.enableDistTask))
tk.MustExec(fmt.Sprintf("set global tidb_ddl_enable_fast_reorg = %s;", tc.enableFastReorg))
}
tk.MustExec("DROP TABLE IF EXISTS t")
tk.MustExec(createTableSQL)
tk.MustExec("insert into t values(19,1,1),(17,2,2)")
Expand All @@ -678,8 +698,13 @@ func TestModifyColumnWithIndexWithDefaultValue(t *testing.T) {
}
for _, tc := range testcases {
t.Run(tc.caseName, func(t *testing.T) {
tk.MustExec(fmt.Sprintf("set global tidb_enable_dist_task = %s;", tc.enableDistTask))
tk.MustExec(fmt.Sprintf("set global tidb_ddl_enable_fast_reorg = %s;", tc.enableFastReorg))
if kerneltype.IsNextGen() && tc.enableDistTask == "off" {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
if kerneltype.IsClassic() {
tk.MustExec(fmt.Sprintf("set global tidb_enable_dist_task = %s;", tc.enableDistTask))
tk.MustExec(fmt.Sprintf("set global tidb_ddl_enable_fast_reorg = %s;", tc.enableFastReorg))
}
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1 (c int(10), c1 datetime default (date_format(now(),'%Y-%m-%d')));")
tk.MustExec("insert into t1(c) values (1), (2);")
Expand Down
7 changes: 6 additions & 1 deletion pkg/ddl/multi_schema_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,9 @@ func TestMultiSchemaChangeAlterIndex(t *testing.T) {
}

func TestMultiSchemaChangeMixCancelled(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
Expand Down Expand Up @@ -668,7 +671,6 @@ func TestMultiSchemaChangeAdminShowDDLJobs(t *testing.T) {

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set global tidb_ddl_enable_fast_reorg = 1;")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default is 1, so no need to set it again

tk.MustExec("create table t (a int, b int, c int)")
tk.MustExec("insert into t values (1, 2, 3)")

Expand Down Expand Up @@ -886,6 +888,9 @@ func TestMultiSchemaChangeBlockedByRowLevelChecksum(t *testing.T) {
}

func TestMultiSchemaChangePollJobCount(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("add-index always runs on DXF with ingest mode in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down
6 changes: 0 additions & 6 deletions pkg/ddl/tests/indexmerge/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestAddIndexMergeProcess(t *testing.T) {
tk.MustExec("insert into t values (1, 2, 3), (4, 5, 6);")
// Force onCreateIndex use the txn-merge process.
ingest.LitInitialized = false
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = 1;")

var checkErr error
var runDML, backfillDone bool
Expand Down Expand Up @@ -84,7 +83,6 @@ func TestAddPrimaryKeyMergeProcess(t *testing.T) {
tk.MustExec("insert into t values (1, 2, 3), (4, 5, 6);")
// Force onCreateIndex use the backfill-merge process.
ingest.LitInitialized = false
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = 1;")

var checkErr error
var runDML, backfillDone bool
Expand Down Expand Up @@ -126,7 +124,6 @@ func TestAddIndexMergeVersionIndexValue(t *testing.T) {
tk.MustExec("insert into t values (1);")
// Force onCreateIndex use the txn-merge process.
ingest.LitInitialized = false
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = 1;")

var checkErr error
var runDML bool
Expand Down Expand Up @@ -175,7 +172,6 @@ func TestAddIndexMergeIndexUntouchedValue(t *testing.T) {
tk.MustExec("insert into t values (1, 1, 'a', 'a')")
// Force onCreateIndex use the txn-merge process.
ingest.LitInitialized = false
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = 1;")

var checkErrs []error
var runInsert bool
Expand Down Expand Up @@ -301,7 +297,6 @@ func TestAddIndexMergeIndexUpdateOnDeleteOnly(t *testing.T) {

// Force onCreateIndex use the txn-merge process.
ingest.LitInitialized = false
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = 1;")
tk.MustExec("set @@global.tidb_enable_mutation_checker = 1;")
tk.MustExec("set @@global.tidb_txn_assertion_level = 'STRICT';")

Expand Down Expand Up @@ -432,7 +427,6 @@ func TestAddIndexMergeConflictWithPessimistic(t *testing.T) {

// Force onCreateIndex use the txn-merge process.
ingest.LitInitialized = false
tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = 1;")
tk.MustExec("set @@global.tidb_enable_metadata_lock = 0;")

runPessimisticTxn := false
Expand Down
2 changes: 1 addition & 1 deletion pkg/disttask/framework/integrationtests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ go_test(
],
flaky = True,
race = "off",
shard_count = 23,
shard_count = 24,
deps = [
"//pkg/config",
"//pkg/config/kerneltype",
Expand Down
12 changes: 12 additions & 0 deletions pkg/disttask/framework/integrationtests/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/pkg/config/kerneltype"
"github.com/pingcap/tidb/pkg/disttask/framework/handle"
mockexecute "github.com/pingcap/tidb/pkg/disttask/framework/mock/execute"
"github.com/pingcap/tidb/pkg/disttask/framework/proto"
Expand Down Expand Up @@ -327,3 +328,14 @@ func TestTaskCancelledBeforeUpdateTask(t *testing.T) {
task := testutil.SubmitAndWaitTask(c.Ctx, t, "key1", scope, 1)
require.Equal(t, proto.TaskStateReverted, task.State)
}

func TestDXFAlwaysEnabledOnNextGen(t *testing.T) {
if kerneltype.IsClassic() {
t.Skip("This test is only for next-gen TiDB")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustQuery("select @@global.tidb_enable_dist_task").Equal(testkit.Rows("1"))
require.ErrorContains(t, tk.ExecToErr("set global tidb_enable_dist_task=0"),
"setting tidb_enable_dist_task is not supported in the next generation of TiDB")
}
3 changes: 3 additions & 0 deletions pkg/executor/importer/importer_testkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ func TestVerifyChecksum(t *testing.T) {
}

func TestGetTargetNodeCpuCnt(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("DXF is always enabled in nextgen")
}
store, tm, ctx := testutil.InitTableTest(t)
tk := testkit.NewTestKit(t, store)

Expand Down
3 changes: 3 additions & 0 deletions pkg/executor/test/ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,9 @@ func TestSetDDLReorgMaxWriteSpeed(t *testing.T) {
}

func TestLoadDDLDistributeVars(t *testing.T) {
if kerneltype.IsNextGen() {
t.Skip("DXF is always enabled in nextgen")
}
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down
3 changes: 2 additions & 1 deletion pkg/sessionctx/vardef/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func GetPlanReplayerGCLease() time.Duration {
func IsReadOnlyVarInNextGen(name string) bool {
name = strings.ToLower(name)
switch name {
case TiDBEnableMDL, TiDBMaxDistTaskNodes, TiDBDDLReorgMaxWriteSpeed, TiDBDDLDiskQuota:
case TiDBEnableMDL, TiDBMaxDistTaskNodes, TiDBDDLReorgMaxWriteSpeed, TiDBDDLDiskQuota,
TiDBEnableDistTask, TiDBDDLEnableFastReorg:
return true
}
return false
Expand Down
2 changes: 2 additions & 0 deletions pkg/sessionctx/vardef/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ func TestIsReadOnlyVarInNextGen(t *testing.T) {
require.True(t, IsReadOnlyVarInNextGen(TiDBMaxDistTaskNodes))
require.True(t, IsReadOnlyVarInNextGen(TiDBDDLReorgMaxWriteSpeed))
require.True(t, IsReadOnlyVarInNextGen(TiDBDDLDiskQuota))
require.True(t, IsReadOnlyVarInNextGen(TiDBDDLEnableFastReorg))
require.True(t, IsReadOnlyVarInNextGen(TiDBEnableDistTask))
}
1 change: 0 additions & 1 deletion pkg/telemetry/data_feature_usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ func TestAddIndexAccelerationAndMDL(t *testing.T) {
tk.MustExec("set global tidb_enable_metadata_lock = 1")
}

tk.MustExec("set @@global.tidb_ddl_enable_fast_reorg = on")
allow := vardef.EnableFastReorg.Load()
require.Equal(t, true, allow)
usage, err = telemetry.GetFeatureUsage(tk.Session())
Expand Down
1 change: 1 addition & 0 deletions tests/realtikvtest/addindextest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_test(
shard_count = 30,
deps = [
"//pkg/config",
"//pkg/config/kerneltype",
"//pkg/disttask/framework/testutil",
"//pkg/meta/model",
"//pkg/testkit",
Expand Down
13 changes: 10 additions & 3 deletions tests/realtikvtest/addindextest/add_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"testing"

"github.com/pingcap/tidb/pkg/config"
"github.com/pingcap/tidb/pkg/config/kerneltype"
"github.com/pingcap/tidb/pkg/disttask/framework/testutil"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/testkit"
Expand Down Expand Up @@ -104,7 +105,9 @@ func TestAddForeignKeyWithAutoCreateIndex(t *testing.T) {
tk.MustExec("drop database if exists fk_index;")
tk.MustExec("create database fk_index;")
tk.MustExec("use fk_index;")
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=1;`)
if kerneltype.IsClassic() {
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=1;`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in realtikv test, cluster is shared, some case might disable it, so we keep it

}
tk.MustExec("create table employee (id bigint auto_increment key, pid bigint)")
tk.MustExec("insert into employee (id) values (1),(2),(3),(4),(5),(6),(7),(8)")
for range 14 {
Expand Down Expand Up @@ -153,7 +156,9 @@ func TestAddUKWithSmallIntHandles(t *testing.T) {
tk.MustExec("drop database if exists small;")
tk.MustExec("create database small;")
tk.MustExec("use small;")
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=1;`)
if kerneltype.IsClassic() {
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=1;`)
}
tk.MustExec("create table t (a bigint, b int, primary key (a) clustered)")
tk.MustExec("insert into t values (-9223372036854775808, 1),(-9223372036854775807, 1)")
tk.MustContainErrMsg("alter table t add unique index uk(b)", "Duplicate entry '1' for key 't.uk'")
Expand All @@ -164,7 +169,9 @@ func TestAddUniqueDuplicateIndexes(t *testing.T) {

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=1;`)
if kerneltype.IsClassic() {
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=1;`)
}
tk.MustExec("create table t(a int DEFAULT '-13202', b varchar(221) NOT NULL DEFAULT 'duplicatevalue', " +
"c int NOT NULL DEFAULT '0');")

Expand Down
Loading