Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that Group Replication does start correctly multiple times after
3 # the server being cloned.
4 #
5 # Test:
6 # 0. The test requires two servers: M1 and M2.
7 # 1. Install clone plugin on server1.
8 # Bootstrap server1 and add some data.
9 # 2. Restart server2 with a monitoring process (mysqld_safe)
10 # if needed.
11 # Install clone plugin on server2.
12 # 3. Start GR on server2, forcing clone.
13 # 4. Stop GR applier on server2 so that all remote
14 # transactions are only queued on relay log.
15 # Execute some transactions on server1.
16 # 5. Wait until server2 receives and certifies the transaction.
17 # Make both members leave the group.
18 # 6. Start Group Replication only on server2.
19 # Assert that server1 and server2 have the same data.
20 # 7. Clean up.
21 ################################################################################
22 --source include/big_test.inc
23 --source include/have_debug_sync.inc
24 --source include/have_mysqld_monitoring_process.inc
25 --source include/have_clone_plugin.inc
26 --source include/have_group_replication_plugin.inc
27 --let $rpl_skip_group_replication_start= 1
28 --source include/group_replication.inc
29
30 --echo
31 --echo ############################################################
32 --echo # 1. Install clone plugin on server1.
33 --echo # Bootstrap server1 and add some data.
34 --let $rpl_connection_name= server1
35 --source include/rpl_connection.inc
36 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
37 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
38
39 --source include/start_and_bootstrap_group_replication.inc
40
41 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
42 INSERT INTO t1 VALUES (1);
43
44
45 --echo
46 --echo ############################################################
47 --echo # 2. Restart server2 with a monitoring process (mysqld_safe)
48 --echo # if needed.
49 --echo # Install clone plugin on server2.
50 --let $rpl_connection_name= server2
51 --source include/rpl_connection.inc
52 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
53 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
54 --let $_group_replication_start_boot_save= `SELECT @@GLOBAL.group_replication_start_on_boot`
55 --let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack`
56 --let $server2_datadir= `SELECT @@DATADIR`
57
58 --let $plugin_list= $GROUP_REPLICATION
59 --source include/spawn_monitoring_process.inc
60
61 --disable_query_log
62 --eval SET PERSIST group_replication_group_name= "$group_replication_group_name"
63 --eval SET PERSIST group_replication_local_address= "$_group_replication_local_address"
64 --eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds"
65 --eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack"
66 SET PERSIST group_replication_start_on_boot= ON;
67 --enable_query_log
68
69 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
70 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
71
72
73 --echo
74 --echo ############################################################
75 --echo # 3. Start GR on server2, forcing clone.
76 --let $_group_replication_threshold_save= `SELECT @@GLOBAL.group_replication_clone_threshold`
77 SET GLOBAL group_replication_clone_threshold= 1;
78
79 START GROUP_REPLICATION;
80
81 --source include/wait_until_disconnected.inc
82
83 --let $rpl_server_number= 2
84 --source include/rpl_reconnect.inc
85
86 --let $group_replication_member_state=ONLINE
87 --source include/gr_wait_for_member_state.inc
88
89 --let $assert_text= Clone must be completed
90 --let $assert_cond= [SELECT state="Completed" FROM performance_schema.clone_status] = 1;
91 --source include/assert.inc
92
93 --let $diff_tables=server1:t1, server2:t1
94 --source include/diff_tables.inc
95
96 # Assert that group_replication_applier channel relay logs were purged after clone.
97 --echo # group_replication_applier channel relay log files
98 --list_files $server2_datadir server-relay-log-group_replication_applier.*
99
100 --let $rpl_channel_name= 'group_replication_applier'
101 --let $binlog_file= server-relay-log-group_replication_applier.000001
102 --source include/show_relaylog_events.inc
103
104 --let $rpl_channel_name= 'group_replication_applier'
105 --let $binlog_file= server-relay-log-group_replication_applier.000002
106 --source include/show_relaylog_events.inc
107
108
109 --echo ############################################################
110 --echo # 4. Stop GR applier on server2 so that all remote
111 --echo # transactions are only queued on relay log.
112 --echo # Execute some transactions on server1.
113 --let $rpl_connection_name= server2
114 --source include/rpl_connection.inc
115 SET @@GLOBAL.DEBUG='+d,block_applier_updates';
116
117 --let $rpl_connection_name= server1
118 --source include/rpl_connection.inc
119 INSERT INTO t1 VALUES (2);
120
121
122 --echo
123 --echo ################################################################
124 --echo # 5. Wait until server2 receives and certifies the transaction.
125 --echo # Make both members leave the group.
126 --let $rpl_connection_name= server2
127 --source include/rpl_connection.inc
128 SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked";
129 --let $wait_condition= SELECT LAST_QUEUED_TRANSACTION="$group_replication_group_name:6" FROM performance_schema.replication_connection_status WHERE channel_name="group_replication_applier";
130 --source include/wait_condition.inc
131
132 SET @@GLOBAL.DEBUG='-d,block_applier_updates';
133 SET @@GLOBAL.DEBUG='+d,force_sql_thread_error';
134 SET DEBUG_SYNC = "now SIGNAL resume_applier_read";
135 --let $group_replication_member_state= ERROR
136 --source include/gr_wait_for_member_state.inc
137 SET @@GLOBAL.DEBUG='-d,force_sql_thread_error';
138 --source include/stop_group_replication.inc
139 SET DEBUG_SYNC= 'RESET';
140
141 --let $rpl_connection_name= server1
142 --source include/rpl_connection.inc
143 --source include/stop_group_replication.inc
144
145
146 --echo
147 --echo ############################################################
148 --echo # 6. Start Group Replication only on server2.
149 --echo # Assert that server1 and server2 have the same data.
150 --let $rpl_connection_name= server2
151 --source include/rpl_connection.inc
152 --source include/start_and_bootstrap_group_replication.inc
153
154 --let $rpl_connection_name= server1
155 --source include/rpl_connection.inc
156 --let $assert_text= 'There are two rows in table t1 on server1'
157 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2
158 --source include/assert.inc
159
160 --let $rpl_connection_name= server2
161 --source include/rpl_connection.inc
162 --let $assert_text= 'There are two rows in table t1 on server2'
163 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2
164 --source include/assert.inc
165
166 --let $diff_tables=server1:t1, server2:t1
167 --source include/diff_tables.inc
168
169 # Assert that group_replication_applier channel relay logs were not purged after clone.
170 --echo # group_replication_applier channel relay log files
171 --list_files $server2_datadir server-relay-log-group_replication_applier.*
172
173 --let $rpl_channel_name= 'group_replication_applier'
174 --let $binlog_file= server-relay-log-group_replication_applier.000002
175 --source include/show_relaylog_events.inc
176
177 --let $rpl_channel_name= 'group_replication_applier'
178 --let $binlog_file= server-relay-log-group_replication_applier.000003
179 --source include/show_relaylog_events.inc
180
181
182 --echo
183 --echo ############################################################
184 --echo # 7. Clean up.
185 --let $rpl_connection_name= server1
186 --source include/rpl_connection.inc
187 DROP TABLE t1;
188
189 UNINSTALL PLUGIN clone;
190
191 --let $rpl_connection_name= server2
192 --source include/rpl_connection.inc
193 --source include/stop_group_replication.inc
194
195 DROP TABLE t1;
196
197 RESET PERSIST group_replication_group_name;
198 RESET PERSIST group_replication_local_address;
199 RESET PERSIST group_replication_group_seeds;
200 RESET PERSIST group_replication_start_on_boot;
201 RESET PERSIST IF EXISTS group_replication_communication_stack;
202
203 --replace_result $_group_replication_threshold_save GROUP_REPLICATION_CLONE_THRESHOLD
204 --eval SET GLOBAL group_replication_clone_threshold= $_group_replication_threshold_save
205
206 --replace_result $_group_replication_start_boot_save START_ON_BOOT_VALUE
207 --eval SET GLOBAL group_replication_start_on_boot= $_group_replication_start_boot_save
208
209 UNINSTALL PLUGIN clone;
210
211 SET SESSION sql_log_bin= 0;
212 call mtr.add_suppression("Due to the number of missing transactions being higher than the configured threshold of*");
213 call mtr.add_suppression("Clone removing all user data for provisioning: Started");
214 call mtr.add_suppression("Clone removing all user data for provisioning: Finished");
215 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Relay log read failure: Could not parse relay log event entry.*");
216 call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group.");
217 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
218 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
219 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
220 SET SESSION sql_log_bin= 1;
221
222 --source include/clean_monitoring_process.inc
223
224 --source include/group_replication_end.inc