mark some file to been opensource for ce-farm
This commit is contained in:
@ -0,0 +1,300 @@
|
||||
drop database if exists duptable_database;
|
||||
create database duptable_database;
|
||||
use duptable_database;
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
drop table if exists dup_t1;
|
||||
drop table if exists dup_t2;
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table dup_t1;
|
||||
Table Create Table
|
||||
dup_t1 CREATE TABLE `dup_t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
show create table dup_t2;
|
||||
Table Create Table
|
||||
dup_t2 CREATE TABLE `dup_t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
select * from t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from dup_t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
select * from dup_t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
0
|
||||
duplicate_scope
|
||||
0
|
||||
准备: 将复制表的leader和普通表的leader分开
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
t1 语句查询普通表和复制表的场景
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
select * from t2, dup_t2 where t2.d1 = dup_t2.d1;
|
||||
d1 d2 d3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
4 4 4 4 4 4
|
||||
t2 复制表插入然后再做多表查询
|
||||
begin;
|
||||
insert into dup_t1 values (11, 11, 11);
|
||||
insert into dup_t2 values (11, 11, 11);
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
c1 c2 c3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
11 11 11 11 11 11
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
d1 d2 d3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
4 4 4 4 4 4
|
||||
commit;
|
||||
t3 复制表先查询,在做插入
|
||||
begin;
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
c1 c2 c3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
11 11 11 11 11 11
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
d1 d2 d3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
4 4 4 4 4 4
|
||||
insert into dup_t1 values (22, 22, 22);
|
||||
insert into dup_t2 values (22, 22, 22);
|
||||
commit;
|
||||
t4 复制表先查询,后插入,再查询
|
||||
begin;
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
c1 c2 c3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
11 11 11 11 11 11
|
||||
22 22 22 22 22 22
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
d1 d2 d3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
4 4 4 4 4 4
|
||||
insert into dup_t1 values (33, 33, 33);
|
||||
insert into dup_t2 values (33, 33, 33);
|
||||
insert into t1 values (33, 33, 33);
|
||||
insert into t2 values (33, 33, 33);
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
c1 c2 c3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
11 11 11 11 11 11
|
||||
22 22 22 22 22 22
|
||||
33 33 33 33 33 33
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
33 33 33 33 33 33
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
d1 d2 d3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
4 4 4 4 4 4
|
||||
33 33 33 33 33 33
|
||||
commit;
|
||||
t5 单表查询
|
||||
begin;
|
||||
select * from t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
33 33 33
|
||||
select * from dup_t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
11 11 11
|
||||
22 22 22
|
||||
33 33 33
|
||||
select * from t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
33 33 33
|
||||
select * from dup_t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
11 11 11
|
||||
22 22 22
|
||||
33 33 33
|
||||
commit;
|
||||
t6 测试单分区事务在执行的过程中,查询复制表的场景
|
||||
begin;
|
||||
insert into t1 values(44, 44, 44);
|
||||
select * from t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
33 33 33
|
||||
44 44 44
|
||||
select * from dup_t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
11 11 11
|
||||
22 22 22
|
||||
33 33 33
|
||||
commit;
|
||||
t7 测试单分区事务在执行过程中,和复制表做join的场景
|
||||
begin;
|
||||
insert into t1 values(55, 55, 55);
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
33 33 33 33 33 33
|
||||
commit;
|
||||
将普通表leader切回来
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
use duptable_database;
|
||||
t6 测试一阶段提交
|
||||
begin;
|
||||
insert into t1 values(66, 66, 66);
|
||||
insert into dup_t1 values(66, 66, 66);
|
||||
insert into t2 values(66, 66, 66);
|
||||
commit;
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
33 33 33 33 33 33
|
||||
66 66 66 66 66 66
|
||||
begin;
|
||||
insert into t1 values(77, 77, 77);
|
||||
select * from dup_t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
11 11 11
|
||||
22 22 22
|
||||
33 33 33
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
c1 c2 c3 c1 c2 c3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
3 3 3 3 3 3
|
||||
33 33 33 33 33 33
|
||||
66 66 66 66 66 66
|
||||
insert into t2 values(77, 77, 77);
|
||||
select * from t2, dup_t2 where dup_t2.d1 = t2.d1;
|
||||
d1 d2 d3 d1 d2 d3
|
||||
1 1 1 1 1 1
|
||||
2 2 2 2 2 2
|
||||
4 4 4 4 4 4
|
||||
33 33 33 33 33 33
|
||||
commit;
|
||||
use duptable_database;
|
||||
drop table if exists tt2;
|
||||
drop table if exists dup2;
|
||||
CREATE TABLE `tt2` (
|
||||
`x` int(11) DEFAULT NULL,
|
||||
`y` int(11) DEFAULT NULL
|
||||
) partition by hash(x) partitions 2;
|
||||
CREATE TABLE `dup2` (
|
||||
`x` int(11) DEFAULT NULL,
|
||||
`y` int(11) DEFAULT NULL
|
||||
) duplicate_scope='cluster';
|
||||
insert into tt2 values(1,2),(3,4);
|
||||
insert into dup2 select * from tt2;
|
||||
select * from dup2 order by 1;
|
||||
x y
|
||||
1 2
|
||||
3 4
|
||||
drop table if exists tt2;
|
||||
drop table if exists dup2;
|
||||
@ -0,0 +1,64 @@
|
||||
set @@session.recyclebin=off;
|
||||
create database duptable_database;
|
||||
use duptable_database;
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
drop table if exists dup_t1;
|
||||
drop table if exists dup_t2;
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table dup_t1;
|
||||
Table Create Table
|
||||
dup_t1 CREATE TABLE `dup_t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
show create table dup_t2;
|
||||
Table Create Table
|
||||
dup_t2 CREATE TABLE `dup_t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
0
|
||||
duplicate_scope
|
||||
0
|
||||
准备: 将复制表的leader和普通表的leader分开
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
1
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
1
|
||||
@ -0,0 +1,164 @@
|
||||
alter system set_tp tp_name = ERRSIM_DUP_TABLE_GC_RIGHT_NOW, error_code = 4016, frequency = 0;
|
||||
alter system set_tp tp_name = ERRSIM_DUP_TABLE_GC_RIGHT_NOW, error_code = 4016, frequency = 1;
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
create table dup_t3 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 5;
|
||||
create table dup_t4 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 30;
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table dup_t1;
|
||||
Table Create Table
|
||||
dup_t1 CREATE TABLE `dup_t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
show create table dup_t2;
|
||||
Table Create Table
|
||||
dup_t2 CREATE TABLE `dup_t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
show create table dup_t3;
|
||||
Table Create Table
|
||||
dup_t3 CREATE TABLE `dup_t3` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) DEFAULT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
partition by hash(d1)
|
||||
(partition `p0`,
|
||||
partition `p1`,
|
||||
partition `p2`,
|
||||
partition `p3`,
|
||||
partition `p4`)
|
||||
show create table dup_t4;
|
||||
Table Create Table
|
||||
dup_t4 CREATE TABLE `dup_t4` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) DEFAULT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
partition by hash(d1)
|
||||
(partition `p0`,
|
||||
partition `p1`,
|
||||
partition `p2`,
|
||||
partition `p3`,
|
||||
partition `p4`,
|
||||
partition `p5`,
|
||||
partition `p6`,
|
||||
partition `p7`,
|
||||
partition `p8`,
|
||||
partition `p9`,
|
||||
partition `p10`,
|
||||
partition `p11`,
|
||||
partition `p12`,
|
||||
partition `p13`,
|
||||
partition `p14`,
|
||||
partition `p15`,
|
||||
partition `p16`,
|
||||
partition `p17`,
|
||||
partition `p18`,
|
||||
partition `p19`,
|
||||
partition `p20`,
|
||||
partition `p21`,
|
||||
partition `p22`,
|
||||
partition `p23`,
|
||||
partition `p24`,
|
||||
partition `p25`,
|
||||
partition `p26`,
|
||||
partition `p27`,
|
||||
partition `p28`,
|
||||
partition `p29`)
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
insert into dup_t3 select * from t1;
|
||||
insert into dup_t4 select * from t2;
|
||||
select * from t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from dup_t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
select * from dup_t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
select * from dup_t3;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from dup_t4;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
0
|
||||
duplicate_scope
|
||||
0
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
5
|
||||
count(*)
|
||||
30
|
||||
count(*)
|
||||
0
|
||||
ls_state
|
||||
LEADER
|
||||
sum(count)
|
||||
37
|
||||
sum(count)
|
||||
37
|
||||
count(*)
|
||||
0
|
||||
drop tenant duptable_tenant1 force;
|
||||
@ -0,0 +1,177 @@
|
||||
set @@recyclebin=off;
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
drop table if exists dup_t1;
|
||||
drop table if exists dup_t2;
|
||||
drop table if exists dup_t3;
|
||||
drop table if exists dup_t4;
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
create table dup_t3 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 5;
|
||||
create table dup_t4 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 30;
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10
|
||||
show create table dup_t1;
|
||||
Table Create Table
|
||||
dup_t1 CREATE TABLE `dup_t1` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` int(11) NOT NULL,
|
||||
`c3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`c1`, `c2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
show create table dup_t2;
|
||||
Table Create Table
|
||||
dup_t2 CREATE TABLE `dup_t2` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) NOT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`, `d2`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
show create table dup_t3;
|
||||
Table Create Table
|
||||
dup_t3 CREATE TABLE `dup_t3` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) DEFAULT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
partition by hash(d1)
|
||||
(partition `p0`,
|
||||
partition `p1`,
|
||||
partition `p2`,
|
||||
partition `p3`,
|
||||
partition `p4`)
|
||||
show create table dup_t4;
|
||||
Table Create Table
|
||||
dup_t4 CREATE TABLE `dup_t4` (
|
||||
`d1` int(11) NOT NULL,
|
||||
`d2` int(11) DEFAULT NULL,
|
||||
`d3` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`d1`)
|
||||
) DEFAULT CHARSET = utf8mb4 COMPRESSION = 'lz4_1.0' REPLICA_NUM = NUM BLOCK_SIZE = SIZE USE_BLOOM_FILTER = FALSE TABLET_SIZE = SIZE PCTFREE = 10 DUPLICATE_SCOPE = 'CLUSTER'
|
||||
partition by hash(d1)
|
||||
(partition `p0`,
|
||||
partition `p1`,
|
||||
partition `p2`,
|
||||
partition `p3`,
|
||||
partition `p4`,
|
||||
partition `p5`,
|
||||
partition `p6`,
|
||||
partition `p7`,
|
||||
partition `p8`,
|
||||
partition `p9`,
|
||||
partition `p10`,
|
||||
partition `p11`,
|
||||
partition `p12`,
|
||||
partition `p13`,
|
||||
partition `p14`,
|
||||
partition `p15`,
|
||||
partition `p16`,
|
||||
partition `p17`,
|
||||
partition `p18`,
|
||||
partition `p19`,
|
||||
partition `p20`,
|
||||
partition `p21`,
|
||||
partition `p22`,
|
||||
partition `p23`,
|
||||
partition `p24`,
|
||||
partition `p25`,
|
||||
partition `p26`,
|
||||
partition `p27`,
|
||||
partition `p28`,
|
||||
partition `p29`)
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
insert into dup_t3 select * from t1;
|
||||
insert into dup_t4 select * from t2;
|
||||
select * from t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from dup_t1;
|
||||
c1 c2 c3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
select * from dup_t2;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
select * from dup_t3;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from dup_t4;
|
||||
d1 d2 d3
|
||||
1 1 1
|
||||
2 2 2
|
||||
4 4 4
|
||||
count(*)
|
||||
37
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
1
|
||||
duplicate_scope
|
||||
0
|
||||
duplicate_scope
|
||||
0
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
5
|
||||
count(*)
|
||||
30
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
1
|
||||
count(*)
|
||||
5
|
||||
count(*)
|
||||
30
|
||||
count(*)
|
||||
37
|
||||
count(*)
|
||||
37
|
||||
drop tenant duptable_tenant1 force;
|
||||
@ -0,0 +1,164 @@
|
||||
drop database if exists duptable_database;
|
||||
create database duptable_database;
|
||||
use duptable_database;
|
||||
drop table if exists t1;
|
||||
drop table if exists t2;
|
||||
drop table if exists dup_t1;
|
||||
drop table if exists dup_t2;
|
||||
drop table if exists dup_t3;
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1));
|
||||
create table t2 (c1 int, c2 int, c3 int, primary key(c1));
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1)) duplicate_scope='cluster';
|
||||
create table dup_t2 (c1 int, c2 int, c3 int, primary key(c1)) duplicate_scope='cluster';
|
||||
create table dup_t3 (c1 int, c2 int, c3 int) duplicate_scope='cluster';
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
insert into t1 values(5, 5, 5);
|
||||
insert into t2 values(5, 5, 5);
|
||||
insert into dup_t1 values(5, 5, 5);
|
||||
insert into dup_t2 values(5, 5, 5);
|
||||
commit;
|
||||
insert into t1 values(6, 6, 6);
|
||||
insert into t2 values(6, 6, 6);
|
||||
insert into dup_t1 values(6, 6, 6);
|
||||
insert into dup_t2 values(6, 6, 6);
|
||||
commit;
|
||||
insert into t1 values(7, 7, 7);
|
||||
insert into t2 values(7, 7, 7);
|
||||
insert into dup_t1 values(7, 7, 7);
|
||||
insert into dup_t2 values(7, 7, 7);
|
||||
commit;
|
||||
insert into t1 values(8, 8, 8);
|
||||
insert into t2 values(8, 8, 8);
|
||||
insert into dup_t1 values(8, 8, 8);
|
||||
insert into dup_t2 values(8, 8, 8);
|
||||
commit;
|
||||
insert into t1 values(9, 9, 9);
|
||||
insert into t2 values(9, 9, 9);
|
||||
insert into dup_t1 values(9, 9, 9);
|
||||
insert into dup_t2 values(9, 9, 9);
|
||||
commit;
|
||||
insert into t1 values(10, 10, 10);
|
||||
insert into t2 values(10, 10, 10);
|
||||
insert into dup_t1 values(10, 10, 10);
|
||||
insert into dup_t2 values(10, 10, 10);
|
||||
commit;
|
||||
insert into t1 values(11, 11, 11);
|
||||
insert into t2 values(11, 11, 11);
|
||||
insert into dup_t1 values(11, 11, 11);
|
||||
insert into dup_t2 values(11, 11, 11);
|
||||
commit;
|
||||
insert into t1 values(12, 12, 12);
|
||||
insert into t2 values(12, 12, 12);
|
||||
insert into dup_t1 values(12, 12, 12);
|
||||
insert into dup_t2 values(12, 12, 12);
|
||||
commit;
|
||||
insert into t1 values(13, 13, 13);
|
||||
insert into t2 values(13, 13, 13);
|
||||
insert into dup_t1 values(13, 13, 13);
|
||||
insert into dup_t2 values(13, 13, 13);
|
||||
commit;
|
||||
insert into t1 values(14, 14, 14);
|
||||
insert into t2 values(14, 14, 14);
|
||||
insert into dup_t1 values(14, 14, 14);
|
||||
insert into dup_t2 values(14, 14, 14);
|
||||
commit;
|
||||
insert into t1 values(15, 15, 15);
|
||||
insert into t2 values(15, 15, 15);
|
||||
insert into dup_t1 values(15, 15, 15);
|
||||
insert into dup_t2 values(15, 15, 15);
|
||||
commit;
|
||||
insert into t1 values(16, 16, 16);
|
||||
insert into t2 values(16, 16, 16);
|
||||
insert into dup_t1 values(16, 16, 16);
|
||||
insert into dup_t2 values(16, 16, 16);
|
||||
commit;
|
||||
insert into t1 values(17, 17, 17);
|
||||
insert into t2 values(17, 17, 17);
|
||||
insert into dup_t1 values(17, 17, 17);
|
||||
insert into dup_t2 values(17, 17, 17);
|
||||
commit;
|
||||
insert into t1 values(18, 18, 18);
|
||||
insert into t2 values(18, 18, 18);
|
||||
insert into dup_t1 values(18, 18, 18);
|
||||
insert into dup_t2 values(18, 18, 18);
|
||||
commit;
|
||||
insert into t1 values(19, 19, 19);
|
||||
insert into t2 values(19, 19, 19);
|
||||
insert into dup_t1 values(19, 19, 19);
|
||||
insert into dup_t2 values(19, 19, 19);
|
||||
commit;
|
||||
insert into t1 values(20, 20, 20);
|
||||
insert into t2 values(20, 20, 20);
|
||||
insert into dup_t1 values(20, 20, 20);
|
||||
insert into dup_t2 values(20, 20, 20);
|
||||
commit;
|
||||
insert into t1 values(21, 21, 21);
|
||||
insert into t2 values(21, 21, 21);
|
||||
insert into dup_t1 values(21, 21, 21);
|
||||
insert into dup_t2 values(21, 21, 21);
|
||||
commit;
|
||||
insert into t1 values(22, 22, 22);
|
||||
insert into t2 values(22, 22, 22);
|
||||
insert into dup_t1 values(22, 22, 22);
|
||||
insert into dup_t2 values(22, 22, 22);
|
||||
commit;
|
||||
insert into t1 values(23, 23, 23);
|
||||
insert into t2 values(23, 23, 23);
|
||||
insert into dup_t1 values(23, 23, 23);
|
||||
insert into dup_t2 values(23, 23, 23);
|
||||
commit;
|
||||
insert into t1 values(24, 24, 24);
|
||||
insert into t2 values(24, 24, 24);
|
||||
insert into dup_t1 values(24, 24, 24);
|
||||
insert into dup_t2 values(24, 24, 24);
|
||||
commit;
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
ls_state
|
||||
LEADER
|
||||
count(*)
|
||||
23
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
use duptable_database;
|
||||
insert into dup_t3 select * from dup_t2;
|
||||
select count(*) from dup_t3;
|
||||
count(*)
|
||||
46
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
c1 c2 c3 c1 c2 c3
|
||||
@ -0,0 +1,264 @@
|
||||
# owner: weixiaoxian.wxx
|
||||
# owner group: transaction
|
||||
# test_no: 04001
|
||||
# tags: 4.x dup table
|
||||
# description: test 4.x basic dup table read write, test case same as "test_duplicate_table.test"
|
||||
|
||||
## build connect
|
||||
connect (obsys, $OBMYSQL_MS0, root@sys, "", oceanbase, $OBMYSQL_PORT);
|
||||
######## create duptable tenant
|
||||
connection obsys;
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
--source mysql_test/include/check_tenant_sync.inc
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
####### begin test dup table
|
||||
connect (conn0,$OBMYSQL_MS0,root@mysql,,test,$OBMYSQL_PORT);
|
||||
connect (conn1,$OBMYSQL_MS0,root@mysql,,test,$OBMYSQL_PORT);
|
||||
|
||||
connection conn0;
|
||||
--disable_warnings
|
||||
drop database if exists duptable_database;
|
||||
create database duptable_database;
|
||||
use duptable_database;
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--enable_warnings
|
||||
|
||||
## create dup table
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
|
||||
## create table
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t2;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t2;
|
||||
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
|
||||
select * from t1;
|
||||
select * from dup_t1;
|
||||
select * from t2;
|
||||
select * from dup_t2;
|
||||
|
||||
sleep 15;
|
||||
|
||||
connection obsys;
|
||||
let $tenant_id = query_get_value(select tenant_id from __all_tenant where tenant_name = 'mysql', tenant_id, 1);
|
||||
let $database_id = query_get_value(select database_id from __all_virtual_database where database_name = 'duptable_database' and tenant_id = $tenant_id, database_id, 1);
|
||||
|
||||
## check duplicate scope
|
||||
--disable_query_log
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
--enable_query_log
|
||||
|
||||
--echo 准备: 将复制表的leader和普通表的leader分开
|
||||
|
||||
## get table id
|
||||
let $t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
|
||||
## get ls id of dup table
|
||||
let $dup_t1_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t1_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t2_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t2_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
|
||||
## get the ip:port of dup table follower
|
||||
let $dup_t1_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t1_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t2_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
## get the ip:port of dup table leader
|
||||
let $dup_t1_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_IP, 1);
|
||||
let $dup_t1_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_IP, 1);
|
||||
let $dup_t2_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_PORT, 1);
|
||||
|
||||
## switch leader to dup table follower server
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$dup_t1_follow_ip:$dup_t1_follow_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t2_ls_id server='$dup_t2_follow_ip:$dup_t2_follow_port' tenant='mysql';
|
||||
--enable_query_log
|
||||
|
||||
## sleep 20s wait for switch
|
||||
sleep 20;
|
||||
|
||||
## check switch leader succ
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$dup_t1_follow_ip' and SVR_PORT = '$dup_t1_follow_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t2_ls_id and SVR_IP = '$dup_t2_follow_ip' and SVR_PORT = '$dup_t2_follow_port' and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
--echo t1 语句查询普通表和复制表的场景
|
||||
connection conn0;
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
select * from t2, dup_t2 where t2.d1 = dup_t2.d1;
|
||||
|
||||
--echo t2 复制表插入然后再做多表查询
|
||||
begin;
|
||||
insert into dup_t1 values (11, 11, 11);
|
||||
insert into dup_t2 values (11, 11, 11);
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
commit;
|
||||
|
||||
--echo t3 复制表先查询,在做插入
|
||||
begin;
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
insert into dup_t1 values (22, 22, 22);
|
||||
insert into dup_t2 values (22, 22, 22);
|
||||
commit;
|
||||
|
||||
--echo t4 复制表先查询,后插入,再查询
|
||||
begin;
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
insert into dup_t1 values (33, 33, 33);
|
||||
insert into dup_t2 values (33, 33, 33);
|
||||
insert into t1 values (33, 33, 33);
|
||||
insert into t2 values (33, 33, 33);
|
||||
select * from dup_t1, dup_t2 where dup_t1.c1 = dup_t2.d1;
|
||||
select * from dup_t1, t1 where dup_t1.c1 = t1.c1;
|
||||
select * from dup_t2, t2 where dup_t2.d1 = t2.d1;
|
||||
commit;
|
||||
|
||||
--echo t5 单表查询
|
||||
begin;
|
||||
select * from t1;
|
||||
select * from dup_t1;
|
||||
select * from t2;
|
||||
select * from dup_t2;
|
||||
commit;
|
||||
|
||||
--echo t6 测试单分区事务在执行的过程中,查询复制表的场景
|
||||
begin;
|
||||
insert into t1 values(44, 44, 44);
|
||||
select * from t1;
|
||||
select * from dup_t1;
|
||||
commit;
|
||||
|
||||
--echo t7 测试单分区事务在执行过程中,和复制表做join的场景
|
||||
begin;
|
||||
insert into t1 values(55, 55, 55);
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
commit;
|
||||
|
||||
--echo 将普通表leader切回来
|
||||
connection obsys;
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$dup_t1_leader_ip:$dup_t1_leader_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t2_ls_id server='$dup_t2_leader_ip:$dup_t2_leader_port' tenant='mysql';
|
||||
--enable_query_log
|
||||
|
||||
sleep 20;
|
||||
|
||||
## check switch leader succ
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$dup_t1_leader_ip' and SVR_PORT = '$dup_t1_leader_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t2_ls_id and SVR_IP = '$dup_t1_leader_ip' and SVR_PORT = '$dup_t2_leader_port' and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
connection conn1;
|
||||
use duptable_database;
|
||||
--echo t6 测试一阶段提交
|
||||
begin;
|
||||
insert into t1 values(66, 66, 66);
|
||||
insert into dup_t1 values(66, 66, 66);
|
||||
insert into t2 values(66, 66, 66);
|
||||
commit;
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
|
||||
begin;
|
||||
insert into t1 values(77, 77, 77);
|
||||
select * from dup_t2;
|
||||
select * from t1, dup_t1 where t1.c1 = dup_t1.c1;
|
||||
insert into t2 values(77, 77, 77);
|
||||
select * from t2, dup_t2 where dup_t2.d1 = t2.d1;
|
||||
commit;
|
||||
|
||||
connection conn0;
|
||||
use duptable_database;
|
||||
--disable_warnings
|
||||
--error 0,942
|
||||
drop table if exists tt2;
|
||||
--error 0,942
|
||||
drop table if exists dup2;
|
||||
--enable_warnings
|
||||
|
||||
#
|
||||
#[复制表]使用insert into select 语句插入数据会进入重试死循环
|
||||
CREATE TABLE `tt2` (
|
||||
`x` int(11) DEFAULT NULL,
|
||||
`y` int(11) DEFAULT NULL
|
||||
) partition by hash(x) partitions 2;
|
||||
|
||||
CREATE TABLE `dup2` (
|
||||
`x` int(11) DEFAULT NULL,
|
||||
`y` int(11) DEFAULT NULL
|
||||
) duplicate_scope='cluster';
|
||||
|
||||
###此处应该连备机
|
||||
insert into tt2 values(1,2),(3,4);
|
||||
insert into dup2 select * from tt2;
|
||||
sleep 10;
|
||||
select * from dup2 order by 1;
|
||||
drop table if exists tt2;
|
||||
drop table if exists dup2;
|
||||
|
||||
connection conn0;
|
||||
--disable_query_log
|
||||
|
||||
--disable_warnings
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t3;
|
||||
--enable_warnings
|
||||
drop database duptable_database;
|
||||
--enable_query_log
|
||||
|
||||
disconnect conn0;
|
||||
disconnect conn1;
|
||||
disconnect obsys;
|
||||
|
||||
@ -0,0 +1,143 @@
|
||||
# owner: weixiaoxian.wxx
|
||||
# owner group: transaction
|
||||
# test_no: 04002
|
||||
# tags: 4.x dup table
|
||||
# description: test 4.x dup table basic lease, test normal and after switch leader, follower can get lease
|
||||
|
||||
## build connect
|
||||
connect (obsys, $OBMYSQL_MS0, root@sys, "", oceanbase, $OBMYSQL_PORT);
|
||||
|
||||
connection obsys;
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
--source mysql_test/include/check_tenant_sync.inc
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
connect (conn0,$OBMYSQL_MS0,root@mysql,,test,$OBMYSQL_PORT);
|
||||
connect (conn1,$OBMYSQL_MS0,root@mysql,,test,$OBMYSQL_PORT);
|
||||
|
||||
connection conn0;
|
||||
## close recyclebin
|
||||
set @@session.recyclebin=off;
|
||||
|
||||
create database duptable_database;
|
||||
use duptable_database;
|
||||
|
||||
--disable_warnings
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--enable_warnings
|
||||
|
||||
## create dup table
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
|
||||
## create table
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t2;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t2;
|
||||
|
||||
connection obsys;
|
||||
let $tenant_id = query_get_value(select tenant_id from __all_tenant where tenant_name = 'mysql', tenant_id, 1);
|
||||
let $database_id = query_get_value(select database_id from __all_virtual_database where database_name = 'duptable_database' and tenant_id = $tenant_id, database_id, 1);
|
||||
|
||||
## check duplicate scope
|
||||
--disable_query_log
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
--enable_query_log
|
||||
|
||||
--echo 准备: 将复制表的leader和普通表的leader分开
|
||||
|
||||
## get table id
|
||||
let $t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
|
||||
## get ls id of dup table
|
||||
let $dup_t1_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t1_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t2_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t2_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
|
||||
## get the ip:port of dup table follower
|
||||
let $dup_t1_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t1_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t2_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
## get the ip:port of dup table leader
|
||||
let $dup_t1_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_IP, 1);
|
||||
let $dup_t1_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_IP, 1);
|
||||
let $dup_t2_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_PORT, 1);
|
||||
|
||||
sleep 20;
|
||||
|
||||
## check dup_t1 lease virtual table
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_virtual_dup_ls_lease_mgr where svr_ip = '$dup_t1_leader_ip' and svr_port = $dup_t1_leader_port and follower_ip = '$dup_t1_follow_ip' and follower_port = $dup_t1_follow_port and tenant_id = $tenant_id;
|
||||
eval select count(*) from oceanbase.__all_virtual_dup_ls_lease_mgr where svr_ip = '$dup_t2_leader_ip' and svr_port = $dup_t2_leader_port and follower_ip = '$dup_t2_follow_ip' and follower_port = $dup_t2_follow_port and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
## switch leader to dup table follower server
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$dup_t1_follow_ip:$dup_t1_follow_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t2_ls_id server='$dup_t2_follow_ip:$dup_t2_follow_port' tenant='mysql';
|
||||
--enable_query_log
|
||||
|
||||
## sleep 20s wait for switch leader
|
||||
sleep 20;
|
||||
|
||||
## check switch leader succ
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$dup_t1_follow_ip' and SVR_PORT = '$dup_t1_follow_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t2_ls_id and SVR_IP = '$dup_t2_follow_ip' and SVR_PORT = '$dup_t2_follow_port' and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
## check follower can get lease after switch leader
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_virtual_dup_ls_lease_mgr where svr_ip = '$dup_t1_follow_ip' and svr_port = $dup_t1_follow_port and follower_ip = '$dup_t1_leader_ip' and follower_port = $dup_t1_leader_port and tenant_id = $tenant_id;
|
||||
eval select count(*) from oceanbase.__all_virtual_dup_ls_lease_mgr where svr_ip = '$dup_t2_follow_ip' and svr_port = $dup_t2_follow_port and follower_ip = '$dup_t2_leader_ip' and follower_port = $dup_t2_leader_port and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
connection conn0;
|
||||
--disable_query_log
|
||||
|
||||
--disable_warnings
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t3;
|
||||
--enable_warnings
|
||||
drop database duptable_database;
|
||||
--enable_query_log
|
||||
|
||||
disconnect conn0;
|
||||
disconnect conn1;
|
||||
disconnect obsys;
|
||||
|
||||
@ -0,0 +1,205 @@
|
||||
# owner: weixiaoxian.wxx
|
||||
# owner group: transaction
|
||||
# test_no: 04003
|
||||
# tags: 4.x dup table
|
||||
# description: test basic add and remove duplicate tablet
|
||||
|
||||
## build connect
|
||||
connect (obsys, $OBMYSQL_MS0, root@sys, "", oceanbase, $OBMYSQL_PORT);
|
||||
|
||||
connection obsys;
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
--source mysql_test/include/check_tenant_sync.inc
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
let $cpu = 1;
|
||||
let $memory = '2G';
|
||||
|
||||
--disable_query_log
|
||||
--disable_warnings
|
||||
drop tenant if exists duptable_tenant1 force;
|
||||
DROP RESOURCE POOL IF EXISTS duptable_pool1;
|
||||
DROP RESOURCE UNIT IF EXISTS duptable_unit1;
|
||||
--enable_warnings
|
||||
|
||||
sleep 5;
|
||||
|
||||
eval CREATE RESOURCE UNIT duptable_unit1 MAX_CPU=$cpu, MEMORY_SIZE=$memory;
|
||||
eval CREATE RESOURCE POOL duptable_pool1 UNIT='duptable_unit1', UNIT_NUM=1, ZONE_LIST=('zone1', 'zone2');
|
||||
CREATE TENANT duptable_tenant1 REPLICA_NUM = 2, RESOURCE_POOL_LIST = ('duptable_pool1') set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql', lower_case_table_names = 0;
|
||||
alter tenant duptable_tenant1 set variables ob_tcp_invited_nodes='%';
|
||||
--enable_query_log
|
||||
|
||||
## set errsim to invoke gc
|
||||
alter system set_tp tp_name = ERRSIM_DUP_TABLE_GC_RIGHT_NOW, error_code = 4016, frequency = 0;
|
||||
sleep 1;
|
||||
|
||||
alter system set_tp tp_name = ERRSIM_DUP_TABLE_GC_RIGHT_NOW, error_code = 4016, frequency = 1;
|
||||
|
||||
|
||||
|
||||
####### begin test dup table
|
||||
connect (conn0,$OBMYSQL_MS0,root@duptable_tenant1,,test,$OBMYSQL_PORT);
|
||||
connect (conn1,$OBMYSQL_MS0,root@duptable_tenant1,,test,$OBMYSQL_PORT);
|
||||
connection conn0;
|
||||
|
||||
## create dup table
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
|
||||
## create partition dup table
|
||||
create table dup_t3 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 5;
|
||||
create table dup_t4 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 30;
|
||||
|
||||
## create table
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
|
||||
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t2;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t2;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t3;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t4;
|
||||
|
||||
sleep 15;
|
||||
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
insert into dup_t3 select * from t1;
|
||||
insert into dup_t4 select * from t2;
|
||||
|
||||
select * from t1;
|
||||
select * from dup_t1;
|
||||
select * from t2;
|
||||
select * from dup_t2;
|
||||
|
||||
select * from dup_t3;
|
||||
select * from dup_t4;
|
||||
|
||||
connection obsys;
|
||||
let $tenant_id = query_get_value(select tenant_id from __all_tenant where tenant_name = 'duptable_tenant1', tenant_id, 1);
|
||||
let $database_id = query_get_value(select database_id from __all_virtual_database where database_name = 'test' and tenant_id = $tenant_id, database_id, 1);
|
||||
|
||||
## check duplicate scope
|
||||
--disable_query_log
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t3' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t4' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
--enable_query_log
|
||||
|
||||
# --echo switch leader
|
||||
|
||||
## get table id
|
||||
#############
|
||||
# /* for debug */ select table_id from oceanbase.__all_virtual_table where table_name = 'dup_t1' or table_name = 'dup_t2' or table_name = 'dup_t3' or table_name = 'dup_t4'and tenant_id = 1004;
|
||||
#############
|
||||
|
||||
let $t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t3_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t3' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t4_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t4' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
|
||||
## get ls id of dup table
|
||||
let $dup_t1_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t1_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t2_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t2_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t3_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t3_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t4_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t4_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
|
||||
## get the ip:port of dup table follower
|
||||
let $dup_t1_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t1_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
## get the ip:port of dup table leader
|
||||
let $dup_t1_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_IP, 1);
|
||||
let $dup_t1_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_PORT, 1);
|
||||
|
||||
connection conn0;
|
||||
## check all_tablet_to_ls;
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t1_ls_id and table_id = $dup_t1_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t2_ls_id and table_id = $dup_t2_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t3_ls_id and table_id = $dup_t3_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t4_ls_id and table_id = $dup_t4_table_id;
|
||||
--enable_query_log
|
||||
|
||||
## check tablet_set hold all dup tablets
|
||||
--disable_query_log
|
||||
# eval select sum(b.count) = count(a.tablet_id) from oceanbase.__all_tablet_to_ls as a, oceanbase.__all_virtual_dup_ls_tablet_set as b where b.ls_state = 'LEADER' and a.table_id = $dup_t1_table_id
|
||||
# or a.table_id = $dup_t2_table_id or a.table_id = $dup_t3_table_id or a.table_id = $dup_t4_table_id;
|
||||
|
||||
## check tabelt_set count follower equal to leader
|
||||
# eval select sum(count) from oceanbase.__all_virtual_dup_ls_tablet_set where attribute = 'READABLE' and ls_state = 'LEADER';
|
||||
# eval select sum(count) from oceanbase.__all_virtual_dup_ls_tablet_set where attribute = 'READABLE' and ls_state = 'FOLLOWER' limit 1;
|
||||
|
||||
## check readable_set, follower uid equal to leader
|
||||
eval select count(*) from (select unique_id not in
|
||||
(select unique_id from oceanbase.__all_virtual_dup_ls_tablet_set
|
||||
where ls_state='LEADER' and attribute ='READABLE') as res
|
||||
from oceanbase.__all_virtual_dup_ls_tablet_set
|
||||
where ls_state='FOLLOWER' and attribute='READABLE' and
|
||||
svr_ip = '$dup_t1_follow_ip' and SVR_PORT = '$dup_t1_follow_port')
|
||||
where res <> FALSE;
|
||||
--enable_query_log
|
||||
|
||||
connection obsys;
|
||||
## switch leader to dup table follower server
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$dup_t1_follow_ip:$dup_t1_follow_port' tenant='duptable_tenant1';
|
||||
--enable_query_log
|
||||
|
||||
## sleep 10s wait for switch
|
||||
sleep 10;
|
||||
|
||||
## check switch leader succ
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$dup_t1_follow_ip' and SVR_PORT = '$dup_t1_follow_port' and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
sleep 10;
|
||||
|
||||
connection conn0;
|
||||
## check all_tablet_to_ls;
|
||||
--disable_query_log
|
||||
## check tabelt_set count follower equal to leader in mysql tenant
|
||||
eval select sum(count) from oceanbase.__all_virtual_dup_ls_tablet_set where attribute = 'READABLE' and ls_state = 'LEADER';
|
||||
eval select sum(count) from oceanbase.__all_virtual_dup_ls_tablet_set where attribute = 'READABLE' and svr_ip = '$dup_t1_leader_ip' and svr_port = '$dup_t1_leader_port';
|
||||
|
||||
## check follower readable_set uid equal to leader
|
||||
eval select count(*) from (select unique_id not in
|
||||
(select unique_id from oceanbase.__all_virtual_dup_ls_tablet_set
|
||||
where ls_state='LEADER' and attribute ='READABLE') as res
|
||||
from oceanbase.__all_virtual_dup_ls_tablet_set
|
||||
where ls_state='FOLLOWER' and attribute='READABLE' and
|
||||
svr_ip = '$dup_t1_leader_ip' and SVR_PORT = '$dup_t1_leader_port')
|
||||
where res <> FALSE;
|
||||
--enable_query_log
|
||||
|
||||
connection obsys;
|
||||
## clean tenant
|
||||
drop tenant duptable_tenant1 force;
|
||||
|
||||
disconnect conn0;
|
||||
disconnect conn1;
|
||||
disconnect obsys;
|
||||
@ -0,0 +1,208 @@
|
||||
# owner: weixiaoxian.wxx
|
||||
# owner group: transaction
|
||||
# test_no: 04003
|
||||
# tags: 4.x dup table
|
||||
# description: test basic add and remove duplicate tablet
|
||||
|
||||
## build connect
|
||||
connect (obsys, $OBMYSQL_MS0, root@sys, "", oceanbase, $OBMYSQL_PORT);
|
||||
|
||||
connection obsys;
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
--source mysql_test/include/check_tenant_sync.inc
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
let $cpu = 1;
|
||||
let $memory = '2G';
|
||||
|
||||
--disable_query_log
|
||||
--disable_warnings
|
||||
drop tenant if exists duptable_tenant1 force;
|
||||
DROP RESOURCE POOL IF EXISTS duptable_pool1;
|
||||
DROP RESOURCE UNIT IF EXISTS duptable_unit1;
|
||||
--enable_warnings
|
||||
|
||||
sleep 5;
|
||||
|
||||
eval CREATE RESOURCE UNIT duptable_unit1 MAX_CPU=$cpu, MEMORY_SIZE=$memory;
|
||||
eval CREATE RESOURCE POOL duptable_pool1 UNIT='duptable_unit1', UNIT_NUM=1, ZONE_LIST=('zone1', 'zone2');
|
||||
CREATE TENANT duptable_tenant1 REPLICA_NUM = 2, RESOURCE_POOL_LIST = ('duptable_pool1') set ob_tcp_invited_nodes='%', ob_compatibility_mode='mysql', lower_case_table_names = 0;
|
||||
alter tenant duptable_tenant1 set variables ob_tcp_invited_nodes='%';
|
||||
--enable_query_log
|
||||
|
||||
|
||||
|
||||
####### begin test dup table
|
||||
connect (conn0,$OBMYSQL_MS0,root@duptable_tenant1,,test,$OBMYSQL_PORT);
|
||||
connect (conn1,$OBMYSQL_MS0,root@duptable_tenant1,,test,$OBMYSQL_PORT);
|
||||
connection conn0;
|
||||
set @@recyclebin=off;
|
||||
--disable_warnings
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t3;
|
||||
--error 0,942
|
||||
drop table if exists dup_t4;
|
||||
--enable_warnings
|
||||
|
||||
## create dup table
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1, c2)) duplicate_scope='cluster';
|
||||
create table dup_t2 (d1 int, d2 int, d3 int, primary key(d1, d2)) duplicate_scope='cluster';
|
||||
|
||||
## create partition dup table
|
||||
create table dup_t3 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 5;
|
||||
create table dup_t4 (d1 int, d2 int, d3 int, primary key(d1)) duplicate_scope='cluster' PARTITION BY HASH(d1) PARTITIONS 30;
|
||||
|
||||
## create table
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1, c2));
|
||||
create table t2 (d1 int, d2 int, d3 int, primary key(d1, d2));
|
||||
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table t2;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t1;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t2;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t3;
|
||||
--source mysql_test/include/show_create_table_old_version_replica2.inc
|
||||
show create table dup_t4;
|
||||
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
insert into dup_t3 select * from t1;
|
||||
insert into dup_t4 select * from t2;
|
||||
|
||||
select * from t1;
|
||||
select * from dup_t1;
|
||||
select * from t2;
|
||||
select * from dup_t2;
|
||||
|
||||
select * from dup_t3;
|
||||
select * from dup_t4;
|
||||
|
||||
sleep 15;
|
||||
|
||||
## check tablets count equal to tablet_to_ls table
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls as ls_tablet, oceanbase.__all_virtual_dup_ls_tablets as ls_dup_tablet
|
||||
where ls_dup_tablet.ls_state = 'LEADER' and ls_tablet.tablet_id = ls_dup_tablet.tablet_id and ls_tablet.ls_id = ls_dup_tablet.ls_id;
|
||||
--enable_query_log
|
||||
|
||||
connection obsys;
|
||||
let $tenant_id = query_get_value(select tenant_id from __all_tenant where tenant_name = 'duptable_tenant1', tenant_id, 1);
|
||||
let $database_id = query_get_value(select database_id from __all_virtual_database where database_name = 'test' and tenant_id = $tenant_id, database_id, 1);
|
||||
|
||||
## check duplicate scope
|
||||
--disable_query_log
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t3' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 'dup_t4' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
eval select duplicate_scope from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id;
|
||||
--enable_query_log
|
||||
|
||||
# --echo 准备: 将复制表的leader和普通表的leader分开
|
||||
|
||||
## get table id
|
||||
let $t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t3_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t3' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t4_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t4' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
|
||||
## get ls id of dup table
|
||||
let $dup_t1_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t1_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t2_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t2_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t3_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t3_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t4_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t4_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
|
||||
## get the ip:port of dup table follower
|
||||
let $dup_t1_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t1_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t2_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
## get the ip:port of dup table leader
|
||||
let $dup_t1_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_IP, 1);
|
||||
let $dup_t1_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_IP, 1);
|
||||
let $dup_t2_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_PORT, 1);
|
||||
|
||||
## get duplicate ls id
|
||||
let $dup_ls_id = query_get_value(select ls_id from oceanbase.__all_virtual_ls where flag like "%DUPLICATE%" and tenant_id = $tenant_id, ls_id, 1);
|
||||
|
||||
|
||||
connection conn0;
|
||||
## check all_tablet_to_ls;
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t1_ls_id and table_id = $dup_t1_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t2_ls_id and table_id = $dup_t2_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t3_ls_id and table_id = $dup_t3_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t4_ls_id and table_id = $dup_t4_table_id;
|
||||
--enable_query_log
|
||||
|
||||
connection obsys;
|
||||
## switch leader to dup table follower server
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$dup_t1_follow_ip:$dup_t1_follow_port' tenant='duptable_tenant1';
|
||||
eval alter system switch replica leader ls=$dup_t2_ls_id server='$dup_t2_follow_ip:$dup_t2_follow_port' tenant='duptable_tenant1';
|
||||
--enable_query_log
|
||||
|
||||
## sleep 20s wait for switch
|
||||
sleep 20;
|
||||
|
||||
## check switch leader succ
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$dup_t1_follow_ip' and SVR_PORT = '$dup_t1_follow_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t2_ls_id and SVR_IP = '$dup_t2_follow_ip' and SVR_PORT = '$dup_t2_follow_port' and tenant_id = $tenant_id;
|
||||
--enable_query_log
|
||||
|
||||
connection conn0;
|
||||
## check all_tablet_to_ls;
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t1_ls_id and table_id = $dup_t1_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t2_ls_id and table_id = $dup_t2_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t3_ls_id and table_id = $dup_t3_table_id;
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls where ls_id= $dup_t4_ls_id and table_id = $dup_t4_table_id;
|
||||
--enable_query_log
|
||||
|
||||
## check tablets count equal to tablet_to_ls table
|
||||
--disable_query_log
|
||||
eval select count(*) from oceanbase.__all_tablet_to_ls as ls_tablet, oceanbase.__all_virtual_dup_ls_tablets as ls_dup_tablet
|
||||
where ls_dup_tablet.ls_state = 'LEADER' and ls_tablet.tablet_id = ls_dup_tablet.tablet_id and ls_tablet.ls_id = ls_dup_tablet.ls_id;
|
||||
|
||||
eval select count(*) from oceanbase.__all_virtual_dup_ls_tablets where ls_id = $dup_ls_id and tenant_id = $tenant_id and ls_state = 'LEADER';
|
||||
--enable_query_log
|
||||
|
||||
### should use errsim test gc handler
|
||||
|
||||
connection obsys;
|
||||
drop tenant duptable_tenant1 force;
|
||||
|
||||
disconnect conn0;
|
||||
disconnect conn1;
|
||||
disconnect obsys;
|
||||
|
||||
@ -0,0 +1,232 @@
|
||||
# owner: weixiaoxian.wxx
|
||||
# owner group: transaction
|
||||
# test_no: 04005
|
||||
# tags: 4.x dup table
|
||||
# description: test duplicate join, insert form select
|
||||
|
||||
## build connect
|
||||
connect (obsys, $OBMYSQL_MS0, root@sys, "", oceanbase, $OBMYSQL_PORT);
|
||||
|
||||
connection obsys;
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
--source mysql_test/include/check_tenant_sync.inc
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
####### begin test dup table
|
||||
connect (conn0,$OBMYSQL_MS0,root@mysql,,test,$OBMYSQL_PORT);
|
||||
connect (conn1,$OBMYSQL_MS0,root@mysql,,test,$OBMYSQL_PORT);
|
||||
|
||||
connection conn0;
|
||||
--disable_warnings
|
||||
drop database if exists duptable_database;
|
||||
create database duptable_database;
|
||||
use duptable_database;
|
||||
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t3;
|
||||
--enable_warnings
|
||||
|
||||
## create table
|
||||
create table t1 (c1 int, c2 int, c3 int, primary key(c1));
|
||||
create table t2 (c1 int, c2 int, c3 int, primary key(c1));
|
||||
|
||||
## create dup table
|
||||
create table dup_t1 (c1 int, c2 int, c3 int, primary key(c1)) duplicate_scope='cluster';
|
||||
create table dup_t2 (c1 int, c2 int, c3 int, primary key(c1)) duplicate_scope='cluster';
|
||||
create table dup_t3 (c1 int, c2 int, c3 int) duplicate_scope='cluster';
|
||||
|
||||
insert into t1 values(1, 1, 1);
|
||||
insert into t1 values(2, 2, 2);
|
||||
insert into t1 values(3, 3, 3);
|
||||
|
||||
insert into t2 values(1, 1, 1);
|
||||
insert into t2 values(2, 2, 2);
|
||||
insert into t2 values(4, 4, 4);
|
||||
|
||||
insert into dup_t1 select * from t1;
|
||||
insert into dup_t2 select * from t2;
|
||||
|
||||
let $test_count = 20;
|
||||
let $v_c1 = 5;
|
||||
|
||||
while ($test_count > 0)
|
||||
{
|
||||
connection conn0;
|
||||
eval insert into t1 values($v_c1, $v_c1, $v_c1);
|
||||
eval insert into t2 values($v_c1, $v_c1, $v_c1);
|
||||
eval insert into dup_t1 values($v_c1, $v_c1, $v_c1);
|
||||
eval insert into dup_t2 values($v_c1, $v_c1, $v_c1);
|
||||
inc $v_c1;
|
||||
dec $test_count;
|
||||
commit;
|
||||
}
|
||||
|
||||
## ensure normal table and dup table in one leader
|
||||
connection obsys;
|
||||
sleep 6;
|
||||
|
||||
let $tenant_id = query_get_value(select tenant_id from __all_tenant where tenant_name = 'mysql', tenant_id, 1);
|
||||
let $database_id = query_get_value(select database_id from __all_virtual_database where database_name = 'duptable_database' and tenant_id = $tenant_id, database_id, 1);
|
||||
|
||||
## get table id
|
||||
let $t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 't2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t1_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t1' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
let $dup_t2_table_id = query_get_value(select table_id from __all_virtual_table where table_name = 'dup_t2' and tenant_id = $tenant_id and database_id = $database_id, table_id, 1);
|
||||
|
||||
## get ls id
|
||||
let $dup_t1_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t1_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $dup_t2_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $dup_t2_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $t1_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $t1_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
let $t2_ls_id = query_get_value(select LS_ID from __all_virtual_tablet_to_ls where table_id = $t2_table_id and tenant_id = $tenant_id, LS_ID, 1);
|
||||
|
||||
##########################################
|
||||
## get the ip:port of dup table follower
|
||||
let $dup_t1_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t1_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $dup_t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $dup_t2_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $dup_t2_ls_id ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
## get the ip:port of dup table leader
|
||||
let $dup_t1_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_IP, 1);
|
||||
let $dup_t1_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t1_ls_id, SVR_PORT, 1);
|
||||
|
||||
let $dup_t2_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_IP, 1);
|
||||
let $dup_t2_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $dup_t2_ls_id, SVR_PORT, 1);
|
||||
|
||||
###########################################
|
||||
## get the ip:port of normal table follower
|
||||
let $t1_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $t1_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_id = $t1_ls_id and ls_state = 'FOLLOWER' ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
let $t2_follow_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $t2_ls_id ORDER BY SVR_PORT, SVR_IP, 1);
|
||||
let $t2_follow_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'FOLLOWER' and ls_id = $t2_ls_id ORDER BY SVR_PORT, SVR_PORT, 1);
|
||||
|
||||
## get the ip:port of normal table leader
|
||||
let $t1_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $t1_ls_id, SVR_IP, 1);
|
||||
let $t1_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $t1_ls_id, SVR_PORT, 1);
|
||||
|
||||
let $t2_leader_ip = query_get_value(select SVR_IP from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $t2_ls_id, SVR_IP, 1);
|
||||
let $t2_leader_port = query_get_value(select SVR_PORT from __all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id = $t2_ls_id, SVR_PORT, 1);
|
||||
|
||||
##### switch all table leader to t1 leader
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$t1_ls_id server='$t1_leader_ip:$t1_leader_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$t2_ls_id server='$t1_leader_ip:$t1_leader_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$t1_leader_ip:$t1_leader_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t2_ls_id server='$t1_leader_ip:$t1_leader_port' tenant='mysql';
|
||||
--enable_query_log
|
||||
|
||||
sleep 20;
|
||||
|
||||
##### check all table leader to t1 leader
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $t1_ls_id and SVR_IP = '$t1_leader_ip' and SVR_PORT = '$t1_leader_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $t2_ls_id and SVR_IP = '$t1_leader_ip' and SVR_PORT = '$t1_leader_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$t1_leader_ip' and SVR_PORT = '$t1_leader_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t2_ls_id and SVR_IP = '$t1_leader_ip' and SVR_PORT = '$t1_leader_port' and tenant_id = $tenant_id;
|
||||
--disable_query_log
|
||||
|
||||
### join test
|
||||
############################ nature join
|
||||
############################ inner join
|
||||
############################ left join
|
||||
############################ right join
|
||||
|
||||
connection conn1;
|
||||
use duptable_database;
|
||||
--disable_query_log
|
||||
select * from t1 join t2 on t1.c1 = t2.c1 where not exists (select * from t1 join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 inner join t2 on t1.c1 = t2.c1 where not exists (select * from t1 inner join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 left join t2 on t1.c1 = t2.c1 where not exists (select * from t1 left join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 right join t2 on t1.c1 = t2.c1 where not exists (select * from t1 right join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
--enable_query_log
|
||||
|
||||
connection obsys;
|
||||
##### switch dup table leader to t1 follower
|
||||
--disable_query_log
|
||||
eval alter system switch replica leader ls=$t1_ls_id server='$t1_leader_ip:$t1_leader_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$t2_ls_id server='$t1_leader_ip:$t1_leader_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t1_ls_id server='$t1_follow_ip:$t1_follow_port' tenant='mysql';
|
||||
eval alter system switch replica leader ls=$dup_t2_ls_id server='$t1_follow_ip:$t1_follow_port' tenant='mysql';
|
||||
--enable_query_log
|
||||
|
||||
sleep 20;
|
||||
|
||||
##### check dup table leader to t1 follower
|
||||
--disable_query_log
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $t1_ls_id and SVR_IP = '$t1_leader_ip' and SVR_PORT = '$t1_leader_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $t2_ls_id and SVR_IP = '$t1_leader_ip' and SVR_PORT = '$t1_leader_port' and tenant_id = $tenant_id;
|
||||
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t1_ls_id and SVR_IP = '$t1_follow_ip' and SVR_PORT = '$t1_follow_port' and tenant_id = $tenant_id;
|
||||
eval select ls_state from __all_virtual_ls_info where ls_id = $dup_t2_ls_id and SVR_IP = '$t1_follow_ip' and SVR_PORT = '$t1_follow_port' and tenant_id = $tenant_id;
|
||||
--disable_query_log
|
||||
|
||||
connection conn1;
|
||||
use duptable_database;
|
||||
insert into dup_t3 select * from dup_t1;
|
||||
select count(*) from dup_t3;
|
||||
--disable_query_log
|
||||
select * from t1 join t2 on t1.c1 = t2.c1 where not exists (select * from t1 join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 inner join t2 on t1.c1 = t2.c1 where not exists (select * from t1 inner join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 left join t2 on t1.c1 = t2.c1 where not exists (select * from t1 left join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 right join t2 on t1.c1 = t2.c1 where not exists (select * from t1 right join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
--enable_query_log
|
||||
|
||||
connection conn0;
|
||||
use duptable_database;
|
||||
insert into dup_t3 select * from dup_t2;
|
||||
select count(*) from dup_t3;
|
||||
--disable_query_log
|
||||
#### normal join dup
|
||||
select * from t1 join t2 on t1.c1 = t2.c1 where not exists (select * from t1 join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 inner join t2 on t1.c1 = t2.c1 where not exists (select * from t1 inner join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 left join t2 on t1.c1 = t2.c1 where not exists (select * from t1 left join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 right join t2 on t1.c1 = t2.c1 where not exists (select * from t1 right join dup_t2 on t1.c1 = dup_t2.c1);
|
||||
--enable_query_log
|
||||
|
||||
--disable_query_log
|
||||
#### dup join normal
|
||||
select * from t1 join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 join t1 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 inner join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 inner join t1 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 left join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 left join t1 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 right join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 right join t1 on t1.c1 = dup_t2.c1);
|
||||
#### dup join dup
|
||||
select * from t1 join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 join dup_t1 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 inner join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 inner join dup_t1 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 left join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 left join dup_t1 on t1.c1 = dup_t2.c1);
|
||||
select * from t1 right join t2 on t1.c1 = t2.c1 where not exists (select * from dup_t2 right join dup_t1 on t1.c1 = dup_t2.c1);
|
||||
--enable_query_log
|
||||
|
||||
connection conn0;
|
||||
--disable_query_log
|
||||
|
||||
--disable_warnings
|
||||
--error 0,942
|
||||
drop table if exists t1;
|
||||
--error 0,942
|
||||
drop table if exists t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t1;
|
||||
--error 0,942
|
||||
drop table if exists dup_t2;
|
||||
--error 0,942
|
||||
drop table if exists dup_t3;
|
||||
--enable_warnings
|
||||
drop database duptable_database;
|
||||
--enable_query_log
|
||||
|
||||
disconnect conn0;
|
||||
disconnect conn1;
|
||||
disconnect obsys;
|
||||
Reference in New Issue
Block a user