[scn] fix failure of mittest after refresh feature scn

This commit is contained in:
obdev
2022-11-28 01:46:42 +00:00
committed by ob-robot
parent 49a02f3304
commit 54b64a7263
1898 changed files with 255804 additions and 280809 deletions

View File

@ -0,0 +1,261 @@
SET @@session.transaction_isolation='READ-COMMITTED';
SELECT @@session.transaction_isolation;
@@session.transaction_isolation
READ-COMMITTED
drop table if exists t1;
drop table if exists t2;
create table t1 (c1 int primary key, c2 int);
create table t2 (c1 int primary key, c2 int);
desc t1;
Field Type Null Key Default Extra
c1 int(11) NO PRI NULL
c2 int(11) YES NULL
desc t2;
Field Type Null Key Default Extra
c1 int(11) NO PRI NULL
c2 int(11) YES NULL
insert into t1 values(1,1);
insert into t1 values(2,1);
insert into t2 values(2,1);
select * from t1;
c1 c2
1 1
2 1
select * from t2;
c1 c2
2 1
set autocommit=1;
select /*+read_consistency(weak)+*/ * from t1;
c1 c2
1 1
2 1
select /*+read_consistency(weak)+*/ * from t1 where c1 = 1;
c1 c2
1 1
select /*+read_consistency(weak)+*/ * from t2;
c1 c2
2 1
select /*+read_consistency(weak)+*/ * from t2 where c1 = 2;
c1 c2
2 1
select /*+read_consistency(weak)+*/ * from t1 as l join t1 as r where l.c1 = r.c1;
c1 c2 c1 c2
1 1 1 1
2 1 2 1
select /*+read_consistency(weak)+*/ * from t1 join t2 where t1.c1 = t2.c1;
c1 c2 c1 c2
2 1 2 1
set autocommit=0;
select /*+read_consistency(weak)+*/ * from t1 as l join t1 as r where l.c1 = r.c1;
c1 c2 c1 c2
1 1 1 1
2 1 2 1
select /*+read_consistency(weak)+*/ * from t1 join t2 where t1.c1 = t2.c1;
c1 c2 c1 c2
2 1 2 1
select /*+read_consistency(weak)+*/* from t1;
c1 c2
1 1
2 1
select /*+read_consistency(weak)+*/* from t2;
c1 c2
2 1
commit;
begin;
insert into t1 values(3, 1);
insert into t2 values(3, 1);
select /*+read_consistency(weak)+*/* from t1;
c1 c2
1 1
2 1
3 1
select /*+read_consistency(weak)+*/* from t2;
c1 c2
2 1
3 1
commit;
begin;
select /*+read_consistency(weak)+*/* from t1;
c1 c2
1 1
2 1
3 1
select /*+read_consistency(weak)+*/* from t2;
c1 c2
2 1
3 1
insert into t1 values(4, 1);
ERROR 0A000: different consistency type in one transaction not supported
select * from t1;
c1 c2
1 1
2 1
3 1
insert into t2 values(4, 1);
ERROR 0A000: different consistency type in one transaction not supported
select * from t2;
c1 c2
2 1
3 1
commit;
begin;
select /*+read_consistency(weak)+*/* from t1 for update;
c1 c2
1 1
2 1
3 1
select /*+read_consistency(weak)+*/* from t2;
c1 c2
2 1
3 1
insert into t1 values(5, 1);
select * from t1;
c1 c2
1 1
2 1
3 1
5 1
insert into t2 values(5, 1);
select * from t2;
c1 c2
2 1
3 1
5 1
commit;
begin;
select /*+read_consistency(weak)+*/* from t2;
c1 c2
2 1
3 1
5 1
select /*+read_consistency(weak)+*/* from t1 for update;
ERROR 0A000: different consistency type in one transaction not supported
insert into t1 values(6, 1);
ERROR 0A000: different consistency type in one transaction not supported
select * from t1;
c1 c2
1 1
2 1
3 1
5 1
insert into t2 values(6, 1);
ERROR 0A000: different consistency type in one transaction not supported
select * from t2;
c1 c2
2 1
3 1
5 1
commit;
begin;
select /*+read_consistency(strong)*/* from t1;
c1 c2
1 1
2 1
3 1
5 1
select /*+read_consistency(weak)*/* from t1;
c1 c2
1 1
2 1
3 1
5 1
commit;
begin;
select /*+read_consistency(weak)*/* from t1;
c1 c2
1 1
2 1
3 1
5 1
select * from t1;
c1 c2
1 1
2 1
3 1
5 1
commit;
drop table t1;
set autocommit=1;
create table t1(a int primary key, b int, c int) partition by hash(a) partitions 5;
insert into t1 values(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5);
insert into t1 values(6, 6, 6), (7, 7, 7), (8, 8, 8), (9, 9, 9), (10, 10, 10);
select /*+read_consistency(WEAK)*/ * from t1;
a b c
create index i1 on t1(b) local;
select /*+read_consistency(WEAK), index(t1, i1)*/ a, b from t1;
a b
1 1
10 10
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
select /*+read_consistency(WEAK), index(t1, i1)*/ * from t1;
a b c
1 1 1
10 10 10
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
drop index i1 on t1;
create index i1 on t1(b) global;
select /*+read_consistency(WEAK), index(t1, i1)*/ a, b from t1;
a b
1 1
10 10
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
select /*+read_consistency(WEAK), index(t1, i1)*/ * from t1;
a b c
1 1 1
10 10 10
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
drop index i1 on t1;
create index i1 on t1(b) global partition by hash(b) partitions 2;
select /*+read_consistency(WEAK), index(t1, i1)*/ a, b from t1;
a b
1 1
10 10
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
select /*+read_consistency(WEAK), index(t1, i1)*/ * from t1;
a b c
1 1 1
10 10 10
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
drop table t1;

