From 1da01d64c039e8c37967e1f55e192118e7a23928 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Wed, 8 Nov 2023 18:26:37 +0800 Subject: [PATCH] Use tidb_isolation_read_engine instead of hint --- .../ddl/alter_partition_by.test | 37 ++++++++++--------- .../ddl/remove_partitioning.test | 34 ++++++++++++++--- .../ddl/reorganize_partition.test | 24 ++++++------ 3 files changed, 59 insertions(+), 36 deletions(-) diff --git a/tests/fullstack-test2/ddl/alter_partition_by.test b/tests/fullstack-test2/ddl/alter_partition_by.test index a05f2a43ce2..a9569c1332b 100644 --- a/tests/fullstack-test2/ddl/alter_partition_by.test +++ b/tests/fullstack-test2/ddl/alter_partition_by.test @@ -28,7 +28,7 @@ mysql> insert into test.t select a+1000000,a+1000000,-(a+1000000) from test.t; func> wait_table test t -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ * from test.t order by a; +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t order by a; +---------+---------+----------+ | a | b | c | +---------+---------+----------+ @@ -56,7 +56,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ * from test.t order by a; │ test │ t │ └───────────────┴───────────┘ -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -64,7 +64,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition ( +----------+ mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -72,14 +72,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio +----------+ mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ | 8 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ @@ -90,7 +90,7 @@ mysql> show warnings; mysql> alter table test.t partition by range (a) (partition p0 values less than (500000), partition p500k values less than (1000000), partition p1M values less than (2000000)); -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -99,7 +99,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p500k); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p500k); +----------+ | count(*) | +----------+ @@ -108,14 +108,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ | 4 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p500k); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p500k); +----------+ | count(*) | +----------+ @@ -124,14 +124,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition ( mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ | 8 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ @@ -144,7 +144,7 @@ mysql> alter table test.t2 set tiflash replica 1; mysql> insert into test.t2 select * from test.t; func> wait_table test t2 -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ * from test.t2 order by a; +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t2 order by a; +---------+---------+----------+ | a | b | c | +---------+---------+----------+ @@ -168,6 +168,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ * from test.t2 order by a; mysql> drop table test.t; +# check the t2 is created in TiFlash >> select tidb_database,tidb_name from system.tables where tidb_database = 'test' and tidb_name = 't2' and is_tombstone = 0 ┌─tidb_database─┬─tidb_name─┐ │ test │ t2 │ @@ -176,7 +177,7 @@ mysql> drop table test.t; mysql> alter table test.t2 partition by hash (a) partitions 3; mysql> analyze table test.t2; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ count(*) from test.t2 partition (p0); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t2 partition (p0); +----------+ | count(*) | +----------+ @@ -185,7 +186,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ count(*) from test.t2 partit mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ count(*) from test.t2 partition (p1); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t2 partition (p1); +----------+ | count(*) | +----------+ @@ -194,14 +195,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ count(*) from test.t2 partit mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t2]) */ count(*) from test.t2 partition (p0); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t2 partition (p0); +----------+ | count(*) | +----------+ | 5 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIKV[t2]) */ count(*) from test.t2 partition (p1); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t2 partition (p1); +----------+ | count(*) | +----------+ @@ -211,14 +212,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIKV[t2]) */ count(*) from test.t2 partition mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t2]) */ count(*) from test.t2 partition (p2); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t2 partition (p2); +----------+ | count(*) | +----------+ | 5 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t2]) */ count(*) from test.t2 partition (p2); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t2 partition (p2); +----------+ | count(*) | +----------+ diff --git a/tests/fullstack-test2/ddl/remove_partitioning.test b/tests/fullstack-test2/ddl/remove_partitioning.test index 2f8f9574be8..2ce14aa9cc4 100644 --- a/tests/fullstack-test2/ddl/remove_partitioning.test +++ b/tests/fullstack-test2/ddl/remove_partitioning.test @@ -28,13 +28,35 @@ mysql> insert into test.t select a+1000000,a+1000000,-(a+1000000) from test.t; func> wait_table test t +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++---------+---------+----------+ +| a | b | c | ++---------+---------+----------+ +| 1 | 1 | -1 | +| 2 | 2 | -2 | +| 3 | 3 | -3 | +| 4 | 4 | -4 | +| 500001 | 500001 | -500001 | +| 500002 | 500002 | -500002 | +| 500003 | 500003 | -500003 | +| 500004 | 500004 | -500004 | +| 1000001 | 1000001 | -1000001 | +| 1000002 | 1000002 | -1000002 | +| 1000003 | 1000003 | -1000003 | +| 1000004 | 1000004 | -1000004 | +| 1500001 | 1500001 | -1500001 | +| 1500002 | 1500002 | -1500002 | +| 1500003 | 1500003 | -1500003 | +| 1500004 | 1500004 | -1500004 | ++---------+---------+----------+ + # check table info in tiflash >> select tidb_database,tidb_name from system.tables where tidb_database = 'test' and tidb_name = 't' and is_tombstone = 0 ┌─tidb_database─┬─tidb_name─┐ │ test │ t │ └───────────────┴───────────┘ -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -42,7 +64,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition ( +----------+ mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -50,14 +72,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio +----------+ mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ | 8 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ @@ -68,7 +90,7 @@ mysql> show warnings; mysql> alter table test.t remove partitioning; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t; +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t; +----------+ | count(*) | +----------+ @@ -77,7 +99,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t; mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t; +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t; +----------+ | count(*) | +----------+ diff --git a/tests/fullstack-test2/ddl/reorganize_partition.test b/tests/fullstack-test2/ddl/reorganize_partition.test index 971a4ce8341..9453bc373e3 100644 --- a/tests/fullstack-test2/ddl/reorganize_partition.test +++ b/tests/fullstack-test2/ddl/reorganize_partition.test @@ -34,7 +34,7 @@ func> wait_table test t │ test │ t │ └───────────────┴───────────┘ -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -42,7 +42,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition ( +----------+ mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -50,14 +50,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio +----------+ mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ | 8 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ @@ -68,7 +68,7 @@ mysql> show warnings; mysql> alter table test.t reorganize partition p0 INTO (partition p0 values less than (500000), partition p500k values less than (1000000)); -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ @@ -77,7 +77,7 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p500k); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p500k); +----------+ | count(*) | +----------+ @@ -86,14 +86,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partitio mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p0); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p0); +----------+ | count(*) | +----------+ | 4 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p500k); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p500k); +----------+ | count(*) | +----------+ @@ -102,14 +102,14 @@ mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition ( mysql> show warnings; -mysql> select /*+ READ_FROM_STORAGE(TIKV[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tikv'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ | 8 | +----------+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[t]) */ count(*) from test.t partition (p1M); +mysql> set session tidb_isolation_read_engines='tiflash'; select count(*) from test.t partition (p1M); +----------+ | count(*) | +----------+ @@ -147,14 +147,14 @@ mysql> alter table test.t1 reorganize partition p1 INTO (partition p1 values les # make write cmd take effect >> DBGInvoke __disable_fail_point(pause_before_apply_raft_cmd) -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[test.t1]) */ * from test.t1 partition (p1); +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t1 partition (p1); +----+------+----+ | id | name | c | +----+------+----+ | 60 | cba |NULL| +----+------+----+ -mysql> select /*+ READ_FROM_STORAGE(TIFLASH[test.t1]) */ * from test.t1 partition (p2); +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t1 partition (p2); +----+------+----+ | id | name | c | +----+------+----+