1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
################################################################################
# Test case to verify that concurrent transactions with intersecting
# write set, the same not null unique key, do conflict.
#
# T1: WS={t1.a= 1}
#
# T2: WS={t1.a= 1}
#
# Outcome: T1 must abort, T2 must commit.
#
# Test:
# 0. The test requires two servers: M1 and M2.
# 1. With both members ONLINE. Create a table on M1.
# 2. Checking the negative case in which there is a conflict.
# 3. Checking the positive case in which there is no conflict:
# 4. Assert table consistency.
# 5. Primary key equivalent i.e. Unique key must be NOT NULL
# 6. Clean up.
################################################################################
--source include/have_debug_sync.inc
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
--echo
--echo # 1. With both members ONLINE. Create a table on M1.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
CREATE TABLE t1 (c1 INT UNIQUE KEY NOT NULL);
--source include/rpl_sync.inc
--echo
--echo # 2. Checking the negative case in which there is a conflict.
--echo
--let $local_server_connection1=server1
--let $local_server_connection2=server_1
--let $remote_server_connection=server2
--let $local_transaction= INSERT INTO t1 VALUES (1);
--let $remote_transaction= INSERT INTO t1 VALUES (1);
--let $conflict_test=1
--source include/gr_parallel_local_and_remote_transactions.inc
--echo
--echo # 3. Checking the positive case in which there is no conflict.
--echo
--let $local_server_connection1=server1
--let $local_server_connection2=server_1
--let $remote_server_connection=server2
--let $local_transaction= INSERT INTO t1 VALUES (2);
--let $remote_transaction= INSERT INTO t1 VALUES (3);
--let $conflict_test=0
--source include/gr_parallel_local_and_remote_transactions.inc
--echo
--echo # 4. Assert table consistency.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain row after the above execution
--let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1]" = "1"
--source include/assert.inc
--let $assert_text= Table t1 will contain 3 rows after the above execution
--let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "3"
--source include/assert.inc
--echo
--echo # 5. Primary key equivalent i.e. Unique key must be NOT NULL
--echo
set session sql_log_bin=0;
call mtr.add_suppression("Table t1_null does not have any PRIMARY KEY. This is not compatible with Group Replication.");
set session sql_log_bin=1;
CREATE TABLE t1_null (c1 INT UNIQUE KEY);
--error ER_BEFORE_DML_VALIDATION_ERROR
INSERT INTO t1_null values (5);
--echo
--echo # 6. Clean up.
--echo
DROP TABLE t1;
DROP TABLE t1_null;
--source include/group_replication_end.inc
|