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

table partition: set tidb_enable_exchange_partition default on #37284

Merged
merged 63 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
5f5e312
add tiflash test
ymkzpx Aug 4, 2022
561a1f0
fix AutoID
ymkzpx Aug 5, 2022
fe4cbcd
Merge branch 'master' into exchange-partition-test
ymkzpx Aug 5, 2022
901ccfc
fix
ymkzpx Aug 5, 2022
33708d0
Merge branch 'exchange-partition-test' of github.com:ymkzpx/tidb into…
ymkzpx Aug 5, 2022
9368775
fix test
ymkzpx Aug 5, 2022
40f8607
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 5, 2022
68f7744
fix
ymkzpx Aug 5, 2022
fc7610b
fix test
ymkzpx Aug 5, 2022
958ab86
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 5, 2022
9c52285
fix
ymkzpx Aug 5, 2022
157b7bd
address comment
ymkzpx Aug 9, 2022
1188b38
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 9, 2022
4115c4b
fix
ymkzpx Aug 9, 2022
8628dad
failpoint replace hook
ymkzpx Aug 11, 2022
4537e26
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 11, 2022
567111b
adress comment
ymkzpx Aug 12, 2022
5a37c6e
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 12, 2022
1e5f9f4
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 12, 2022
e635904
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 12, 2022
9eacb62
add test
ymkzpx Aug 13, 2022
52457b4
address conflict
ymkzpx Aug 13, 2022
6ad4fd2
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 18, 2022
6538393
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
074a16c
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
b73aaca
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
5231399
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
7573e2e
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
49cf0e0
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
fc60fb8
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
94b6965
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
9016343
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 19, 2022
ffc47b4
fix test
ymkzpx Aug 20, 2022
86ea099
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 20, 2022
adf8a8f
Merge branch 'exchange-partition-test' of github.com:ymkzpx/tidb into…
ymkzpx Aug 20, 2022
b03985c
Merge branch 'master' into exchange-partition-test
ymkzpx Aug 22, 2022
36fdf11
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 22, 2022
20b8216
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 22, 2022
985f988
Merge branch 'master' into exchange-partition-test
ti-chi-bot Aug 22, 2022
ef2d045
fix
ymkzpx Aug 22, 2022
ebd7f3b
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 22, 2022
c144787
Merge branch 'exchange-partition-test' of github.com:ymkzpx/tidb into…
ymkzpx Aug 22, 2022
095159f
add test
ymkzpx Aug 22, 2022
cdc9382
fix test
ymkzpx Aug 23, 2022
691c3f5
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 23, 2022
22d164a
Merge branch 'master' into exchange-partition-test
ymkzpx Aug 24, 2022
74960ad
fix test
ymkzpx Aug 24, 2022
36e40bd
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 24, 2022
82b4e55
Merge branch 'exchange-partition-test' of github.com:ymkzpx/tidb into…
ymkzpx Aug 24, 2022
4600d25
fix
ymkzpx Aug 24, 2022
3f5a595
fix
ymkzpx Aug 24, 2022
3e00c47
fix
ymkzpx Aug 24, 2022
fdd57db
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 24, 2022
c92a867
Merge branch 'master' of github.com:pingcap/tidb into exchange-partit…
ymkzpx Aug 28, 2022
9eb3141
Update sessionctx/variable/sysvar.go
ymkzpx Sep 9, 2022
1b9ed91
address conflict
ymkzpx Sep 9, 2022
b505bc1
Merge branch 'exchange-partition-test' of github.com:ymkzpx/tidb into…
ymkzpx Sep 9, 2022
05d2243
fix ut
ymkzpx Sep 9, 2022
87724a6
Merge branch 'exchange-partition-test' of github.com:ymkzpx/tidb into…
ymkzpx Sep 9, 2022
22d270e
fix
ymkzpx Sep 9, 2022
c2d4f19
Update sessionctx/variable/sysvar.go
ymkzpx Sep 16, 2022
79fae76
Merge branch 'master' into exchange-partition-test
ymkzpx Sep 16, 2022
7f0fa48
Merge branch 'master' into exchange-partition-test
ti-chi-bot Sep 19, 2022
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
34 changes: 29 additions & 5 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1861,11 +1861,6 @@ func TestAlterTableExchangePartition(t *testing.T) {
id INT NOT NULL
);`)
tk.MustExec(`INSERT INTO e VALUES (1669),(337),(16),(2005)`)
// test disable exchange partition
tk.MustExec("ALTER TABLE e EXCHANGE PARTITION p0 WITH TABLE e2")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 8200 Exchange Partition is disabled, please set 'tidb_enable_exchange_partition' if you need to need to enable it"))
tk.MustQuery("select * from e").Check(testkit.Rows("16", "1669", "337", "2005"))
tk.MustQuery("select * from e2").Check(testkit.Rows())

// enable exchange partition
tk.MustExec("set @@tidb_enable_exchange_partition=1")
Expand Down Expand Up @@ -2440,6 +2435,35 @@ func TestExchangePartitionAutoID(t *testing.T) {
tk.MustQuery("select count(*) from pt where a >= 4000000").Check(testkit.Rows("1"))
}

func TestTiDBEnableExchangePartition(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec(`create table pt (a int primary key auto_increment) partition by range(a) (
partition p0 values less than (3),
partition p1 values less than (6),
PARTITION p2 values less than (9)
);`)
// default
tk.MustExec(`create table nt(a int primary key auto_increment);`)
tk.MustExec("alter table pt exchange partition p0 with table nt")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 after the exchange, please analyze related table of the exchange to update statistics"))

// set tidb_enable_exchange_partition = 0
tk.MustExec("set @@tidb_enable_exchange_partition=0")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 tidb_enable_exchange_partition is always turned on, this variable will be deleted later"))
tk.MustExec("alter table pt exchange partition p0 with table nt")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 after the exchange, please analyze related table of the exchange to update statistics"))

// set tidb_enable_exchange_partition = 1
tk.MustExec("set @@tidb_enable_exchange_partition=1")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 tidb_enable_exchange_partition is always turned on, this variable will be deleted later"))
tk.MustExec("alter table pt exchange partition p0 with table nt")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 after the exchange, please analyze related table of the exchange to update statistics"))
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 after the exchange, please analyze related table of the exchange to update statistics"))
}

func TestExchangePartitionExpressIndex(t *testing.T) {
restore := config.RestoreFunc()
defer restore()
Expand Down
4 changes: 0 additions & 4 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3981,10 +3981,6 @@ func checkExchangePartition(pt *model.TableInfo, nt *model.TableInfo) error {
}

func (d *ddl) ExchangeTablePartition(ctx sessionctx.Context, ident ast.Ident, spec *ast.AlterTableSpec) error {
if !ctx.GetSessionVars().TiDBEnableExchangePartition {
ctx.GetSessionVars().StmtCtx.AppendWarning(dbterror.ErrExchangePartitionDisabled)
return nil
}
ptSchema, pt, err := d.getSchemaAndTableByIdent(ctx, ident)
if err != nil {
return errors.Trace(err)
Expand Down
3 changes: 1 addition & 2 deletions ddl/placement_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2060,8 +2060,7 @@ func TestPDFail(t *testing.T) {
checkAllBundlesNotChange(t, existBundles)

// exchange partition
tk.MustExec("alter table tp exchange partition p1 with table t1")
require.True(t, infosync.ErrHTTPServiceError.Equal(err))
tk.MustGetErrCode("alter table tp exchange partition p1 with table t1", mysql.ErrTablesDifferentMetadata)
tk.MustQuery("show create table t1").Check(testkit.Rows("t1 CREATE TABLE `t1` (\n" +
" `id` int(11) DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
Expand Down
3 changes: 2 additions & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,8 @@ var defaultSysVars = []*SysVar{
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableExchangePartition, Value: BoolToOnOff(DefTiDBEnableExchangePartition), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
s.TiDBEnableExchangePartition = TiDBOptOn(val)
s.StmtCtx.AppendWarning(errors.New("tidb_enable_exchange_partition is always turned on, this variable will be deleted later"))
ymkzpx marked this conversation as resolved.
Show resolved Hide resolved
s.TiDBEnableExchangePartition = true
ymkzpx marked this conversation as resolved.
Show resolved Hide resolved
return nil
}},
// It's different from tmp_table_size or max_heap_table_size. See https://github.com/pingcap/tidb/issues/28691.
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ const (
DefTiDBAnalyzeVersion = 2
DefTiDBEnableIndexMergeJoin = false
DefTiDBTrackAggregateMemoryUsage = true
DefTiDBEnableExchangePartition = false
DefTiDBEnableExchangePartition = true
DefCTEMaxRecursionDepth = 1000
DefTiDBTmpTableMaxSize = 64 << 20 // 64MB.
DefTiDBEnableLocalTxn = false
Expand Down