Debian Codegraph @

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

raw
1 ################################################################################
2 # Test case to verify that concurrent transactions with intersecting
3 # write set, on table with single primary and multiple unique key.
4 #
5 # Scenario 8.1: on WL#6834 page
6 #
7 # T1: WS={t1.c1=1, t1.(c2,c3)=(2,3)}
8 #
9 # T2: WS={t1.c1=4, t1.(c2,c3)=(2,3)}
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 the members ONLINE. Create a table on M1.
18 # 2. Set a DEBUG sync before broadcast message to group on connection M1.
19 # Commit a transaction that will be block before broadcast.
20 # 3. Wait until connection reaches DEBUG sync point.
21 # 4. Execute a transaction on M2, that will reach first certification,
22 # since M1 is blocked before broadcast.
23 # 5. Signal the waiting thread on M1 to resume.
24 # 6. It will end up in an error stating that it was aborted, since
25 # transactions are conflicting and M2 was ordered first.
26 # 7. Assert that number of certified transactions are the expected one.
27 #
28 # Checking the positive case in which there is no conflict.
29 # 8. Set a DEBUG sync before broadcast message to group on connection M1.
30 # Commit a transaction that will be block before broadcast.
31 # 9. Wait until connection reaches DEBUG sync point.
32 # 10. Execute a transaction on M2, that will reach first certification,
33 # since M1 is blocked before broadcast.
34 # 11. Signal the waiting thread on M1 to resume.
35 # 12. It will execute without error as the conflicting transactions have been
36 # removed.
37 # 13. Assert that number of certified transactions are the expected one.
38 # 14. Clean up.
39 ################################################################################
40
41 --source include/have_debug_sync.inc
42 --source include/have_group_replication_plugin.inc
43 --source include/group_replication.inc
44
45 --echo
46 --echo ############################################################
47 --echo # 1. Create a table on server1.
48 --let $rpl_connection_name= server1
49 --source include/rpl_connection.inc
50 CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT NOT NULL, c3 INT NOT NULL, UNIQUE KEY (c2, c3));
51 --source include/rpl_sync.inc
52
53 --echo
54 --echo ############################################################
55 --echo # 2. Set a debug sync before broadcast message to group on
56 --echo # connection server_1.
57 --echo # Commit a transaction that will be block before broadcast.
58 --let $rpl_connection_name= server_1
59 --source include/rpl_connection.inc
60 SET @debug_save= @@GLOBAL.DEBUG;
61 SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast';
62 BEGIN;
63 INSERT INTO t1 VALUES(1, 2, 3);
64 --send COMMIT
65
66 --echo
67 --echo ############################################################
68 --echo # 3. Wait until server_1 connection reaches the
69 --echo # group_replication_before_message_broadcast debug sync point.
70 --let $rpl_connection_name= server1
71 --source include/rpl_connection.inc
72 --let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now'
73 --source include/wait_condition.inc
74
75 --echo
76 --echo ############################################################
77 --echo # 4. Execute a transaction on server2, that will reach first
78 --echo # certification, since server_1 is blocked before broadcast.
79 --let $rpl_connection_name= server2
80 --source include/rpl_connection.inc
81 INSERT INTO t1 VALUES(4, 2, 3);
82
83 --echo
84 --echo ############################################################
85 --echo # 5. Signal the waiting thread on server_1 to resume.
86 --let $rpl_connection_name= server1
87 --source include/rpl_connection.inc
88 SET DEBUG_SYNC='now SIGNAL waiting';
89 SET @@GLOBAL.DEBUG= @debug_save;
90
91 --echo
92 --echo ############################################################
93 --echo # 6. It will end up in an error stating that it was aborted,
94 --echo # since transactions are conflicting and server2 was
95 --echo # ordered first.
96 --let $rpl_connection_name= server2
97 --source include/rpl_connection.inc
98 --let $sync_slave_connection= server1
99 --source include/sync_slave_sql_with_master.inc
100
101 --let $rpl_connection_name= server_1
102 --source include/rpl_connection.inc
103 --error ER_TRANSACTION_ROLLBACK_DURING_COMMIT
104 --reap
105
106 --echo
107 --echo ############################################################
108 --echo # 7. Assert that number of certified transactions are the
109 --echo # expected ones.
110 --let $rpl_connection_name= server1
111 --source include/rpl_connection.inc
112
113 --let $certified_transactions= query_get_value(SELECT Count_Transactions_Checked from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Transactions_Checked, 1)
114 --let $assert_text= The value of Count_Transactions_Checked should be 3 after starting group replication
115 --let $assert_cond= "$certified_transactions" = 3
116 --source include/assert.inc
117
118 --let $negatively_certified= query_get_value(SELECT Count_Conflicts_Detected from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Conflicts_Detected, 1)
119 --let $assert_text= The value of Count_Conflicts_Detected should be 1 after starting group replication
120 --let $assert_cond= "$negatively_certified" = 1
121 --source include/assert.inc
122
123 --echo
124 --echo ############################################################
125 --echo # Checking the positive case in which there is no conflict.
126 --echo ############################################################
127 --echo
128 --echo ############################################################
129 --echo # 1. Set a debug sync before broadcast message to group on
130 --echo # connection server_1.
131 --echo # Commit a transaction that will be block before broadcast.
132 --let $rpl_connection_name= server_1
133 --source include/rpl_connection.inc
134 SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast';
135 BEGIN;
136 INSERT INTO t1 VALUES(5, 6, 7);
137 --send COMMIT
138
139 --echo
140 --echo ############################################################
141 --echo # 2. Wait until server_1 connection reaches the
142 --echo # group_replication_before_message_broadcast debug sync point.
143 --let $rpl_connection_name= server1
144 --source include/rpl_connection.inc
145 --let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now'
146 --source include/wait_condition.inc
147
148 --echo
149 --echo ############################################################
150 --echo # 3. Execute a transaction on server2, that will reach first
151 --echo # certification, since server_1 is blocked before broadcast.
152 --let $rpl_connection_name= server2
153 --source include/rpl_connection.inc
154 INSERT INTO t1 VALUES(7, 6, 8);
155 --let $sync_slave_connection= server1
156 --source include/sync_slave_sql_with_master.inc
157
158 --echo
159 --echo ############################################################
160 --echo # 4. Signal the waiting thread on server_1 to resume.
161 --let $rpl_connection_name= server1
162 --source include/rpl_connection.inc
163 SET DEBUG_SYNC='now SIGNAL waiting';
164 SET @@GLOBAL.DEBUG= @debug_save;
165
166 --echo
167 --echo ########################################################################
168 --echo # 5. It will execute without error as the conflicting transactions have
169 --echo # been removed.
170 --let $rpl_connection_name= server_1
171 --source include/rpl_connection.inc
172 --reap
173
174 --source include/rpl_sync.inc
175 --echo
176 --echo ############################################################
177 --echo # 6. Assert that number of certified transactions are the
178 --echo # expected ones.
179 --let $rpl_connection_name= server1
180 --source include/rpl_connection.inc
181
182 --let $assert_text= Table t1 will contain row after the above execution
183 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4 AND t1.c2 = 2 AND t1.c3 = 3, count, 1]" = "1"
184 --source include/assert.inc
185
186 --let $assert_text= Table t1 will contain row after the above execution
187 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 5 AND t1.c2 = 6 AND t1.c3 = 7, count, 1]" = "1"
188 --source include/assert.inc
189
190 --let $assert_text= Table t1 will contain row after the above execution
191 --let $assert_cond= "[SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 7 AND t1.c2 = 6 AND t1.c3 = 8, count, 1]" = "1"
192 --source include/assert.inc
193
194 --let $assert_text= Table t1 will contain 3 rows after the above execution
195 --let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "3"
196 --source include/assert.inc
197
198 --let $certified_transactions= query_get_value(SELECT Count_Transactions_Checked from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Transactions_Checked, 1)
199 --let $assert_text= The value of Count_Transactions_Checked should be 5 after starting group replication
200 --let $assert_cond= "$certified_transactions" = 5
201 --source include/assert.inc
202
203 --let $negatively_certified= query_get_value(SELECT Count_Conflicts_Detected from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_Conflicts_Detected, 1)
204 --let $assert_text= The value of Count_Conflicts_Detected should be 1 after starting group replication
205 --let $assert_cond= "$negatively_certified" = 1
206 --source include/assert.inc
207
208 --echo
209 --echo ############################################################
210 --echo # Clean up.
211 DROP TABLE t1;
212
213 --source include/group_replication_end.inc