Skip to content

Commit

Permalink
variables: add concurrent DDL switch (#35028)
Browse files Browse the repository at this point in the history
ref #32031
  • Loading branch information
xiongjiwei committed Jun 6, 2022
1 parent eca9f2d commit 7ffab33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions expression/integration_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3747,6 +3747,13 @@ func TestSetVariables(t *testing.T) {
_, err = tk.Exec("set @@global.max_prepared_stmt_count='';")
require.Error(t, err)
require.Error(t, err, variable.ErrWrongTypeForVar.GenWithStackByArgs("max_prepared_stmt_count").Error())

tk.MustQuery("select @@global.tidb_enable_concurrent_ddl").Check(testkit.Rows("1"))
require.True(t, variable.EnableConcurrentDDL.Load())
tk.MustExec("set @@global.tidb_enable_concurrent_ddl=0")
tk.MustQuery("select @@global.tidb_enable_concurrent_ddl").Check(testkit.Rows("0"))
require.False(t, variable.EnableConcurrentDDL.Load())
testkit.NewTestKit(t, store).MustQuery("select @@global.tidb_enable_concurrent_ddl").Check(testkit.Rows("0"))
}

func TestPreparePlanCache(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ var defaultSysVars = []*SysVar{
return err
},
},
{Scope: ScopeGlobal, Name: TiDBEnableConcurrentDDL, Value: BoolToOnOff(DefTiDBEnableConcurrentDDL), Type: TypeBool, SetGlobal: func(s *SessionVars, val string) error {
EnableConcurrentDDL.Store(TiDBOptOn(val))
return nil
}, GetGlobal: func(s *SessionVars) (string, error) {
return BoolToOnOff(EnableConcurrentDDL.Load()), nil
}},

/* The system variables below have GLOBAL and SESSION scope */
{Scope: ScopeGlobal | ScopeSession, Name: SQLSelectLimit, Value: "18446744073709551615", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error {
Expand Down
4 changes: 4 additions & 0 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ const (
// TiDBMaxAutoAnalyzeTime is the max time that auto analyze can run. If auto analyze runs longer than the value, it
// will be killed. 0 indicates that there is no time limit.
TiDBMaxAutoAnalyzeTime = "tidb_max_auto_analyze_time"
// TiDBEnableConcurrentDDL indicates whether to enable the new DDL framework.
TiDBEnableConcurrentDDL = "tidb_enable_concurrent_ddl"
)

// TiDB intentional limits
Expand Down Expand Up @@ -892,6 +894,7 @@ const (
DefTiDBEnablePrepPlanCache = true
DefTiDBPrepPlanCacheSize = 100
DefTiDBPrepPlanCacheMemoryGuardRatio = 0.1
DefTiDBEnableConcurrentDDL = true
)

// Process global variables.
Expand Down Expand Up @@ -939,6 +942,7 @@ var (
EnablePreparedPlanCache = atomic.NewBool(DefTiDBEnablePrepPlanCache)
PreparedPlanCacheSize = atomic.NewUint64(DefTiDBPrepPlanCacheSize)
PreparedPlanCacheMemoryGuardRatio = atomic.NewFloat64(DefTiDBPrepPlanCacheMemoryGuardRatio)
EnableConcurrentDDL = atomic.NewBool(DefTiDBEnableConcurrentDDL)
)

var (
Expand Down

0 comments on commit 7ffab33

Please sign in to comment.