Debian Codegraph @

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

raw
1 ################################################################################
2 # Test that evaluates the safe guards that stop members from joining with
3 # transactions not present in the group.
4 #
5 # Here we test several cases where the joiner is allowed or not in the group
6 # based on its executed transaction set.
7 #
8 # Test guide:
9 # 0. The test requires three servers.
10 # Test case 1: A member that has an unrelated transaction fails to join
11 # 1) There is a group with a member that has some transactions
12 # 2) Insert a transaction on server 2 that acquires a local GTID
13 # 3) Server 2 fails to join because the group doesn't know that GTID
14 #
15 # Test case 2: A member that has more group transactions fails to join
16 # 1) Take server 1 out of the group.
17 # 2) Clean server 2 and boot the group again with it
18 # 3) Try to add server 1 to the group. It fails because server 1 has 5
19 # transaction and server 2 only has 1
20 #
21 # 3. Verify all is fine.
22 #
23 # 4. Clean up.
24 ################################################################################
25
26 --source include/big_test.inc
27 --let $group_replication_group_name= b2b6cdc0-eb94-11e5-a837-0800200c9a66
28 --source include/have_group_replication_plugin.inc
29 --let $rpl_gtid_utils= 1
30 --let $rpl_skip_group_replication_start= 1
31 --source include/group_replication.inc
32 --let $errand_transaction_uuid= aaaaaaaa-bbbb-aaaa-bbbb-aaaaaaaaaaaa
33
34 # Suppress errors
35
36 --let $rpl_connection_name= server1
37 --source include/rpl_connection.inc
38
39 SET SESSION sql_log_bin= 0;
40 call mtr.add_suppression(".*This member has more executed transactions *.*");
41 call mtr.add_suppression(".*The member contains transactions not present *.*");
42 SET SESSION sql_log_bin= 1;
43
44 --let $rpl_connection_name= server2
45 --source include/rpl_connection.inc
46
47 SET SESSION sql_log_bin= 0;
48 call mtr.add_suppression(".*This member has more executed transactions *.*");
49 call mtr.add_suppression(".*The member contains transactions not present *.*");
50 SET SESSION sql_log_bin= 1;
51
52 --echo #
53 --echo # Setup the first member
54 --echo #
55
56 --let $rpl_connection_name= server1
57 --source include/rpl_connection.inc
58 --source include/start_and_bootstrap_group_replication.inc
59
60 # Add some data for recovery
61
62 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
63 INSERT INTO t1 VALUES (1);
64
65 --let $assert_text= The first member has 3 transaction belonging to the group
66 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-3";
67 --source include/assert.inc
68
69 --echo #
70 --echo # Test case 1: Try to add a member with local data on it.
71 --echo # The start group replication command shall fail
72 --echo #
73
74 --let $rpl_connection_name= server2
75 --source include/rpl_connection.inc
76
77 --eval SET GTID_NEXT= "$errand_transaction_uuid:1"
78 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
79 SET GTID_NEXT= "AUTOMATIC";
80
81 --let $assert_text= The member shall contain a local transaction
82 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$errand_transaction_uuid:1";
83 --source include/assert.inc
84
85 --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"
86 --error ER_GROUP_REPLICATION_CONFIGURATION
87 START GROUP_REPLICATION;
88
89 --echo # Test case 1 cleanup
90 --echo # Remove data on server 2
91
92 DROP TABLE t2;
93 RESET MASTER;
94
95 #For precaution, wait for server 2 to leave
96 --let $rpl_connection_name= server1
97 --source include/rpl_connection.inc
98
99 --let $group_replication_number_of_members= 1
100 --source include/gr_wait_for_number_of_members.inc
101
102 # Wait until View_change_log_event from server 2 join is logged on binary log
103 --let $wait_condition= SELECT @@GLOBAL.GTID_EXECUTED = "$group_replication_group_name:1-4"
104 --source include/wait_condition.inc
105
106 --echo #
107 --echo # Test case 2: Try to add a member with more group transactions
108 --echo # The start group replication command shall fail
109 --echo #
110
111 --let $rpl_connection_name= server1
112 --source include/rpl_connection.inc
113
114 --source include/stop_group_replication.inc
115
116 --let $rpl_connection_name= server2
117 --source include/rpl_connection.inc
118
119 --source include/start_and_bootstrap_group_replication.inc
120
121 --let $assert_text= The first member to join has only one transaction
122 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1";
123 --source include/assert.inc
124
125 --let $rpl_connection_name= server1
126 --source include/rpl_connection.inc
127
128 --let $assert_text= The second member to join has 4 transactions
129 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4";
130 --source include/assert.inc
131
132 --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"
133 --error ER_GROUP_REPLICATION_CONFIGURATION
134 START GROUP_REPLICATION;
135
136 --echo # Test case 2 cleanup
137 --echo # Put server 1 back in the group
138
139 --let $rpl_connection_name= server2
140 --source include/rpl_connection.inc
141
142 #For precaution, wait for server 1 to leave
143 --let $group_replication_number_of_members= 1
144 --source include/gr_wait_for_number_of_members.inc
145
146 --source include/stop_group_replication.inc
147
148 RESET MASTER;
149
150 --let $rpl_connection_name= server1
151 --source include/rpl_connection.inc
152
153 --source include/start_and_bootstrap_group_replication.inc
154
155 --let $rpl_connection_name= server2
156 --source include/rpl_connection.inc
157
158 --source include/start_group_replication.inc
159
160 --echo #
161 --echo # Verify all is fine
162 --echo #
163
164 --let $rpl_connection_name= server1
165 --source include/rpl_connection.inc
166
167 INSERT INTO t1 VALUES (2);
168
169 --source include/rpl_sync.inc
170
171 --let $assert_text= 'There are two values in table t1'
172 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2
173 --source include/assert.inc
174
175 --let $rpl_connection_name= server2
176 --source include/rpl_connection.inc
177
178 --let $assert_text= 'There are two values in table t1'
179 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2
180 --source include/assert.inc
181
182 --echo #
183 --echo # Cleaning up
184 --echo #
185
186 DROP TABLE t1;
187
188 --source include/group_replication_end.inc