diff --git a/expression/integration_serial_test.go b/expression/integration_serial_test.go index c0c2c3b8e7d91..6bc58779def9f 100644 --- a/expression/integration_serial_test.go +++ b/expression/integration_serial_test.go @@ -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) { diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 6f5d9dc98da9b..84f6ca8a2bbdb 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -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 { diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index 7d621ec5db22a..6c2515fd1e6a4 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -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 @@ -892,6 +894,7 @@ const ( DefTiDBEnablePrepPlanCache = true DefTiDBPrepPlanCacheSize = 100 DefTiDBPrepPlanCacheMemoryGuardRatio = 0.1 + DefTiDBEnableConcurrentDDL = true ) // Process global variables. @@ -939,6 +942,7 @@ var ( EnablePreparedPlanCache = atomic.NewBool(DefTiDBEnablePrepPlanCache) PreparedPlanCacheSize = atomic.NewUint64(DefTiDBPrepPlanCacheSize) PreparedPlanCacheMemoryGuardRatio = atomic.NewFloat64(DefTiDBPrepPlanCacheMemoryGuardRatio) + EnableConcurrentDDL = atomic.NewBool(DefTiDBEnableConcurrentDDL) ) var (