Debian Codegraph @

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