Debian Codegraph @

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

raw
1 ################################################################################
2 # Test case to verify that concurrent transactions with intersecting
3 # write set, on foreign key, do conflict.
4 #
5 # Scenario 8.3: on WL#6834 page
6 #
7 # T1: WS={t1.c1=1, t2.c1=1}
8 #
9 # T2: WS={t1.c1=1}
10 # {t1.c1=2}
11 #
12 # Outcome: T1 must abort, T2 must commit.
13 #
14 # Full details on WL#6834 QA notes.
15 #
16 # Test:
17 # 0. The test requires two servers: M1 and M2.
18 # 1. Create a table on server1.
19 # 2. Checking the negative case in which there is a conflict.
20 # 3. Checking the positive case in which there is no conflict.
21 # 4. Check the data sanity
22 # 5. Clean up.
23 ################################################################################
24
25 --source include/have_debug_sync.inc
26 --source include/have_group_replication_plugin.inc
27 --source include/group_replication.inc
28
29 --echo
30 --echo ############################################################
31 --echo # Create a table on server1.
32 --let $rpl_connection_name= server1
33 --source include/rpl_connection.inc
34 CREATE TABLE t1 (c1 INT PRIMARY KEY);
35 CREATE TABLE t2 (c2 INT PRIMARY KEY, FOREIGN KEY (c2) REFERENCES t1(c1));
36 INSERT INTO t1 VALUES(1);
37 --source include/rpl_sync.inc
38
39 --echo
40 --echo ############################################################
41 --echo # Checking the negative case in which there is a conflict.
42 --echo ############################################################
43 --echo
44 --let $local_server_connection1=server1
45 --let $local_server_connection2=server_1
46 --let $remote_server_connection=server2
47 --let $local_transaction= INSERT INTO t2 VALUES (1)
48 --let $remote_transaction=UPDATE t1 SET c1=2 WHERE c1=1
49 --let $conflict_test=1
50 --source include/gr_parallel_local_and_remote_transactions.inc
51
52 --echo
53 --echo ############################################################
54 --echo # Checking the positive case in which there is no conflict.
55 --echo ############################################################
56 --echo
57 INSERT INTO t1 VALUES (5);
58
59 --let $local_server_connection1=server1
60 --let $local_server_connection2=server_1
61 --let $remote_server_connection=server2
62 --let $local_transaction= INSERT INTO t2 VALUES (5)
63 --let $remote_transaction=UPDATE t1 SET c1=6 WHERE c1=2
64 --let $conflict_test=0
65 --source include/gr_parallel_local_and_remote_transactions.inc
66
67 --echo
68 --echo ############################################################
69 --echo # Check the data sanity
70 --let $rpl_connection_name= server1
71 --source include/rpl_connection.inc
72
73 --let $assert_text= Table t2 will contain row after the above execution
74 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t2 WHERE t2.c2 = 5, count, 1]" = "1"
75 --source include/assert.inc
76
77 --let $assert_text= Table t1 will contain row after the above execution
78 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 5, count, 1]" = "1"
79 --source include/assert.inc
80
81 --let $assert_text= Table t1 will contain row after the above execution
82 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 6, count, 1]" = "1"
83 --source include/assert.inc
84
85 --let $assert_text= Table t2 will contain 1 rows after the above execution
86 --let $assert_cond= "[SELECT COUNT(*) FROM t2]" = "1"
87 --source include/assert.inc
88
89 --let $assert_text= Table t1 will contain 2 rows after the above execution
90 --let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "2"
91 --source include/assert.inc
92
93 --echo
94 --echo ############################################################
95 --echo # Clean up.
96 DROP TABLE t2;
97 DROP TABLE t1;
98
99 --source include/group_replication_end.inc