| 1 |
############################################################################### |
| 2 |
# Validate that on a group mode change from multi to single-primary, |
| 3 |
# the primary shall override the replication failover channels configuration |
| 4 |
# on all group members. |
| 5 |
# |
| 6 |
# Test: |
| 7 |
# 0. This test requires three servers |
| 8 |
# 1. Deploy a group in multi-primary mode on server1 and server2. |
| 9 |
# 2. Configure a failover channel on server1 that replicates |
| 10 |
# from server3. |
| 11 |
# 3. Configure the same failover channel on server2. |
| 12 |
# In single-primary mode, the mode to which we will change, |
| 13 |
# the failover channels must exist on all members. |
| 14 |
# The channel is created with SOURCE_CONNECTION_AUTO_FAILOVER=0 |
| 15 |
# to show that it will change to SOURCE_CONNECTION_AUTO_FAILOVER=1 |
| 16 |
# when group mode changes to single-primary mode. |
| 17 |
# 4. Add some failovers sources to server2 that will be replaced |
| 18 |
# when server1 becomes the primary in single-primary mode. |
| 19 |
# 5. Change to single-primary mode. |
| 20 |
# The primary must be server1, since when a member has |
| 21 |
# replication channels running it must be the primary. |
| 22 |
# 6. Validate that server1 replication failover channels |
| 23 |
# configuration is preserved, and that it did replace the |
| 24 |
# one on server2. |
| 25 |
# 7. server1 leaves the group. |
| 26 |
# server2 is the new primary and does start the failover |
| 27 |
# channel. |
| 28 |
# 8. Clean up. |
| 29 |
############################################################################### |
| 30 |
--source include/big_test.inc |
| 31 |
--source include/have_group_replication_plugin.inc |
| 32 |
--let $rpl_skip_group_replication_start= 1 |
| 33 |
--source include/group_replication.inc |
| 34 |
|
| 35 |
|
| 36 |
--echo |
| 37 |
--echo ############################################################ |
| 38 |
--echo # 1. Deploy a group in multi-primary mode on server1 and server2. |
| 39 |
--let $rpl_connection_name= server1 |
| 40 |
--source include/rpl_connection.inc |
| 41 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 42 |
--source include/start_and_bootstrap_group_replication.inc |
| 43 |
|
| 44 |
--let $rpl_connection_name= server2 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
--source include/start_group_replication.inc |
| 47 |
|
| 48 |
|
| 49 |
--echo |
| 50 |
--echo ############################################################ |
| 51 |
--echo # 2. Configure a failover channel on server1 that replicates |
| 52 |
--echo # from server3. |
| 53 |
--let $rpl_connection_name= server3 |
| 54 |
--source include/rpl_connection.inc |
| 55 |
--let $server3_uuid= `SELECT @@server_uuid` |
| 56 |
|
| 57 |
--let $rpl_connection_name= server1 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 60 |
--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' |
| 61 |
|
| 62 |
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 |
| 63 |
--eval SELECT asynchronous_connection_failover_add_source('ch1', '127.0.0.1', $SERVER_MYPORT_3, '', 50); |
| 64 |
|
| 65 |
--let $rpl_channel_name='ch1' |
| 66 |
--source include/start_slave.inc |
| 67 |
|
| 68 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 69 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 70 |
--source include/assert.inc |
| 71 |
|
| 72 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 73 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 74 |
--source include/assert.inc |
| 75 |
|
| 76 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 77 |
--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 |
| 78 |
--source include/assert.inc |
| 79 |
|
| 80 |
--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3 |
| 81 |
--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" |
| 82 |
--source include/assert.inc |
| 83 |
|
| 84 |
--let $assert_text= Verify replica_monitor thread is running |
| 85 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 86 |
--source include/assert.inc |
| 87 |
|
| 88 |
|
| 89 |
--echo |
| 90 |
--echo ############################################################ |
| 91 |
--echo # 3. Configure the same failover channel on server2. |
| 92 |
--echo # In single-primary mode, the mode to which we will change, |
| 93 |
--echo # the failover channels must exist on all members. |
| 94 |
--echo # The channel is created with SOURCE_CONNECTION_AUTO_FAILOVER=0 |
| 95 |
--echo # to show that it will change to SOURCE_CONNECTION_AUTO_FAILOVER=1 |
| 96 |
--echo # when group mode changes to single-primary mode. |
| 97 |
--let $rpl_connection_name= server2 |
| 98 |
--source include/rpl_connection.inc |
| 99 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 100 |
--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' |
| 101 |
|
| 102 |
|
| 103 |
--echo |
| 104 |
--echo ############################################################ |
| 105 |
--echo # 4. Add some failovers sources to server2 that will be replaced |
| 106 |
--echo # when server1 becomes the primary in single-primary mode. |
| 107 |
SELECT asynchronous_connection_failover_add_source('ch1', '10.0.0.1', 3306, '', 50); |
| 108 |
SELECT asynchronous_connection_failover_add_source('ch1', '10.0.0.2', 3306, '', 50); |
| 109 |
|
| 110 |
--let $assert_text= 'There are 2 rows in performance_schema.replication_asynchronous_connection_failover' |
| 111 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 2 |
| 112 |
--source include/assert.inc |
| 113 |
|
| 114 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 2' |
| 115 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 2 |
| 116 |
|
| 117 |
SELECT * FROM performance_schema.replication_asynchronous_connection_failover; |
| 118 |
|
| 119 |
SELECT * FROM performance_schema.replication_group_configuration_version WHERE name LIKE 'replication_asynchronous_connection_failover'; |
| 120 |
|
| 121 |
--echo |
| 122 |
--echo ############################################################ |
| 123 |
--echo # 5. Change to single-primary mode. |
| 124 |
--echo # The primary must be server1, since when a member has |
| 125 |
--echo # replication channels running it must be the primary. |
| 126 |
--let $rpl_connection_name= server1 |
| 127 |
--source include/rpl_connection.inc |
| 128 |
--replace_result $server1_uuid MEMBER1_UUID |
| 129 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 130 |
--source include/gr_assert_primary_member.inc |
| 131 |
|
| 132 |
--let $rpl_connection_name= server2 |
| 133 |
--source include/rpl_connection.inc |
| 134 |
--source include/gr_assert_secondary_member.inc |
| 135 |
|
| 136 |
|
| 137 |
--echo |
| 138 |
--echo ############################################################ |
| 139 |
--echo # 6. Validate that server1 replication failover channels |
| 140 |
--echo # configuration is preserved, and that it did replace the |
| 141 |
--echo # one on server2. |
| 142 |
--let $rpl_connection_name= server1 |
| 143 |
--source include/rpl_connection.inc |
| 144 |
|
| 145 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 146 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 147 |
--source include/assert.inc |
| 148 |
|
| 149 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 150 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 151 |
--source include/assert.inc |
| 152 |
|
| 153 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 154 |
--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 |
| 155 |
--source include/assert.inc |
| 156 |
|
| 157 |
--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3 |
| 158 |
--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" |
| 159 |
--source include/assert.inc |
| 160 |
|
| 161 |
--let $applier_workers= `SELECT @@GLOBAL.SLAVE_PARALLEL_WORKERS` |
| 162 |
--let $assert_text= 'Validate the number of workers on performance_schema.replication_applier_status_by_worker table for channel ch1' |
| 163 |
--let $assert_cond= MAX(WORKER_ID) = $applier_workers FROM performance_schema.replication_applier_status_by_worker WHERE channel_name = "ch1" |
| 164 |
--source include/assert.inc |
| 165 |
|
| 166 |
--let $assert_text= Verify replica_monitor thread is running |
| 167 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 168 |
--source include/assert.inc |
| 169 |
|
| 170 |
--replace_column 3 PORT |
| 171 |
SELECT * FROM performance_schema.replication_asynchronous_connection_failover; |
| 172 |
|
| 173 |
SELECT * FROM performance_schema.replication_group_configuration_version WHERE name LIKE 'replication_asynchronous_connection_failover'; |
| 174 |
|
| 175 |
|
| 176 |
--let $rpl_connection_name= server2 |
| 177 |
--source include/rpl_connection.inc |
| 178 |
|
| 179 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 180 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 181 |
--source include/assert.inc |
| 182 |
|
| 183 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 184 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 185 |
--source include/assert.inc |
| 186 |
|
| 187 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 188 |
--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 |
| 189 |
--source include/assert.inc |
| 190 |
|
| 191 |
--let $assert_text= Verify channel ch1 IO_THREAD is OFF |
| 192 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name=\'ch1\', SERVICE_STATE, 1]" = "OFF" |
| 193 |
--source include/assert.inc |
| 194 |
|
| 195 |
--let $assert_text= Verify replica_monitor thread is not running |
| 196 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 0; |
| 197 |
--source include/assert.inc |
| 198 |
|
| 199 |
--replace_column 3 PORT |
| 200 |
SELECT * FROM performance_schema.replication_asynchronous_connection_failover; |
| 201 |
|
| 202 |
SELECT * FROM performance_schema.replication_group_configuration_version WHERE name LIKE 'replication_asynchronous_connection_failover'; |
| 203 |
|
| 204 |
|
| 205 |
--echo |
| 206 |
--echo ############################################################ |
| 207 |
--echo # 7. server1 leaves the group. |
| 208 |
--echo # server2 is the new primary and does start the failover |
| 209 |
--echo # channel. |
| 210 |
--let $rpl_connection_name= server1 |
| 211 |
--source include/rpl_connection.inc |
| 212 |
--source include/stop_group_replication.inc |
| 213 |
|
| 214 |
--let $rpl_connection_name= server2 |
| 215 |
--source include/rpl_connection.inc |
| 216 |
|
| 217 |
--let $server2_uuid= `SELECT @@server_uuid` |
| 218 |
--let $group_replication_expected_uuid= $server2_uuid |
| 219 |
--source include/gr_wait_primary_member_uuid.inc |
| 220 |
|
| 221 |
--let $rpl_channel_name= 'ch1' |
| 222 |
--source include/wait_for_slave_to_start.inc |
| 223 |
|
| 224 |
--let $assert_text= 'There is 1 row in performance_schema.replication_asynchronous_connection_failover' |
| 225 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 226 |
--source include/assert.inc |
| 227 |
|
| 228 |
--let $assert_text= 'The version of replication_asynchronous_connection_failover must be 1' |
| 229 |
--let $assert_cond= [SELECT version FROM performance_schema.replication_group_configuration_version WHERE name=\'replication_asynchronous_connection_failover\', version, 1] = 1 |
| 230 |
--source include/assert.inc |
| 231 |
|
| 232 |
--let $assert_text= 'SOURCE_CONNECTION_AUTO_FAILOVER must be enabled on ch1' |
| 233 |
--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 |
| 234 |
--source include/assert.inc |
| 235 |
|
| 236 |
--let $assert_text= Verify channel ch1 IO_THREAD is ON and connected to server3 |
| 237 |
--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" |
| 238 |
--source include/assert.inc |
| 239 |
|
| 240 |
--let $applier_workers= `SELECT @@GLOBAL.SLAVE_PARALLEL_WORKERS` |
| 241 |
--let $assert_text= 'Validate the number of workers on performance_schema.replication_applier_status_by_worker table for channel ch1' |
| 242 |
--let $assert_cond= MAX(WORKER_ID) = $applier_workers FROM performance_schema.replication_applier_status_by_worker WHERE channel_name = "ch1" |
| 243 |
--source include/assert.inc |
| 244 |
|
| 245 |
--let $assert_text= Verify replica_monitor thread is running |
| 246 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 247 |
--source include/assert.inc |
| 248 |
|
| 249 |
--replace_column 3 PORT |
| 250 |
SELECT * FROM performance_schema.replication_asynchronous_connection_failover; |
| 251 |
|
| 252 |
SELECT * FROM performance_schema.replication_group_configuration_version WHERE name LIKE 'replication_asynchronous_connection_failover'; |
| 253 |
|
| 254 |
|
| 255 |
--echo |
| 256 |
--echo ############################################################ |
| 257 |
--echo # 8. Clean up. |
| 258 |
--let $rpl_connection_name= server2 |
| 259 |
--source include/rpl_connection.inc |
| 260 |
--source include/stop_group_replication.inc |
| 261 |
|
| 262 |
--let $rpl_channel_name='ch1' |
| 263 |
--let $rpl_multi_source= 1 |
| 264 |
--let $rpl_reset_slave_all= 1 |
| 265 |
--source include/rpl_reset_slave.inc |
| 266 |
--let $rpl_channel_name= |
| 267 |
--let $rpl_multi_source= |
| 268 |
|
| 269 |
--let $rpl_connection_name= server1 |
| 270 |
--source include/rpl_connection.inc |
| 271 |
--let $rpl_channel_name='ch1' |
| 272 |
--let $rpl_multi_source= 1 |
| 273 |
--let $rpl_reset_slave_all= 1 |
| 274 |
--source include/rpl_reset_slave.inc |
| 275 |
--let $rpl_channel_name= |
| 276 |
--let $rpl_multi_source= |
| 277 |
|
| 278 |
--let $rpl_connection_name= server3 |
| 279 |
--source include/rpl_connection.inc |
| 280 |
# Ensure that all dump threads are stopped. |
| 281 |
--source include/stop_dump_threads.inc |
| 282 |
|
| 283 |
--let $rpl_group_replication_single_primary_mode=1 |
| 284 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 285 |
--source include/group_replication_end.inc |