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