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

*: Remove variable tidb_enable_alter_placement #31066

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 0 additions & 2 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ func setUpSuite(s *testDBSuite, c *C) {
c.Assert(err, IsNil)
_, err = s.s.Execute(context.Background(), "set @@global.tidb_max_delta_schema_count= 4096")
c.Assert(err, IsNil)
_, err = s.s.Execute(context.Background(), "set @@global.tidb_enable_alter_placement=1")
c.Assert(err, IsNil)
}

func tearDownSuite(s *testDBSuite, c *C) {
Expand Down
3 changes: 0 additions & 3 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ func (d *ddl) AlterTablePlacement(ctx sessionctx.Context, ident ast.Ident, place
}

func checkAndNormalizePlacement(ctx sessionctx.Context, placementPolicyRef *model.PolicyRefInfo, directPlacementOpts *model.PlacementSettings, fallbackPlacementPolicyRef *model.PolicyRefInfo, fallbackDirectPlacementOpts *model.PlacementSettings) (*model.PolicyRefInfo, *model.PlacementSettings, error) {
if !ctx.GetSessionVars().EnableAlterPlacement && (placementPolicyRef != nil || directPlacementOpts != nil) {
return nil, nil, ErrPlacementDisabled
}
if placementPolicyRef != nil && directPlacementOpts != nil {
return nil, nil, errors.Trace(ErrPlacementPolicyWithDirectOption.GenWithStackByArgs(placementPolicyRef.Name))
}
Expand Down
3 changes: 0 additions & 3 deletions ddl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ var (
// ErrPlacementPolicyInUse is returned when placement policy is in use in drop/alter.
ErrPlacementPolicyInUse = dbterror.ClassDDL.NewStd(mysql.ErrPlacementPolicyInUse)

// ErrPlacementDisabled is returned when tidb_enable_alter_placement = 0
ErrPlacementDisabled = dbterror.ClassDDL.NewStdErr(mysql.ErrUnsupportedDDLOperation, parser_mysql.Message("Alter Placement Rule is disabled, please set 'tidb_enable_alter_placement' if you need to enable it", nil))

// ErrMultipleDefConstInListPart returns multiple definition of same constant in list partitioning.
ErrMultipleDefConstInListPart = dbterror.ClassDDL.NewStd(mysql.ErrMultipleDefConstInListPart)

Expand Down
43 changes: 1 addition & 42 deletions ddl/placement_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package ddl_test

import (
"context"
"fmt"
"sort"

Expand All @@ -34,13 +33,11 @@ import (
func (s *testDBSuite1) TestPlacementPolicyCache(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.Se.GetSessionVars().EnableAlterPlacement = true
tk.MustExec("set @@tidb_enable_exchange_partition = 1")
defer func() {
tk.MustExec("set @@tidb_enable_exchange_partition = 0")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
tk.Se.GetSessionVars().EnableAlterPlacement = false
}()

initTable := func() []string {
Expand Down Expand Up @@ -103,10 +100,8 @@ func (s *testSerialDBSuite) TestTxnScopeConstraint(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.Se.GetSessionVars().EnableAlterPlacement = true
defer func() {
tk.MustExec("drop table if exists t1")
tk.Se.GetSessionVars().EnableAlterPlacement = false
}()

tk.MustExec(`create table t1 (c int)
Expand Down Expand Up @@ -257,13 +252,11 @@ func (s *testDBSuite6) TestCreateSchemaWithPlacement(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("drop schema if exists SchemaDirectPlacementTest")
tk.MustExec("drop schema if exists SchemaPolicyPlacementTest")
tk.Se.GetSessionVars().EnableAlterPlacement = true
defer func() {
tk.MustExec("drop schema if exists SchemaDirectPlacementTest")
tk.MustExec("drop schema if exists SchemaPolicyPlacementTest")
tk.MustExec("drop placement policy if exists PolicySchemaTest")
tk.MustExec("drop placement policy if exists PolicyTableTest")
tk.Se.GetSessionVars().EnableAlterPlacement = false
}()

tk.MustExec(`CREATE SCHEMA SchemaDirectPlacementTest PRIMARY_REGION='nl' REGIONS = "se,nz,nl" FOLLOWERS=3`)
Expand Down Expand Up @@ -445,42 +438,8 @@ func (s *testDBSuite6) TestAlterDBPlacement(c *C) {
))
}

func (s *testDBSuite6) TestEnablePlacementCheck(c *C) {

tk := testkit.NewTestKit(c, s.store)
se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_alter_placement=1")
c.Assert(err, IsNil)

tk.MustExec("drop database if exists TestPlacementDB;")
tk.MustExec("create database TestPlacementDB;")
tk.MustExec("use TestPlacementDB;")
tk.MustExec("drop placement policy if exists placement_x;")
tk.MustExec("create placement policy placement_x PRIMARY_REGION=\"cn-east-1\", REGIONS=\"cn-east-1\";")
se.GetSessionVars().EnableAlterPlacement = true
tk.MustExec("create table t(c int) partition by range (c) (partition p1 values less than (200) followers=2);")
defer func() {
tk.MustExec("drop database if exists TestPlacementDB;")
tk.MustExec("drop placement policy if exists placement_x;")
}()

tk.Se.GetSessionVars().EnableAlterPlacement = false
tk.MustGetErrCode("create database TestPlacementDB2 followers=2;", mysql.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("alter database TestPlacementDB placement policy=placement_x", mysql.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("create table t (c int) FOLLOWERS=2;", mysql.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("alter table t voters=2;", mysql.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("create table m (c int) partition by range (c) (partition p1 values less than (200) followers=2);", mysql.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("alter table t partition p1 placement policy=\"placement_x\";", mysql.ErrUnsupportedDDLOperation)
}

func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {
tk := testkit.NewTestKit(c, s.store)
se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_alter_placement=1")
c.Assert(err, IsNil)

c.Assert(failpoint.Enable("github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount", `return(true)`), IsNil)
defer func() {
err := failpoint.Disable("github.com/pingcap/tidb/infoschema/mockTiFlashStoreCount")
Expand All @@ -501,7 +460,7 @@ func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {
defer tk.MustExec("drop table if exists tp")
tk.MustExec("alter table tp set tiflash replica 1")

err = tk.ExecToErr("alter table tp placement policy p1")
err := tk.ExecToErr("alter table tp placement policy p1")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
err = tk.ExecToErr("alter table tp primary_region='r2' regions='r2'")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
Expand Down
6 changes: 1 addition & 5 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,17 +530,13 @@ func (s *testSerialSuite) TestCreateTableWithLike(c *C) {

func (s *testSerialSuite) TestCreateTableWithLikeAtTemporaryMode(c *C) {
tk := testkit.NewTestKit(c, s.store)
se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_alter_placement=1")
c.Assert(err, IsNil)

// Test create table like at temporary mode.
tk.MustExec("use test")
tk.MustExec("drop table if exists temporary_table;")
tk.MustExec("create global temporary table temporary_table (a int, b int,index(a)) on commit delete rows")
tk.MustExec("drop table if exists temporary_table_t1;")
_, err = tk.Exec("create table temporary_table_t1 like temporary_table")
_, err := tk.Exec("create table temporary_table_t1 like temporary_table")
c.Assert(err.Error(), Equals, core.ErrOptOnTemporaryTable.GenWithStackByArgs("create table like").Error())
tk.MustExec("drop table if exists temporary_table;")

Expand Down
1 change: 0 additions & 1 deletion docs/design/2021-07-29-hidden-sysvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ There are currently ~20 hidden system variables:
| tidb_enable_pipelined_window_function | ‘Pipelined window function’ feature | #1 Stable |
| tidb_enable_change_multi_schema | ‘Change multi schema in one statement’ feature. | #3 In Development Feature |
| tidb_enable_point_get_cache | ‘point get cache’ feature | #2 Experimental |
| tidb_enable_alter_placement | placement rules in SQL feature | #3 In Development Feature |
| tidb_enable_extended_stats | ‘extended stats’ feature | #2 Experimental |
| tidb_partition_prune_mode | Is partition prune mode dynamic or static | #2 Experimental |
| tidb_enable_async_commit | Support Async Commit PRD | #1 Stable |
Expand Down
2 changes: 0 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ func (s *baseTestSuite) SetUpSuite(c *C) {
c.Assert(err, IsNil)
se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_alter_placement=1")
c.Assert(err, IsNil)
se.Close()
d.SetStatsUpdating(true)
s.domain = d
Expand Down
1 change: 0 additions & 1 deletion privilege/privileges/privileges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2595,7 +2595,6 @@ func TestInformationSchemaPlacmentRulesPrivileges(t *testing.T) {
}()
tk.MustExec("CREATE DATABASE placement_rule_db")
tk.MustExec("USE placement_rule_db")
tk.Session().GetSessionVars().EnableAlterPlacement = true
tk.MustExec(`CREATE TABLE placement_rule_table_se (a int) PRIMARY_REGION="se" REGIONS="se,nl"`)
tk.MustExec(`CREATE TABLE placement_rule_table_nl (a int) PRIMARY_REGION="nl" REGIONS="se,nl"`)
tk.MustQuery(`SELECT * FROM information_schema.placement_rules WHERE SCHEMA_NAME = "placement_rule_db"`).Sort().Check(testkit.Rows(
Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,9 +719,6 @@ type SessionVars struct {
// EnablePointGetCache is used to cache value for point get for read only scenario.
EnablePointGetCache bool

// EnableAlterPlacement indicates whether a user can alter table partition placement rules.
EnableAlterPlacement bool

// EnablePlacementChecks indicates whether a user can check validation of placement.
EnablePlacementChecks bool

Expand Down Expand Up @@ -1197,7 +1194,6 @@ func NewSessionVars() *SessionVars {
ShardAllocateStep: DefTiDBShardAllocateStep,
EnableChangeMultiSchema: DefTiDBChangeMultiSchema,
EnablePointGetCache: DefTiDBPointGetCache,
EnableAlterPlacement: DefTiDBEnableAlterPlacement,
EnableAmendPessimisticTxn: DefTiDBEnableAmendPessimisticTxn,
PartitionPruneMode: *atomic2.NewString(DefTiDBPartitionPruneMode),
TxnScope: kv.NewDefaultTxnScopeVar(),
Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,6 @@ var defaultSysVars = []*SysVar{
s.EnablePointGetCache = TiDBOptOn(val)
return nil
}},
{Scope: ScopeGlobal, Name: TiDBEnableAlterPlacement, Value: BoolToOnOff(DefTiDBEnableAlterPlacement), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
s.EnableAlterPlacement = TiDBOptOn(val)
return nil
}},
morgo marked this conversation as resolved.
Show resolved Hide resolved
{Scope: ScopeSession, Name: TiDBForcePriority, skipInit: true, Value: mysql.Priority2Str[DefTiDBForcePriority], SetSession: func(s *SessionVars, val string) error {
atomic.StoreInt32(&ForcePriority, int32(mysql.Str2Priority(val)))
return nil
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/sysvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ func TestSettersandGetters(t *testing.T) {
// There are some historial exceptions where global variables are loaded into the session.
// Please don't add to this list, the behavior is not MySQL compatible.
switch sv.Name {
case TiDBEnableChangeMultiSchema, TiDBDDLReorgBatchSize, TiDBEnableAlterPlacement,
case TiDBEnableChangeMultiSchema, TiDBDDLReorgBatchSize,
TiDBMaxDeltaSchemaCount, InitConnect, MaxPreparedStmtCount,
TiDBDDLReorgWorkerCount, TiDBDDLErrorCountLimit, TiDBRowFormatVersion,
TiDBEnableTelemetry, TiDBEnablePointGetCache:
Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,6 @@ const (
// TiDBEnablePointGetCache is used to control whether to enable the point get cache for special scenario.
TiDBEnablePointGetCache = "tidb_enable_point_get_cache"

// TiDBEnableAlterPlacement is used to control whether to enable alter table partition.
TiDBEnableAlterPlacement = "tidb_enable_alter_placement"

// tidb_max_delta_schema_count defines the max length of deltaSchemaInfos.
// deltaSchemaInfos is a queue that maintains the history of schema changes.
TiDBMaxDeltaSchemaCount = "tidb_max_delta_schema_count"
Expand Down Expand Up @@ -713,7 +710,6 @@ const (
DefTiDBMaxDeltaSchemaCount = 1024
DefTiDBChangeMultiSchema = false
DefTiDBPointGetCache = false
DefTiDBEnableAlterPlacement = false
DefTiDBEnableAutoIncrementInGenerated = false
DefTiDBHashAggPartialConcurrency = ConcurrencyUnset
DefTiDBHashAggFinalConcurrency = ConcurrencyUnset
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func (sv *SysVar) SkipInit() bool {
// These a special "Global-only" sysvars that for backward compatibility
// are currently cached in the session. Please don't add to this list.
switch sv.Name {
case TiDBEnableChangeMultiSchema, TiDBDDLReorgBatchSize, TiDBEnableAlterPlacement,
case TiDBEnableChangeMultiSchema, TiDBDDLReorgBatchSize,
TiDBMaxDeltaSchemaCount, InitConnect, MaxPreparedStmtCount,
TiDBDDLReorgWorkerCount, TiDBDDLErrorCountLimit, TiDBRowFormatVersion,
TiDBEnableTelemetry, TiDBEnablePointGetCache:
Expand Down