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

variables: add concurrent DDL switch #35028

Merged
merged 15 commits into from
Jun 6, 2022
Merged
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
8 changes: 8 additions & 0 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,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 Expand Up @@ -1884,4 +1890,6 @@ const (
RandSeed1 = "rand_seed1"
// RandSeed2 is the name of 'rand_seed2' system variable.
RandSeed2 = "rand_seed2"
// TiDBEnableConcurrentDDL indicates whether to enable the new DDL framework.
TiDBEnableConcurrentDDL = "tidb_enable_concurrent_ddl"
xiongjiwei marked this conversation as resolved.
Show resolved Hide resolved
)
2 changes: 2 additions & 0 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ const (
DefTiDBEnablePrepPlanCache = true
DefTiDBPrepPlanCacheSize = 100
DefTiDBPrepPlanCacheMemoryGuardRatio = 0.1
DefTiDBEnableConcurrentDDL = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe default enable it after all test is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

enable it by default is helpful for running unit-test, and I think it does not matter since there is no new tidb release before delivery of the feature.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, We can create a new pipeline to enable this switch to test.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you plan to just change the default for tests, see #34755 (it gets a bit cleaner with this PR).

)

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

var (
Expand Down