| 1 |
############################################################################### |
| 2 |
# Validate that a primary can leave and rejoin the group when it has |
| 3 |
# replication failover channels running. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. This test requires three servers: |
| 7 |
# server1, server2: group |
| 8 |
# server3: single server |
| 9 |
# 2. Configure and start a failover channel on server1 that |
| 10 |
# replicates from server3. |
| 11 |
# 3. Validate server1 and server2 configuration. |
| 12 |
# 4. Server1 will restart and rejoin the group as secondary. |
| 13 |
# 5. Validate server1 and server2 configuration. |
| 14 |
# 6. Clean up. |
| 15 |
############################################################################### |
| 16 |
--source include/big_test.inc |
| 17 |
--source include/have_group_replication_plugin.inc |
| 18 |
--let $rpl_skip_group_replication_start= 1 |
| 19 |
--let $rpl_server_count= 3 |
| 20 |
--source include/group_replication.inc |
| 21 |
|
| 22 |
|
| 23 |
--echo |
| 24 |
--echo ############################################################ |
| 25 |
--echo # 1. Deploy a group in single-primary mode on server1 and server2. |
| 26 |
--let $rpl_connection_name= server1 |
| 27 |
--source include/rpl_connection.inc |
| 28 |
|
| 29 |
SET SESSION sql_log_bin= 0; |
| 30 |
BEGIN; |
| 31 |
call mtr.add_suppression("The 'replica applier' thread of channel 'ch1' will error out as this server is a group secondary."); |
| 32 |
call mtr.add_suppression("The 'replica IO' thread of channel 'ch1' will error out as this server is a group secondary."); |
| 33 |
call mtr.add_suppression("Run function 'applier_start' in plugin 'group_replication' failed"); |
| 34 |
call mtr.add_suppression("Run function 'thread_start' in plugin 'group_replication' failed"); |
| 35 |
call mtr.add_suppression("Replica SQL for channel 'ch1': Fatal error: Failed to run 'applier_start' hook, Error_code: MY-013117"); |
| 36 |
call mtr.add_suppression("Replica I/O for channel 'ch1': Fatal error: Failed to run 'thread_start' hook, Error_code: MY-013117"); |
| 37 |
call mtr.add_suppression("Plugin group_replication reported: 'Can't start replica IO THREAD of channel 'ch1' when group replication is running with single-primary mode on a secondary member."); |
| 38 |
COMMIT; |
| 39 |
SET SESSION sql_log_bin= 1; |
| 40 |
|
| 41 |
--source include/start_and_bootstrap_group_replication.inc |
| 42 |
--source include/gr_assert_primary_member.inc |
| 43 |
|
| 44 |
--let $rpl_connection_name= server2 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 47 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=0, SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1' |
| 48 |
|
| 49 |
--source include/start_group_replication.inc |
| 50 |
--source include/gr_assert_secondary_member.inc |
| 51 |
|
| 52 |
|
| 53 |
--echo |
| 54 |
--echo ############################################################ |
| 55 |
--echo # 2. Configure and start a failover channel on server1 that |
| 56 |
--echo # replicates from server3. |
| 57 |
--let $rpl_connection_name= server3 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
--let $server3_uuid= `SELECT @@server_uuid` |
| 60 |
|
| 61 |
--let $rpl_connection_name= server1 |
| 62 |
--source include/rpl_connection.inc |
| 63 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 64 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1' |
| 65 |
|
| 66 |
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 |
| 67 |
--eval SELECT asynchronous_connection_failover_add_source('ch1', '127.0.0.1', $SERVER_MYPORT_3, '', 50); |
| 68 |
|
| 69 |
--let $rpl_channel_name='ch1' |
| 70 |
--source include/start_slave.inc |
| 71 |
|
| 72 |
|
| 73 |
--echo |
| 74 |
--echo ############################################################ |
| 75 |
--echo # 3. Validate server1 and server2 configuration. |
| 76 |
--let $rpl_connection_name= server1 |
| 77 |
--source include/rpl_connection.inc |
| 78 |
|
| 79 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 80 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 81 |
--source include/assert.inc |
| 82 |
|
| 83 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 84 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 85 |
--source include/assert.inc |
| 86 |
|
| 87 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 88 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME="ch1" AND SOURCE_CONNECTION_AUTO_FAILOVER=1, count, 1] = 1 |
| 89 |
--source include/assert.inc |
| 90 |
|
| 91 |
--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3 |
| 92 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\' AND source_uuid=\'$server3_uuid\', SERVICE_STATE, 1]" = "ON" |
| 93 |
--source include/assert.inc |
| 94 |
|
| 95 |
--let $assert_text= Verify channel ch1 SQL_THREAD is ON |
| 96 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1\', SERVICE_STATE, 1]" = "ON" |
| 97 |
--source include/assert.inc |
| 98 |
|
| 99 |
--let $assert_text= Verify replica_monitor thread is running |
| 100 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 101 |
--source include/assert.inc |
| 102 |
|
| 103 |
--let $rpl_connection_name= server2 |
| 104 |
--source include/rpl_connection.inc |
| 105 |
|
| 106 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_asynchronous_connection_failover |
| 107 |
--source include/wait_condition.inc |
| 108 |
|
| 109 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 110 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 111 |
--source include/assert.inc |
| 112 |
|
| 113 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 114 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME="ch1" AND SOURCE_CONNECTION_AUTO_FAILOVER=1, count, 1] = 1 |
| 115 |
--source include/assert.inc |
| 116 |
|
| 117 |
--let $assert_text= Verify channel ch1 IO_THREAD is OFF |
| 118 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\', SERVICE_STATE, 1]" = "OFF" |
| 119 |
--source include/assert.inc |
| 120 |
|
| 121 |
--let $assert_text= Verify channel ch1 SQL_THREAD is OFF |
| 122 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1\', SERVICE_STATE, 1]" = "OFF" |
| 123 |
--source include/assert.inc |
| 124 |
|
| 125 |
--let $assert_text= Verify replica_monitor thread is not running |
| 126 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 0; |
| 127 |
--source include/assert.inc |
| 128 |
|
| 129 |
|
| 130 |
--echo |
| 131 |
--echo ############################################################ |
| 132 |
--echo # 4. Server1 will restart and rejoin the group as secondary. |
| 133 |
--let $rpl_connection_name= server1 |
| 134 |
--source include/rpl_connection.inc |
| 135 |
|
| 136 |
--let $allow_rpl_inited=1 |
| 137 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 138 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 139 |
--let $restart_parameters=restart:--group-replication-group-name=$group_replication_group_name --group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group-replication-start-on-boot=1 --skip-slave-start=0 |
| 140 |
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 141 |
--source include/restart_mysqld.inc |
| 142 |
|
| 143 |
--let $rpl_server_number= 1 |
| 144 |
--source include/rpl_reconnect.inc |
| 145 |
|
| 146 |
--let $group_replication_member_state= ONLINE |
| 147 |
--source include/gr_wait_for_member_state.inc |
| 148 |
|
| 149 |
|
| 150 |
--echo |
| 151 |
--echo ############################################################ |
| 152 |
--echo # 5. Validate server1 and server2 configuration. |
| 153 |
--let $rpl_connection_name= server1 |
| 154 |
--source include/rpl_connection.inc |
| 155 |
--source include/gr_assert_secondary_member.inc |
| 156 |
|
| 157 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 158 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 159 |
--source include/assert.inc |
| 160 |
|
| 161 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 162 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 163 |
--source include/assert.inc |
| 164 |
|
| 165 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 166 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME="ch1" AND SOURCE_CONNECTION_AUTO_FAILOVER=1, count, 1] = 1 |
| 167 |
--source include/assert.inc |
| 168 |
|
| 169 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE CHANNEL_NAME="ch1" and SERVICE_STATE="OFF" |
| 170 |
--source include/wait_condition.inc |
| 171 |
|
| 172 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_applier_status WHERE CHANNEL_NAME="ch1" AND SERVICE_STATE = "OFF" |
| 173 |
--source include/wait_condition.inc |
| 174 |
|
| 175 |
--let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.threads WHERE NAME="thread/sql/replica_monitor" |
| 176 |
--source include/wait_condition.inc |
| 177 |
|
| 178 |
--let $rpl_connection_name= server2 |
| 179 |
--source include/rpl_connection.inc |
| 180 |
--source include/gr_assert_primary_member.inc |
| 181 |
|
| 182 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 183 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 184 |
--source include/assert.inc |
| 185 |
|
| 186 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 187 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 188 |
--source include/assert.inc |
| 189 |
|
| 190 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 191 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME="ch1" AND SOURCE_CONNECTION_AUTO_FAILOVER=1, count, 1] = 1 |
| 192 |
--source include/assert.inc |
| 193 |
|
| 194 |
--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3 |
| 195 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\' AND source_uuid=\'$server3_uuid\', SERVICE_STATE, 1]" = "ON" |
| 196 |
--source include/assert.inc |
| 197 |
|
| 198 |
--let $assert_text= Verify channel ch1 SQL_THREAD is ON |
| 199 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1\', SERVICE_STATE, 1]" = "ON" |
| 200 |
--source include/assert.inc |
| 201 |
|
| 202 |
--let $assert_text= Verify replica_monitor thread is running |
| 203 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 204 |
--source include/assert.inc |
| 205 |
|
| 206 |
|
| 207 |
--echo |
| 208 |
--echo ############################################################ |
| 209 |
--echo # 6. Clean up. |
| 210 |
--let $rpl_connection_name= server1 |
| 211 |
--source include/rpl_connection.inc |
| 212 |
--source include/stop_group_replication.inc |
| 213 |
|
| 214 |
--let $rpl_channel_name='ch1' |
| 215 |
--let $rpl_multi_source= 1 |
| 216 |
--let $rpl_reset_slave_all= 1 |
| 217 |
--source include/rpl_reset_slave.inc |
| 218 |
--let $rpl_channel_name= |
| 219 |
--let $rpl_multi_source= |
| 220 |
|
| 221 |
--let $rpl_connection_name= server2 |
| 222 |
--source include/rpl_connection.inc |
| 223 |
--source include/stop_group_replication.inc |
| 224 |
|
| 225 |
--let $rpl_channel_name='ch1' |
| 226 |
--let $rpl_multi_source= 1 |
| 227 |
--let $rpl_reset_slave_all= 1 |
| 228 |
--source include/rpl_reset_slave.inc |
| 229 |
--let $rpl_channel_name= |
| 230 |
--let $rpl_multi_source= |
| 231 |
|
| 232 |
--source include/group_replication_end.inc |