Debian Codegraph @

mysql-test/suite/group_replication/t/gr_unique_key_conflict.test

raw
1 ################################################################################
2 # Test case to verify that concurrent transactions with intersecting
3 # write set, the same unique key, do conflict.
4 #
5 # Scenario 8.1: WL#6834
6 #
7 # T1: WS={t1.c1=1,t1.c2=2}
8 #
9 # T2: WS={t1.c1=3,t1.c2=2}
10 #
11 # Outcome: T1 must abort, T2 must commit.
12 #
13 # Full details on WL#6834 QA notes.
14 #
15 # Test:
16 # 0. The test requires two servers: M1 and M2.
17 # 1. With both members ONLINE. Create a table on M1.
18 # 2. Test the following two scenarios by calling
19 # gr_parallel_local_and_remote_transactions.inc.
20 # Scenario 1: UNIQUE NOT NULL KEY, conflicting case (1,2) vs (3, 2).
21 # Scenario 2: UNIQUE NOT NULL KEY, non-conflicting case (5,6) vs (7,8).
22 # 3. Check the data sanity after the above two scenarios are executed.
23 # 4. Clean up.
24 ################################################################################
25
26 --source include/have_debug_sync.inc
27 --source include/have_group_replication_plugin.inc
28 --source include/group_replication.inc
29
30 --echo
31 --echo ############################################################
32 --echo # Create a table on server1.
33 --let $rpl_connection_name= server1
34 --source include/rpl_connection.inc
35 CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT UNIQUE KEY NOT NULL);
36 --source include/rpl_sync.inc
37
38 --echo
39 --echo ###########################################################
40 --echo # Scenario 1: UNIQUE NOT NULL KEY, conflicting case
41 --let $local_server_connection1=server1
42 --let $local_server_connection2=server_1
43 --let $remote_server_connection=server2
44 --let $local_transaction=INSERT INTO t1 VALUES (1, 2)
45 --let $remote_transaction=INSERT INTO t1 VALUES (3, 2)
46 --let $conflict_test=1
47 --source include/gr_parallel_local_and_remote_transactions.inc
48
49 --echo
50 --echo ############################################################
51 --echo # Scenario 2: UNIQUE NOT NULL KEY, non-conflicting case
52 --let $local_server_connection1=server1
53 --let $local_server_connection2=server_1
54 --let $remote_server_connection=server2
55 --let $local_transaction=INSERT INTO t1 VALUES (5, 6)
56 --let $remote_transaction=INSERT INTO t1 VALUES (7, 8)
57 --let $conflict_test=0
58 --source include/gr_parallel_local_and_remote_transactions.inc
59
60 --echo
61 --echo ############################################################
62 --echo # Check the data sanity
63 --let $rpl_connection_name= server1
64 --source include/rpl_connection.inc
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 = 3 AND t1.c2 = 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 = 5 AND t1.c2 = 6, count, 1]" = "1"
71 --source include/assert.inc
72
73 --let $assert_text= Table t1 will contain row after the above execution
74 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 7 AND t1.c2 = 8, count, 1]" = "1"
75 --source include/assert.inc
76
77 --let $assert_text= Table t1 will contain 3 rows after the above execution
78 --let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "3"
79 --source include/assert.inc
80
81 --echo
82 --echo ############################################################
83 --echo # Clean up.
84 DROP TABLE t1;
85
86 --source include/group_replication_end.inc