Debian Codegraph @

mysql-test/suite/group_replication/r/gr_foreign_key_conflict.result

raw
1 include/group_replication.inc
2 Warnings:
3 Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4 Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
5 [connection server1]
6
7 ############################################################
8 # Create a table on server1.
9 [connection server1]
10 CREATE TABLE t1 (c1 INT PRIMARY KEY);
11 CREATE TABLE t2 (c2 INT PRIMARY KEY, FOREIGN KEY (c2) REFERENCES t1(c1));
12 INSERT INTO t1 VALUES(1);
13 include/rpl_sync.inc
14
15 ############################################################
16 # Checking the negative case in which there is a conflict.
17 ############################################################
18
19
20 ############################################################
21 # 0. Initial setup and checks.
22 [connection server1]
23 SET SESSION sql_log_bin= 0;
24 include/gtid_utils.inc
25 SET SESSION sql_log_bin= 1;
26 include/gtid_step_reset.inc
27
28 ############################################################
29 # 1. Set a debug sync before broadcast message to group on
30 # connection local_server_connection1.
31 [connection server1]
32 SET @debug_save= @@GLOBAL.DEBUG;
33 SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast';
34
35 #####################################################################
36 # 2. Commit local_transaction that will be blocked before broadcast.
37 BEGIN;
38 INSERT INTO t2 VALUES (1);
39 COMMIT;
40
41 ############################################################
42 # 3. Wait until local transaction reaches the
43 # group_replication_before_message_broadcast debug sync point.
44 [connection server_1]
45
46 ############################################################
47 # 4. Execute a transaction on remote server, that will reach first
48 # certification, since transaction on the local server
49 # is blocked before broadcast.
50 [connection server2]
51 BEGIN;
52 UPDATE t1 SET c1=2 WHERE c1=1;
53 COMMIT;
54
55 ############################################################
56 # 5. Signal the waiting thread on local server to resume the
57 # transaction.
58 [connection server_1]
59 SET DEBUG_SYNC='now SIGNAL waiting';
60 SET @@GLOBAL.DEBUG= @debug_save;
61
62 ############################################################
63 # 6. Wait for remote transaction to be executed succesfully
64 on local server.
65 [connection server2]
66 include/sync_slave_sql_with_master.inc
67 ############################################################
68 # 7. If the test case is conflict scenario, local transaction
69 # will end up in an error stating that it was aborted,
70 # since transactions are conflicting and transaction on
71 # remote server was ordered first. If the test case is
72 # is positive scenario, no error will be seen here.
73 [connection server1]
74 ERROR 40000: Plugin instructed the server to rollback the current transaction.
75 [connection server1]
76 SET @@GLOBAL.DEBUG=@debug_save;
77 ############################################################
78 # 8. Sync everything
79 include/rpl_sync.inc
80 ############################################################
81 # 9. Assert that number of certified transactions are the
82 # expected ones.
83 include/assert.inc [The value of Count_Transactions_Checked should be 5 after starting group replication]
84 include/assert.inc [The value of Count_Conflicts_Detected should be 1 after starting group replication]
85 ############################################################
86 # 10. Assert that GTID is increased as expected
87 include/gtid_step_assert.inc [count=1, only_count=1]
88 [connection server1]
89 SET SESSION sql_log_bin= 0;
90 include/gtid_utils_end.inc
91 SET SESSION sql_log_bin= 1;
92 ############################################################
93 # 11. Cleanup (restore the connection back to original)
94 [connection server1]
95
96 ############################################################
97 # Checking the positive case in which there is no conflict.
98 ############################################################
99
100 INSERT INTO t1 VALUES (5);
101
102 ############################################################
103 # 0. Initial setup and checks.
104 [connection server1]
105 SET SESSION sql_log_bin= 0;
106 include/gtid_utils.inc
107 SET SESSION sql_log_bin= 1;
108 include/gtid_step_reset.inc
109
110 ############################################################
111 # 1. Set a debug sync before broadcast message to group on
112 # connection local_server_connection1.
113 [connection server1]
114 SET @debug_save= @@GLOBAL.DEBUG;
115 SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast';
116
117 #####################################################################
118 # 2. Commit local_transaction that will be blocked before broadcast.
119 BEGIN;
120 INSERT INTO t2 VALUES (5);
121 COMMIT;
122
123 ############################################################
124 # 3. Wait until local transaction reaches the
125 # group_replication_before_message_broadcast debug sync point.
126 [connection server_1]
127
128 ############################################################
129 # 4. Execute a transaction on remote server, that will reach first
130 # certification, since transaction on the local server
131 # is blocked before broadcast.
132 [connection server2]
133 BEGIN;
134 UPDATE t1 SET c1=6 WHERE c1=2;
135 COMMIT;
136
137 ############################################################
138 # 5. Signal the waiting thread on local server to resume the
139 # transaction.
140 [connection server_1]
141 SET DEBUG_SYNC='now SIGNAL waiting';
142 SET @@GLOBAL.DEBUG= @debug_save;
143
144 ############################################################
145 # 6. Wait for remote transaction to be executed succesfully
146 on local server.
147 [connection server2]
148 include/sync_slave_sql_with_master.inc
149 ############################################################
150 # 7. If the test case is conflict scenario, local transaction
151 # will end up in an error stating that it was aborted,
152 # since transactions are conflicting and transaction on
153 # remote server was ordered first. If the test case is
154 # is positive scenario, no error will be seen here.
155 [connection server1]
156 [connection server1]
157 SET @@GLOBAL.DEBUG=@debug_save;
158 ############################################################
159 # 8. Sync everything
160 include/rpl_sync.inc
161 ############################################################
162 # 9. Assert that number of certified transactions are the
163 # expected ones.
164 include/assert.inc [The value of Count_Transactions_Checked should be 8 after starting group replication]
165 include/assert.inc [The value of Count_Conflicts_Detected should be 1 after starting group replication]
166 ############################################################
167 # 10. Assert that GTID is increased as expected
168 include/gtid_step_assert.inc [count=2, only_count=1]
169 [connection server1]
170 SET SESSION sql_log_bin= 0;
171 include/gtid_utils_end.inc
172 SET SESSION sql_log_bin= 1;
173 ############################################################
174 # 11. Cleanup (restore the connection back to original)
175 [connection server1]
176
177 ############################################################
178 # Check the data sanity
179 [connection server1]
180 include/assert.inc [Table t2 will contain row after the above execution]
181 include/assert.inc [Table t1 will contain row after the above execution]
182 include/assert.inc [Table t1 will contain row after the above execution]
183 include/assert.inc [Table t2 will contain 1 rows after the above execution]
184 include/assert.inc [Table t1 will contain 2 rows after the above execution]
185
186 ############################################################
187 # Clean up.
188 DROP TABLE t2;
189 DROP TABLE t1;
190 include/group_replication_end.inc