| 1 |
# |
| 2 |
# Test case to verify that when asynchronous replication failover is enabled, |
| 3 |
# adding one of the member of the group replication using |
| 4 |
# asynchronous_connection_failover_add_managed() does add other group members |
| 5 |
# as source for asynchronous replication channel. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. The test requires 3 servers: |
| 9 |
# server1: primary |
| 10 |
# server2: secondary |
| 11 |
# server3: single server replica |
| 12 |
# 1. Start GR on server1 & 2. |
| 13 |
# 2. Add some data to server1. |
| 14 |
# 3. Add asynchronous connection failover server and |
| 15 |
# verify that it is inserted successfully in |
| 16 |
# performance_schema.replication_asynchronous_connection_failover. |
| 17 |
# 4. Create and start new channel ch1_3: server3(replica), server1(source) |
| 18 |
# 5. Verify channel ch1_3 IO THREAD is ON |
| 19 |
# Start SQL THREAD |
| 20 |
# 6. Verify data is replicated to server1 & 3 |
| 21 |
# 7. Verify server2 which is member of group is added to |
| 22 |
# performance_schema.replication_asynchronous_connection_failover. |
| 23 |
# 8. Verify Monitor IO thread would set |
| 24 |
# stage_fetching_source_member_details, |
| 25 |
# stage_upating_source_member_details and |
| 26 |
# stage_wait_before_next_fetch state. |
| 27 |
# 9. Clean up. |
| 28 |
# |
| 29 |
--source include/big_test.inc |
| 30 |
--source include/have_group_replication_plugin.inc |
| 31 |
--let $rpl_skip_group_replication_start= 1 |
| 32 |
--let $rpl_server_count= 3 |
| 33 |
--let $rpl_group_replication_single_primary_mode=1 |
| 34 |
--source include/group_replication.inc |
| 35 |
|
| 36 |
|
| 37 |
--echo |
| 38 |
--echo # 1. Start GR on server1 & 2 |
| 39 |
--echo |
| 40 |
# Boostrap start GR on server1 (Primary) |
| 41 |
--let $rpl_connection_name= server1 |
| 42 |
--source include/rpl_connection.inc |
| 43 |
--source include/start_and_bootstrap_group_replication.inc |
| 44 |
|
| 45 |
# Start GR on server2 (Secondary) |
| 46 |
--let $rpl_connection_name= server2 |
| 47 |
--source include/rpl_connection.inc |
| 48 |
--source include/start_group_replication.inc |
| 49 |
|
| 50 |
--let $_tmp_gr_group_name= `SELECT @@GLOBAL.group_replication_group_name` |
| 51 |
|
| 52 |
|
| 53 |
--echo |
| 54 |
--echo # 2. Add some data to server1. |
| 55 |
--echo |
| 56 |
# server1: create table t1 and add data |
| 57 |
--let $rpl_connection_name= server1 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
CREATE TABLE test.t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 60 |
INSERT INTO test.t1 VALUES (1); |
| 61 |
|
| 62 |
|
| 63 |
--echo # |
| 64 |
--echo # 3. Add asynchronous connection failover server and |
| 65 |
--echo # verify that it is inserted successfully in |
| 66 |
--echo # performance_schema.replication_asynchronous_connection_failover. |
| 67 |
--echo # |
| 68 |
--let $rpl_connection_name= server3 |
| 69 |
--source include/rpl_connection.inc |
| 70 |
|
| 71 |
SET SESSION sql_log_bin = 0; |
| 72 |
call mtr.add_suppression("The source.*for channel.*has joined the group.*and so added its entry into replication_asynchronous_connection_failover table"); |
| 73 |
call mtr.add_suppression("The group .* for the channel .* has been removed, and so removed its entry from replication_asynchronous_connection_failover_managed and all the group members from replication_asynchronous_connection_failover table."); |
| 74 |
call mtr.add_suppression("The group .* for the channel .* has been added, and so added its entry in replication_asynchronous_connection_failover_managed and source to replication_asynchronous_connection_failover table."); |
| 75 |
SET SESSION sql_log_bin = 1; |
| 76 |
|
| 77 |
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $_tmp_gr_group_name FAILOVER_GROUP_NAME |
| 78 |
--eval SELECT asynchronous_connection_failover_add_managed('ch1_3', 'GroupReplication', '$_tmp_gr_group_name', '127.0.0.1', $SERVER_MYPORT_1, '', 80, 60); |
| 79 |
|
| 80 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover' |
| 81 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 82 |
--source include/assert.inc |
| 83 |
|
| 84 |
|
| 85 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover' |
| 86 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_1 AND weight=60, count, 1] = 1 |
| 87 |
--source include/assert.inc |
| 88 |
|
| 89 |
|
| 90 |
--echo |
| 91 |
--echo # 4. Create and start new channel ch1_3: server3(replica), server1(source) |
| 92 |
--echo |
| 93 |
--let $rpl_connection_name= server3 |
| 94 |
--source include/rpl_connection.inc |
| 95 |
--replace_result $SERVER_MYPORT_1 SERVER_1_PORT |
| 96 |
--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_1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2 FOR CHANNEL 'ch1_3' |
| 97 |
|
| 98 |
--let $rpl_channel_name='ch1_3' |
| 99 |
--source include/start_slave_io.inc |
| 100 |
--let $rpl_channel_name= |
| 101 |
|
| 102 |
|
| 103 |
--echo |
| 104 |
--echo # 5. Verify channel ch1_3 IO THREAD is ON |
| 105 |
--echo # Start SQL THREAD |
| 106 |
--echo |
| 107 |
--let $assert_text= Verify channel ch1_3 IO_THREAD is ON |
| 108 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = \'ch1_3\', SERVICE_STATE, 1]" = "ON" |
| 109 |
--source include/assert.inc |
| 110 |
|
| 111 |
--let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover; |
| 112 |
--source include/wait_condition.inc |
| 113 |
|
| 114 |
--let $rpl_channel_name='ch1_3' |
| 115 |
--source include/start_slave_sql.inc |
| 116 |
--let $rpl_channel_name= |
| 117 |
|
| 118 |
--let $assert_text= Verify channel ch1_3 SQL_THREAD is ON |
| 119 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1_3\', SERVICE_STATE, 1]" = "ON" |
| 120 |
--source include/assert.inc |
| 121 |
|
| 122 |
|
| 123 |
--echo |
| 124 |
--echo # 6. Verify data is replicated to server1 & 3 |
| 125 |
--echo |
| 126 |
# Sync replica(server3) with source(server1) |
| 127 |
--let $rpl_connection_name= server1 |
| 128 |
--source include/rpl_connection.inc |
| 129 |
--let $rpl_channel_name='ch1_3' |
| 130 |
--let $sync_slave_connection=server3 |
| 131 |
--source include/sync_slave_sql_with_master.inc |
| 132 |
--let $rpl_channel_name= |
| 133 |
|
| 134 |
--let $rpl_connection_name= server3 |
| 135 |
--source include/rpl_connection.inc |
| 136 |
|
| 137 |
--let $assert_text= Verify test.t1 is synced |
| 138 |
--let $assert_cond= "[SELECT count(*) COUNT FROM test.t1, COUNT, 1]" = "1" |
| 139 |
--source include/assert.inc |
| 140 |
|
| 141 |
|
| 142 |
--let $rpl_connection_name= server1 |
| 143 |
--source include/rpl_connection.inc |
| 144 |
|
| 145 |
--let $assert_text= Verify test.t1 is synced |
| 146 |
--let $assert_cond= "[SELECT count(*) COUNT FROM test.t1, COUNT, 1]" = "1" |
| 147 |
--source include/assert.inc |
| 148 |
|
| 149 |
|
| 150 |
--echo |
| 151 |
--echo # 7. Verify server2 which is member of group is added to |
| 152 |
--echo # performance_schema.replication_asynchronous_connection_failover. |
| 153 |
--echo |
| 154 |
--let $rpl_connection_name= server3 |
| 155 |
--source include/rpl_connection.inc |
| 156 |
|
| 157 |
--let $assert_text= 'There are 2 rows in performance_schema.replication_asynchronous_connection_failover' |
| 158 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 2 |
| 159 |
--source include/assert.inc |
| 160 |
|
| 161 |
--let $assert_text= Verify server1 which is primary has weight=80 |
| 162 |
--let $assert_cond= "[SELECT count(*) COUNT FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT=$SERVER_MYPORT_1 AND WEIGHT=80, COUNT, 1]" = "1" |
| 163 |
--source include/assert.inc |
| 164 |
|
| 165 |
--let $assert_text= Verify server2 which is secondary has weight=60 |
| 166 |
--let $assert_cond= "[SELECT count(*) COUNT FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT=$SERVER_MYPORT_2 AND WEIGHT=60, COUNT, 1]" = "1" |
| 167 |
--source include/assert.inc |
| 168 |
|
| 169 |
--let $assert_text= Verify Slave_monitor thread is FOREGROUND thread |
| 170 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\" AND TYPE=\"FOREGROUND\"]" = 1; |
| 171 |
--source include/assert.inc |
| 172 |
|
| 173 |
--echo |
| 174 |
--echo # 8. Verify Monitor IO thread would set |
| 175 |
--echo # stage_fetching_source_member_details, |
| 176 |
--echo # stage_upating_source_member_details and |
| 177 |
--echo # stage_wait_before_next_fetch state. |
| 178 |
--echo |
| 179 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.setup_instruments WHERE NAME LIKE 'stage/%/Fetching source member details from connected source'; |
| 180 |
--source include/wait_condition.inc |
| 181 |
|
| 182 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.setup_instruments WHERE NAME LIKE 'stage/%/Updating fetched source member details on receiver'; |
| 183 |
--source include/wait_condition.inc |
| 184 |
|
| 185 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.setup_instruments WHERE NAME LIKE 'stage/%/Wait before trying to fetch next membership changes from source'; |
| 186 |
--source include/wait_condition.inc |
| 187 |
|
| 188 |
|
| 189 |
--echo |
| 190 |
--echo # 9. Clean Up. |
| 191 |
--echo |
| 192 |
--let $rpl_connection_name= server1 |
| 193 |
--source include/rpl_connection.inc |
| 194 |
DROP TABLE test.t1; |
| 195 |
|
| 196 |
--let $sync_slave_connection= server3 |
| 197 |
--source include/sync_slave_sql_with_master.inc |
| 198 |
|
| 199 |
--let $rpl_channel_name='ch1_3' |
| 200 |
--source include/stop_slave.inc |
| 201 |
|
| 202 |
--let $rpl_reset_slave_all= 1 |
| 203 |
--let $rpl_multi_source= 1 |
| 204 |
--source include/rpl_reset_slave.inc |
| 205 |
--let $rpl_channel_name= |
| 206 |
--let $rpl_reset_slave_all= |
| 207 |
--let $rpl_multi_source= |
| 208 |
|
| 209 |
--replace_result $_tmp_gr_group_name FAILOVER_GROUP_NAME |
| 210 |
--eval SELECT asynchronous_connection_failover_delete_managed('ch1_3', '$_tmp_gr_group_name') |
| 211 |
|
| 212 |
--let $rpl_connection_name= server1 |
| 213 |
--source include/rpl_connection.inc |
| 214 |
|
| 215 |
--let $rpl_skip_sync= 1 |
| 216 |
--let $rpl_only_running_threads= 1 |
| 217 |
|
| 218 |
--source include/group_replication_end.inc |