Skip to content

Commit

Permalink
Use tidb_isolation_read_engine instead of hint
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySon-Huang committed Nov 9, 2023
1 parent b092db0 commit 1da01d6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 36 deletions.
37 changes: 19 additions & 18 deletions tests/fullstack-test2/ddl/alter_partition_by.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
+---------+---------+----------+
Expand Down Expand Up @@ -56,30 +56,30 @@ 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(*) |
+----------+
| 8 |
+----------+

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(*) |
+----------+
| 8 |
+----------+

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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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 |
+---------+---------+----------+
Expand All @@ -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 │
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand Down
34 changes: 28 additions & 6 deletions tests/fullstack-test2/ddl/remove_partitioning.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,58 @@ 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(*) |
+----------+
| 8 |
+----------+

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(*) |
+----------+
| 8 |
+----------+

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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand Down
24 changes: 12 additions & 12 deletions tests/fullstack-test2/ddl/reorganize_partition.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ 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(*) |
+----------+
| 8 |
+----------+

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(*) |
+----------+
| 8 |
+----------+

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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand All @@ -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(*) |
+----------+
Expand Down Expand Up @@ -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 |
+----+------+----+
Expand Down

0 comments on commit 1da01d6

Please sign in to comment.