polardbxengine/mysql-test/suite/xengine/t/check_uk_issue19122361.test

216 lines
5.7 KiB
Plaintext

--source include/have_debug_sync.inc
drop table if exists t1;
--connect (conn1, 127.0.0.1, root, , test, $MYPORT_1)
--connect (conn2, 127.0.0.1, root, , test, $MYPORT_1)
# case 1.1
# uk seq validate test, using RC
--connection conn1
set transaction_isolation = 'READ-COMMITTED';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
SET DEBUG_SYNC = "xengine.check_and_lock_sk SIGNAL try_insert WAIT_FOR insert_done";
begin;
send insert into t1 value (1, 2, 3) on duplicate key update sk = 3;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
insert into t1 value (2, 2, 4) on duplicate key update sk = 4;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 1.2
# uk seq validate test, using RR
--connection conn1
set transaction_isolation = 'REPEATABLE-READ';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
SET DEBUG_SYNC = "xengine.check_and_lock_sk SIGNAL try_insert WAIT_FOR insert_done";
begin;
send insert into t1 value (1, 2, 3) on duplicate key update sk = 3;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
insert into t1 value (2, 2, 4) on duplicate key update sk = 4;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
# transaction rollback
--error 1213
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 2.1
# pk seq validate test, using RC
--connection conn1
set transaction_isolation = 'READ-COMMITTED';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
SET DEBUG_SYNC = "xengine.check_and_lock_unique_pk SIGNAL try_insert WAIT_FOR insert_done";
begin;
select * from t1;
send insert into t1 value (1, 2, 3) on duplicate key update sk = 3;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
insert into t1 value (1, 3, 4) on duplicate key update sk = 4;
set global xengine_force_flush_memtable_now=on;
sleep 1;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 2.2
# pk seq validate test, using RR
--connection conn1
set transaction_isolation = 'REPEATABLE-READ';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
SET DEBUG_SYNC = "xengine.check_and_lock_unique_pk SIGNAL try_insert WAIT_FOR insert_done";
begin;
select * from t1;
send insert into t1 value (1, 2, 3) on duplicate key update sk = 3;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
insert into t1 value (1, 3, 4) on duplicate key update sk = 4;
set global xengine_force_flush_memtable_now=on;
sleep 1;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
# transaction rollback
--error 1213
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 3.1
# uk seq and pk seq validate test, using RC
--connection conn1
set transaction_isolation = 'READ-COMMITTED';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
insert into t1 value (1, 2, 3);
SET DEBUG_SYNC = "xengine.check_and_lock_sk SIGNAL try_insert WAIT_FOR insert_done";
begin;
send insert into t1 value (2, 2, 4) on duplicate key update sk = 4;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
insert into t1 value (3, 2, 5) on duplicate key update sk = 5;
set global xengine_force_flush_memtable_now=on;
sleep 1;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 3.2
# uk seq and pk seq validate test, using RR
--connection conn1
set transaction_isolation = 'REPEATABLE-READ';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
insert into t1 value (1, 2, 3);
SET DEBUG_SYNC = "xengine.check_and_lock_sk SIGNAL try_insert WAIT_FOR insert_done";
begin;
send insert into t1 value (2, 2, 4) on duplicate key update sk = 4;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
insert into t1 value (3, 2, 5) on duplicate key update sk = 5;
set global xengine_force_flush_memtable_now=on;
sleep 1;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
# transaction rollback
--error 1213
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 4.1
# uk seq validate test, using RC
--connection conn1
set transaction_isolation = 'READ-COMMITTED';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
insert into t1 value (1, 2, 3);
SET DEBUG_SYNC = "xengine.check_and_lock_sk SIGNAL try_insert WAIT_FOR insert_done";
begin;
send insert into t1 value (2, 2, 4) on duplicate key update sk = 4;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
delete from t1 where pk = 1;
set global xengine_force_flush_memtable_now=on;
sleep 1;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
# case 4.2
# uk seq validate test, using RR
--connection conn1
set transaction_isolation = 'REPEATABLE-READ';
create table t1 (pk int, uk int, sk int, primary key (pk), unique key (uk), key (sk)) engine=xengine;
insert into t1 value (1, 2, 3);
SET DEBUG_SYNC = "xengine.check_and_lock_sk SIGNAL try_insert WAIT_FOR insert_done";
begin;
send insert into t1 value (2, 2, 4) on duplicate key update sk = 4;
--connection conn2
SET DEBUG_SYNC = "now WAIT_FOR try_insert";
delete from t1 where pk = 1;
set global xengine_force_flush_memtable_now=on;
sleep 1;
SET DEBUG_SYNC = "now SIGNAL insert_done";
--connection conn1
--error 1213
reap;
commit;
select sk from t1;
select * from t1;
drop table t1;
--source suite/xengine/include/check_xengine_log_error.inc