| 1 |
############################################################################### |
| 2 |
# This test verifies that cloning on server start works. |
| 3 |
# It also verifies that any present async channels will error out if clone |
| 4 |
# is executed. |
| 5 |
# |
| 6 |
# 0. This test needs a group with M1, M2 and M3 for a async connection |
| 7 |
# 1. Install clone plugin on server1. |
| 8 |
# 2. Bootstrap server1 and add some data |
| 9 |
# 3. Restart server 2 with a monitoring process (mysqld_safe) if needed |
| 10 |
# Remove the default channel from server1 to server2 |
| 11 |
# 4. Setup the server so group replication starts on boot |
| 12 |
# Install the Clone plugin |
| 13 |
# 5. Create a new channel from server 3 into server 2 |
| 14 |
# 6. Restart the server making it use clone on start |
| 15 |
# Check that clone goes ok |
| 16 |
# 7. Check the channel threads failed to start due to clone |
| 17 |
# 8. Cleanup |
| 18 |
# |
| 19 |
|
| 20 |
--source include/have_mysqld_monitoring_process.inc |
| 21 |
--source include/have_clone_plugin.inc |
| 22 |
--source include/have_group_replication_plugin.inc |
| 23 |
--let $rpl_server_count= 3 |
| 24 |
--let $rpl_skip_group_replication_start= 1 |
| 25 |
--source include/group_replication.inc |
| 26 |
|
| 27 |
# Validate plugins |
| 28 |
--let plugins = CLONE_PLUGIN,GROUP_REPLICATION |
| 29 |
--source include/check_plugin_dir.inc |
| 30 |
|
| 31 |
--echo |
| 32 |
--echo ############################################################ |
| 33 |
--echo # 1. Install clone plugin on server1. |
| 34 |
|
| 35 |
--let $rpl_connection_name= server1 |
| 36 |
--source include/rpl_connection.inc |
| 37 |
--let $server1_port= `SELECT @@GLOBAL.PORT` |
| 38 |
|
| 39 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 40 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 41 |
|
| 42 |
--echo |
| 43 |
--echo ############################################################ |
| 44 |
--echo # 2. Bootstrap server1 and add some data |
| 45 |
|
| 46 |
--source include/start_and_bootstrap_group_replication.inc |
| 47 |
|
| 48 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 49 |
INSERT INTO t1 VALUES (1); |
| 50 |
INSERT INTO t1 VALUES (2); |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo ####################################################################### |
| 54 |
--echo # 3. Restart server 2 with a monitoring process (mysqld_safe) if needed |
| 55 |
--echo # Remove the default channel from server1 to server2 |
| 56 |
|
| 57 |
--let $rpl_connection_name= server2 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
|
| 60 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 61 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 62 |
--let $_group_replication_start_boot_save= `SELECT @@GLOBAL.group_replication_start_on_boot` |
| 63 |
--let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack` |
| 64 |
|
| 65 |
RESET SLAVE ALL; |
| 66 |
|
| 67 |
--let $plugin_list= $GROUP_REPLICATION |
| 68 |
--let $mysqld_extra_settings= "--skip-replica-start=0" |
| 69 |
--source include/spawn_monitoring_process.inc |
| 70 |
|
| 71 |
--echo |
| 72 |
--echo ############################################################ |
| 73 |
--echo # 4. Setup the server so group replication starts on boot |
| 74 |
--echo # Install the Clone plugin |
| 75 |
|
| 76 |
--disable_query_log |
| 77 |
--eval SET PERSIST group_replication_group_name= "$group_replication_group_name" |
| 78 |
--eval SET PERSIST group_replication_local_address= "$_group_replication_local_address" |
| 79 |
--eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds" |
| 80 |
--eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack" |
| 81 |
|
| 82 |
SET PERSIST group_replication_start_on_boot= ON; |
| 83 |
--enable_query_log |
| 84 |
|
| 85 |
# Re configure the recovery channel due to the above RESET SLAVE command. |
| 86 |
CHANGE REPLICATION SOURCE TO SOURCE_USER="root" FOR CHANNEL "group_replication_recovery"; |
| 87 |
|
| 88 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 89 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 90 |
|
| 91 |
--echo |
| 92 |
--echo ############################################################ |
| 93 |
--echo # 5. Create a new channel from server 3 into server 2 |
| 94 |
|
| 95 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 96 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_3 for channel 'ch3_2' |
| 97 |
|
| 98 |
--echo |
| 99 |
--echo ############################################################ |
| 100 |
--echo # 6. Restart the server making it use clone on start |
| 101 |
--echo # Check that clone goes ok |
| 102 |
|
| 103 |
# Ensure the clone is used on restart |
| 104 |
--let $_group_replication_threshold_save= `SELECT @@GLOBAL.group_replication_clone_threshold` |
| 105 |
SET PERSIST group_replication_clone_threshold= 1; |
| 106 |
|
| 107 |
RESTART; |
| 108 |
|
| 109 |
# Wait for it to restart after the command |
| 110 |
--source include/wait_until_disconnected.inc |
| 111 |
--enable_reconnect |
| 112 |
--source include/wait_until_connected_again.inc |
| 113 |
|
| 114 |
# Wait for it to restart after cloning |
| 115 |
--source include/wait_until_disconnected.inc |
| 116 |
|
| 117 |
--let $rpl_server_number= 2 |
| 118 |
--source include/rpl_reconnect.inc |
| 119 |
|
| 120 |
--let $rpl_connection_name= server2 |
| 121 |
--source include/rpl_connection.inc |
| 122 |
|
| 123 |
--let $group_replication_member_state=ONLINE |
| 124 |
--source include/gr_wait_for_member_state.inc |
| 125 |
|
| 126 |
--let $assert_text= Clone must be completed |
| 127 |
--let $assert_cond= [SELECT state="Completed" FROM performance_schema.clone_status] = 1; |
| 128 |
--source include/assert.inc |
| 129 |
|
| 130 |
# See if the data has been properly cloned in server2 |
| 131 |
--let $diff_tables=server1:test.t1 ,server2:test.t1 |
| 132 |
--source include/diff_tables.inc |
| 133 |
|
| 134 |
--echo |
| 135 |
--echo ############################################################ |
| 136 |
--echo # 7. Check the channel threads failed to start due to clone |
| 137 |
|
| 138 |
# Verify in the log file that the applier thread failed |
| 139 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 140 |
--let $assert_text = The applier thread for channel ch3_2 failed to start |
| 141 |
--let $assert_select = The 'replica applier' thread of channel 'ch3_2' will error out as the server will attempt to clone another server |
| 142 |
--let $assert_count = 1 |
| 143 |
--source include/assert_grep.inc |
| 144 |
|
| 145 |
# Verify in the log file that the IO thread failed |
| 146 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 147 |
--let $assert_text = The IO thread for channel ch3_2 failed to start |
| 148 |
--let $assert_select = The 'replica IO' thread of channel 'ch3_2' will error out as the server will attempt to clone another server |
| 149 |
--let $assert_count = 1 |
| 150 |
--source include/assert_grep.inc |
| 151 |
|
| 152 |
--echo |
| 153 |
--echo ############################################################ |
| 154 |
--echo # 8. Cleanup |
| 155 |
|
| 156 |
|
| 157 |
RESET PERSIST IF EXISTS group_replication_group_name; |
| 158 |
RESET PERSIST IF EXISTS group_replication_local_address; |
| 159 |
RESET PERSIST IF EXISTS group_replication_group_seeds; |
| 160 |
RESET PERSIST IF EXISTS group_replication_start_on_boot; |
| 161 |
RESET PERSIST IF EXISTS group_replication_clone_threshold; |
| 162 |
RESET PERSIST IF EXISTS group_replication_communication_stack; |
| 163 |
|
| 164 |
--eval SET GLOBAL group_replication_clone_threshold= $_group_replication_threshold_save |
| 165 |
|
| 166 |
DROP TABLE t1; |
| 167 |
|
| 168 |
--source include/rpl_sync.inc |
| 169 |
|
| 170 |
set session sql_log_bin=0; |
| 171 |
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*"); |
| 172 |
call mtr.add_suppression("The 'replica IO' thread of channel 'ch3_2' will error out as the server will attempt to clone another server"); |
| 173 |
call mtr.add_suppression("The 'replica applier' thread of channel 'ch3_2' will error out as the server will attempt to clone another server"); |
| 174 |
call mtr.add_suppression("Run function 'thread_start' in plugin 'group_replication' failed"); |
| 175 |
call mtr.add_suppression("Run function 'applier_start' in plugin 'group_replication' failed"); |
| 176 |
call mtr.add_suppression("Replica I/O for channel 'ch3_2': Fatal error: Failed to run 'thread_start' hook, Error_code: MY-013117"); |
| 177 |
call mtr.add_suppression("Replica SQL for channel 'ch3_2': Fatal error: Failed to run 'applier_start' hook, Error_code: MY-013117"); |
| 178 |
call mtr.add_suppression("Clone removing all user data for provisioning: Started"); |
| 179 |
call mtr.add_suppression("Clone removing all user data for provisioning: Finished"); |
| 180 |
set session sql_log_bin=1; |
| 181 |
|
| 182 |
UNINSTALL PLUGIN clone; |
| 183 |
|
| 184 |
--source include/clean_monitoring_process.inc |
| 185 |
|
| 186 |
--replace_result $_group_replication_start_boot_save START_ON_BOOT_VALUE |
| 187 |
--eval SET GLOBAL group_replication_start_on_boot= $_group_replication_start_boot_save |
| 188 |
|
| 189 |
--let $rpl_connection_name= server1 |
| 190 |
--source include/rpl_connection.inc |
| 191 |
|
| 192 |
UNINSTALL PLUGIN clone; |
| 193 |
|
| 194 |
--source include/group_replication_end.inc |