Skip to content

Commit

Permalink
disttask: enable on default (#52401)
Browse files Browse the repository at this point in the history
ref #52441
  • Loading branch information
D3Hunter authored Apr 12, 2024
1 parent 3fff0f2 commit 7308ff1
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 144 deletions.
3 changes: 3 additions & 0 deletions pkg/ddl/ingest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestIngestError(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("set global tidb_enable_dist_task = 0")
defer ingesttestutil.InjectMockBackendMgr(t, store)()

tk.MustExec("set @@global.tidb_ddl_reorg_worker_cnt = 1;")
Expand Down Expand Up @@ -126,6 +127,8 @@ func TestAddIndexIngestPanic(t *testing.T) {
tk.MustExec("use test;")
defer ingesttestutil.InjectMockBackendMgr(t, store)()

tk.MustExec("set global tidb_enable_dist_task = 0")

// Mock panic on coprocessor request sender.
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/ddl/mockCopSenderPanic", "return(true)"))
tk.MustExec("create table t (a int, b int, c int, d int, primary key (a) clustered);")
Expand Down
1 change: 1 addition & 0 deletions pkg/ddl/ingest/tests/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestAddIndexIngestRecoverPartition(t *testing.T) {
defer ingesttestutil.InjectMockBackendMgr(t, tc.Store)()
tk := testkit.NewTestKit(t, tc.Store)
tk.MustExec("use test;")
tk.MustExec("set global tidb_enable_dist_task = 0")
tk.MustExec("create table t (a int primary key, b int) partition by hash(a) partitions 8;")
tk.MustExec("insert into t values (2, 3), (3, 3), (5, 5);")

Expand Down
14 changes: 4 additions & 10 deletions pkg/ddl/modify_column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,10 @@ func TestModifyColumnReorgInfo(t *testing.T) {
// Test encountering a "notOwnerErr" error which caused the processing backfill job to exit halfway.
// During the period, the old TiDB version(do not exist the element information) is upgraded to the new TiDB version.
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/ddl/MockGetIndexRecordErr", `return("addIdxNotOwnerErr")`))
// TODO: Remove this check after "err" isn't nil in runReorgJobAndHandleErr.
if variable.EnableDistTask.Load() {
err = tk.ExecToErr("alter table t1 add index idx2(c1)")
require.EqualError(t, err, "[ddl:8201]TiDB server is not a DDL owner")
} else {
tk.MustExec("alter table t1 add index idx2(c1)")
expectedElements = []*meta.Element{
{ID: 7, TypeKey: meta.IndexElementKey}}
checkReorgHandle(elements, expectedElements)
}
tk.MustExec("alter table t1 add index idx2(c1)")
expectedElements = []*meta.Element{
{ID: 7, TypeKey: meta.IndexElementKey}}
checkReorgHandle(elements, expectedElements)
tk.MustExec("admin check table t1")
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/ddl/MockGetIndexRecordErr"))
}
Expand Down
1 change: 1 addition & 0 deletions pkg/ddl/multi_schema_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ func TestMultiSchemaChangeMixCancelled(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("set global tidb_enable_dist_task = 0;")
tk.MustExec("set global tidb_ddl_enable_fast_reorg = 0;")

tk.MustExec("create table t (a int, b int, c int, index i1(c), index i2(c));")
Expand Down
5 changes: 3 additions & 2 deletions pkg/executor/importer/importer_testkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,13 @@ func TestVerifyChecksum(t *testing.T) {

func TestGetTargetNodeCpuCnt(t *testing.T) {
_, tm, ctx := testutil.InitTableTest(t)
require.False(t, variable.EnableDistTask.Load())
old := variable.EnableDistTask.Load()

variable.EnableDistTask.Store(false)
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/util/cpu/mockNumCpu", "return(16)"))
t.Cleanup(func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/util/cpu/mockNumCpu"))
variable.EnableDistTask.Store(false)
variable.EnableDistTask.Store(old)
})
require.NoError(t, tm.InitMeta(ctx, "tidb1", ""))

Expand Down
1 change: 0 additions & 1 deletion pkg/executor/test/ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ go_test(
"//pkg/parser/model",
"//pkg/parser/mysql",
"//pkg/sessionctx/variable",
"//pkg/sessionctx/variable/featuretag/disttask",
"//pkg/sessiontxn",
"//pkg/store/mockstore",
"//pkg/table",
Expand Down
9 changes: 4 additions & 5 deletions pkg/executor/test/ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/sessionctx/variable/featuretag/disttask"
"github.com/pingcap/tidb/pkg/sessiontxn"
"github.com/pingcap/tidb/pkg/store/mockstore"
"github.com/pingcap/tidb/pkg/table"
Expand Down Expand Up @@ -884,14 +883,14 @@ func TestLoadDDLDistributeVars(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
require.Equal(t, variable.DefTiDBEnableDistTask, disttask.TiDBEnableDistTask)

require.Equal(t, variable.DefTiDBEnableDistTask, variable.EnableDistTask.Load())
tk.MustGetDBError("set @@global.tidb_enable_dist_task = invalid_val", variable.ErrWrongValueForVar)
require.Equal(t, disttask.TiDBEnableDistTask, variable.EnableDistTask.Load())
require.Equal(t, variable.DefTiDBEnableDistTask, variable.EnableDistTask.Load())
tk.MustExec("set @@global.tidb_enable_dist_task = 'on'")
require.Equal(t, true, variable.EnableDistTask.Load())
tk.MustExec(fmt.Sprintf("set @@global.tidb_enable_dist_task = %v", disttask.TiDBEnableDistTask))
require.Equal(t, disttask.TiDBEnableDistTask, variable.EnableDistTask.Load())
tk.MustExec(fmt.Sprintf("set @@global.tidb_enable_dist_task = %v", false))
require.Equal(t, false, variable.EnableDistTask.Load())
}

// this test will change the fail-point `mockAutoIDChange`, so we move it to the `testRecoverTable` suite
Expand Down
8 changes: 6 additions & 2 deletions pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,11 @@ var (
SupportUpgradeHTTPOpVer int64 = version174
)

func checkDistTask(s sessiontypes.Session) {
func checkDistTask(s sessiontypes.Session, ver int64) {
if ver > version195 {
// since version195 we enable dist task by default, no need to check
return
}
ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnBootstrap)
rs, err := s.ExecuteInternal(ctx, "SELECT HIGH_PRIORITY variable_value from mysql.global_variables where variable_name = %?;", variable.TiDBEnableDistTask)
if err != nil {
Expand Down Expand Up @@ -1361,7 +1365,7 @@ func upgrade(s sessiontypes.Session) {
return
}

checkDistTask(s)
checkDistTask(s, ver)
printClusterState(s, ver)

// Only upgrade from under version92 and this TiDB is not owner set.
Expand Down
Loading

0 comments on commit 7308ff1

Please sign in to comment.