Debian Codegraph @

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

raw
1 ###############################################################################
2 # This test verifies that when the primary leaves the group while a member is
3 # cloning nothing will happen.
4 #
5 # 0. The test requires three servers: M1, M2 and M3 in single primary mode.
6 # 1. Install the clone plugin on server 1
7 # 2. Bootstrap server1 and add some data
8 # 3. Install the clone plugin and start GR on server3
9 # 4. Restart server 2 with a monitoring process (mysqld_safe) if needed
10 # 5. Install the clone plugin on server 2
11 # Setup the server so group replication starts on boot
12 # 6. Start group replication on server 2
13 # Set a debug point so it blocks before clone.
14 # 7. Stop the current primary member forcing an election
15 # Check all states are correct
16 # 8. Unblock clone.
17 # Check everything is fine after restart
18 # 9. Start the stopped server
19 # Check data consistency
20 # 10. Cleanup
21 #
22
23 --source include/big_test.inc
24 --source include/have_debug_sync.inc
25 --source include/have_mysqld_monitoring_process.inc
26 --source include/have_clone_plugin.inc
27 --source include/force_restart.inc
28 --source include/have_group_replication_plugin.inc
29 --let $rpl_server_count= 3
30 --let $rpl_skip_group_replication_start= 1
31 --let $rpl_group_replication_single_primary_mode=1
32 --source include/group_replication.inc
33
34 # Validate plugins
35 --let plugins = CLONE_PLUGIN,GROUP_REPLICATION
36 --source include/check_plugin_dir.inc
37
38 --echo
39 --echo ############################################################
40 --echo # 1. Install clone plugin on server1.
41
42 --let $rpl_connection_name= server1
43 --source include/rpl_connection.inc
44
45 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
46 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
47
48 --echo
49 --echo ############################################################
50 --echo # 2. Bootstrap server1 and add some data
51
52 --source include/start_and_bootstrap_group_replication.inc
53
54 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
55 INSERT INTO t1 VALUES (1);
56 INSERT INTO t1 VALUES (2);
57
58 --echo
59 --echo #################################################################
60 --echo # 3. Install the clone plugin and start GR on server3
61 --let $rpl_connection_name= server3
62 --source include/rpl_connection.inc
63 --let $server3_port = `SELECT @@port`
64 --let $server3_ip_port= 127.0.0.1:$server3_port
65
66 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
67 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
68
69 --source include/start_group_replication.inc
70
71 --echo
72 --echo #######################################################################
73 --echo # 4. Restart server 2 with a monitoring process (mysqld_safe) if needed
74
75 --let $rpl_connection_name= server2
76 --source include/rpl_connection.inc
77
78 --let $_group_replication_local_address2= `SELECT @@GLOBAL.group_replication_local_address`
79 --let $_group_replication_group_seeds2= `SELECT @@GLOBAL.group_replication_group_seeds`
80 --let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack`
81
82 # Persist the primary mode settings so mysqld_safe starts with them
83 SET PERSIST group_replication_enforce_update_everywhere_checks= OFF;
84 SET PERSIST group_replication_single_primary_mode= ON;
85
86 --let $plugin_list= $GROUP_REPLICATION
87 --source include/spawn_monitoring_process.inc
88
89 --echo ############################################################
90 --echo # 5. Install the clone plugin on server 2
91 --echo # Setup the server so group replication starts on boot
92
93 --disable_query_log
94 --eval SET PERSIST group_replication_group_name= "$group_replication_group_name"
95 --eval SET PERSIST group_replication_local_address= "$_group_replication_local_address2"
96 --eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds2"
97 --eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack"
98
99 SET PERSIST group_replication_start_on_boot= ON;
100 --enable_query_log
101
102 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
103 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
104
105 --echo
106 --echo ############################################################
107 --echo # 6. Start group replication on server 2
108 --echo # Set a debug point so it blocks before clone.
109
110 --let $_group_replication_threshold_save= `SELECT @@GLOBAL.group_replication_clone_threshold`
111 SET GLOBAL group_replication_clone_threshold= 1;
112
113 SET @@GLOBAL.DEBUG='+d,gr_clone_process_before_execution';
114
115 START GROUP_REPLICATION;
116
117 SET DEBUG_SYNC = 'now WAIT_FOR signal.gr_clone_thd_paused';
118
119 --echo
120 --echo ############################################################
121 --echo # 7. Stop the current primary member forcing an election
122 --echo # Check all states are correct
123
124 --let $rpl_connection_name= server1
125 --source include/rpl_connection.inc
126
127 --source include/stop_group_replication.inc
128
129 --let $rpl_connection_name= server2
130 --source include/rpl_connection.inc
131
132 --let $group_replication_number_of_members= 2
133 --source include/gr_wait_for_number_of_members.inc
134
135 --let $server_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
136
137 let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_group_members
138 WHERE member_role="SECONDARY" AND member_id="$server_uuid";
139 --source include/wait_condition.inc
140
141 --let $rpl_connection_name= server3
142 --source include/rpl_connection.inc
143
144 --let $group_replication_number_of_members= 2
145 --source include/gr_wait_for_number_of_members.inc
146
147 # Wait for server 3 to disable read mode on the election process
148 --let $wait_condition= SELECT @@GLOBAL.super_read_only = '0'
149 --source include/wait_condition.inc
150
151 --source include/gr_assert_primary_member.inc
152
153 --echo
154 --echo ############################################################
155 --echo # 8. Unblock clone.
156 --echo # Check everything is fine after restart
157
158 --let $rpl_connection_name= server2
159 --source include/rpl_connection.inc
160
161 SET DEBUG_SYNC = 'now SIGNAL signal.gr_clone_thd_continue';
162 SET @@GLOBAL.DEBUG = '-d,gr_clone_process_before_execution';
163
164 --source include/wait_until_disconnected.inc
165
166 --let $rpl_server_number= 2
167 --source include/rpl_reconnect.inc
168
169 --let $group_replication_member_state=ONLINE
170 --source include/gr_wait_for_member_state.inc
171
172 --let $assert_text= Clone must be completed
173 --let $assert_cond= [SELECT state="Completed" FROM performance_schema.clone_status] = 1;
174 --source include/assert.inc
175
176 --echo
177 --echo ############################################################
178 --echo # 9. Start the stopped server
179 --echo # Check data consistency
180
181 --let $rpl_connection_name= server1
182 --source include/rpl_connection.inc
183
184 --source include/start_group_replication.inc
185
186 # See if the data has been properly cloned in server2
187 --let $diff_tables=server1:test.t1, server2:test.t1, server3:test.t1
188 --source include/diff_tables.inc
189
190 --echo
191 --echo ############################################################
192 --echo # 10. Cleanup
193 --let $rpl_connection_name= server2
194 --source include/rpl_connection.inc
195
196 SET DEBUG_SYNC = 'RESET';
197
198 --eval SET GLOBAL group_replication_clone_threshold= $_group_replication_threshold_save
199
200 RESET PERSIST IF EXISTS group_replication_enforce_update_everywhere_checks;
201 RESET PERSIST IF EXISTS group_replication_single_primary_mode;
202 RESET PERSIST IF EXISTS group_replication_group_name;
203 RESET PERSIST IF EXISTS group_replication_local_address;
204 RESET PERSIST IF EXISTS group_replication_group_seeds;
205 RESET PERSIST IF EXISTS group_replication_start_on_boot;
206 RESET PERSIST IF EXISTS group_replication_communication_stack;
207
208 SET GLOBAL read_only= FALSE;
209
210 set session sql_log_bin=0;
211 call mtr.add_suppression("This member will start distributed recovery using clone. It is due to the number of missing transactions being higher than the configured threshold of 1.");
212 call mtr.add_suppression("Plugin group_replication reported: 'Internal query: CLONE INSTANCE FROM \"root\"@127.0.0.1:[0-9]+ IDENTIFIED BY \"\\*\\*\\*\\*\\*\" REQUIRE NO SSL; result in error. Error number: 1317'");
213 call mtr.add_suppression("There was an issue when cloning from another server: Error number: 1317 Error message: Query execution was interrupted'");
214 call mtr.add_suppression("Clone removing all user data for provisioning: Started");
215 call mtr.add_suppression("Clone removing all user data for provisioning: Finished");
216 set session sql_log_bin=1;
217
218 --source include/clean_monitoring_process.inc
219
220 --source include/group_replication_end.inc