View File

@ -0,0 +1,163 @@
--disable_query_log
set @@session.explicit_defaults_for_timestamp=off;
--enable_query_log
#owner: shanyan.g
#owner group: transaction
#description: 测试备机读语句的合法性
connect (conn1,$OBMYSQL_MS0,$OBMYSQL_USR,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection conn1;
SET @@session.transaction_isolation='READ-COMMITTED';
SELECT @@session.transaction_isolation;
--disable_warnings
drop table if exists t1;
drop table if exists t2;
--enable_warnings
#建表
create table t1 (c1 int primary key, c2 int);
create table t2 (c1 int primary key, c2 int);
desc t1;
desc t2;
#准备数据
insert into t1 values(1,1);
insert into t1 values(2,1);
insert into t2 values(2,1);
#check数据是否插入成功
select * from t1;
select * from t2;
#保证备机上版本号是更新过的
sleep 4;
# case 1: 单partition备机读操作
set autocommit=1;
select /*+read_consistency(weak)+*/ * from t1;
select /*+read_consistency(weak)+*/ * from t1 where c1 = 1;
select /*+read_consistency(weak)+*/ * from t2;
select /*+read_consistency(weak)+*/ * from t2 where c1 = 2;
# case 2: ac=1的单partition self join事务
select /*+read_consistency(weak)+*/ * from t1 as l join t1 as r where l.c1 = r.c1;
# case 3: ac=1的多partition事务;
select /*+read_consistency(weak)+*/ * from t1 join t2 where t1.c1 = t2.c1;
# case 4: ac = 0的多partition事务
set autocommit=0;
select /*+read_consistency(weak)+*/ * from t1 as l join t1 as r where l.c1 = r.c1;
select /*+read_consistency(weak)+*/ * from t1 join t2 where t1.c1 = t2.c1;
select /*+read_consistency(weak)+*/* from t1;
select /*+read_consistency(weak)+*/* from t2;
commit;
##下面开始测试备机读异常的情况
#case 5: 强一致操作中混入弱一致性查询
begin;
insert into t1 values(3, 1);
insert into t2 values(3, 1);
#下面的这两条语句,正常来讲,应该报错的,但sql根据前两条语句,将其发到了leader上,没有报错
select /*+read_consistency(weak)+*/* from t1;
select /*+read_consistency(weak)+*/* from t2;
commit;
#插入数据成功了,sleep一下,以便weak读的结果一致
sleep 4;
#case 6: 弱一致操作中混入强一致性操作
begin;
select /*+read_consistency(weak)+*/* from t1;
select /*+read_consistency(weak)+*/* from t2;
#下面的这两条语句,必须要报错:not supportted
--error 1235
insert into t1 values(4, 1);
#预期按照弱一致性操作执行
select * from t1;
--error 1235
insert into t2 values(4, 1);
select * from t2;
commit;
#case 7:select for update操作1
begin;
#目前sql是忽略这个hint的,当成强一致性读来操作;
select /*+read_consistency(weak)+*/* from t1 for update;
#既然第一条语句判断事务是强一致性操作的,因此下面的语句发给了leader
select /*+read_consistency(weak)+*/* from t2;
insert into t1 values(5, 1);
select * from t1;
insert into t2 values(5, 1);
select * from t2;
commit;
#插入数据成功了,sleep一下,以便weak读的结果一致
sleep 4;
#case 8:select for update操作2
begin;
#第一条语句是弱一致性查询,该事务就应该是弱一致性的;
select /*+read_consistency(weak)+*/* from t2;
#事务是弱一致性的,下面的语句需要报错
--error 1235
select /*+read_consistency(weak)+*/* from t1 for update;
--error 1235
insert into t1 values(6, 1);
select * from t1;
--error 1235
insert into t2 values(6, 1);
select * from t2;
commit;
#case 9:其他场景
begin;
#事务是强一致性的,下面的语句全部按照强一致性操作
select /*+read_consistency(strong)*/* from t1;
#预期strong读
select /*+read_consistency(weak)*/* from t1;
commit;
begin;
#事务是弱一致性的,下面的语句全部走弱一致性逻辑
select /*+read_consistency(weak)*/* from t1;
select * from t1;
commit;
--disable_query_log
--disable_result_log
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
let $old_primary_zone=query_get_value(select primary_zone from oceanbase.__all_tenant where tenant_name='mysql',primary_zone,1);
alter tenant mysql set primary_zone='RANDOM';
sleep 3;
connection default;
--enable_result_log
--enable_query_log
--enable_sorted_result
drop table t1;
set autocommit=1;
create table t1(a int primary key, b int, c int) partition by hash(a) partitions 5;
insert into t1 values(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5);
insert into t1 values(6, 6, 6), (7, 7, 7), (8, 8, 8), (9, 9, 9), (10, 10, 10);
select /*+read_consistency(WEAK)*/ * from t1;
create index i1 on t1(b) local;
select /*+read_consistency(WEAK), index(t1, i1)*/ a, b from t1;
select /*+read_consistency(WEAK), index(t1, i1)*/ * from t1;
drop index i1 on t1;
create index i1 on t1(b) global;
select /*+read_consistency(WEAK), index(t1, i1)*/ a, b from t1;
select /*+read_consistency(WEAK), index(t1, i1)*/ * from t1;
drop index i1 on t1;
create index i1 on t1(b) global partition by hash(b) partitions 2;
select /*+read_consistency(WEAK), index(t1, i1)*/ a, b from t1;
select /*+read_consistency(WEAK), index(t1, i1)*/ * from t1;
drop table t1;
--disable_query_log
--disable_result_log
connection obsys;
eval alter tenant mysql set primary_zone='$old_primary_zone';
connection default;
--enable_result_log
--enable_query_log