| 1 |
# |
| 2 |
# Validate that stopping one replica doesn't stop Monitor IO thread till other |
| 3 |
# managed IO threads are running. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires 5 servers: |
| 7 |
# server1: group A primary |
| 8 |
# server2: group A secondary |
| 9 |
# server3: group B primary |
| 10 |
# server4: group B secondary |
| 11 |
# server5: single server |
| 12 |
# 1. Deploy a 2 members group A in single primary mode. |
| 13 |
# 2. Deploy a 2 members group B in single primary mode. |
| 14 |
# 3. Configure replica to manage the asynchronous connection |
| 15 |
# to groups A and B. |
| 16 |
# 4. Create and start two managed channel. |
| 17 |
# 5. Stop one of the replicas and verify Monitor IO thread is still running. |
| 18 |
# 6. Stop the primary of group A and validate the ch2 reconnects to |
| 19 |
# the new primary (server4). |
| 20 |
# 7. Clean up. |
| 21 |
# |
| 22 |
--source include/big_test.inc |
| 23 |
--source include/have_group_replication_plugin.inc |
| 24 |
--let $rpl_skip_group_replication_start= 1 |
| 25 |
--let $rpl_server_count= 5 |
| 26 |
--source include/group_replication.inc |
| 27 |
|
| 28 |
|
| 29 |
--echo |
| 30 |
--echo # 1. Deploy a 2 members group A in single primary mode. |
| 31 |
--echo |
| 32 |
--let $rpl_connection_name= server1 |
| 33 |
--source include/rpl_connection.inc |
| 34 |
--let $server1_uuid= `SELECT @@server_uuid` |
| 35 |
--let $group_replication_group_name= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa |
| 36 |
--let $group_a= $group_replication_group_name |
| 37 |
--disable_query_log |
| 38 |
if ($have_xcom_stack){ |
| 39 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2" |
| 40 |
} |
| 41 |
|
| 42 |
if (!$have_xcom_stack){ |
| 43 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2" |
| 44 |
} |
| 45 |
--enable_query_log |
| 46 |
--source include/start_and_bootstrap_group_replication.inc |
| 47 |
|
| 48 |
--let $rpl_connection_name= server2 |
| 49 |
--source include/rpl_connection.inc |
| 50 |
--let $server2_uuid= `SELECT @@server_uuid` |
| 51 |
--disable_query_log |
| 52 |
if ($have_xcom_stack){ |
| 53 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_1,localhost:$SERVER_GR_PORT_2" |
| 54 |
} |
| 55 |
|
| 56 |
if (!$have_xcom_stack){ |
| 57 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_1,localhost:$SERVER_MYPORT_2" |
| 58 |
} |
| 59 |
--enable_query_log |
| 60 |
--source include/start_group_replication.inc |
| 61 |
|
| 62 |
|
| 63 |
--echo |
| 64 |
--echo # 2. Deploy a 2 members group B in single primary mode. |
| 65 |
--echo |
| 66 |
--let $rpl_connection_name= server3 |
| 67 |
--source include/rpl_connection.inc |
| 68 |
--let $server3_uuid= `SELECT @@server_uuid` |
| 69 |
--let $group_replication_group_name= bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb |
| 70 |
--let $group_b= $group_replication_group_name |
| 71 |
--disable_query_log |
| 72 |
if ($have_xcom_stack){ |
| 73 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4" |
| 74 |
} |
| 75 |
if (!$have_xcom_stack){ |
| 76 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4" |
| 77 |
} |
| 78 |
--enable_query_log |
| 79 |
--source include/start_and_bootstrap_group_replication.inc |
| 80 |
|
| 81 |
--let $rpl_connection_name= server4 |
| 82 |
--source include/rpl_connection.inc |
| 83 |
--let $server4_uuid= `SELECT @@server_uuid` |
| 84 |
--disable_query_log |
| 85 |
if ($have_xcom_stack){ |
| 86 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_GR_PORT_3,localhost:$SERVER_GR_PORT_4" |
| 87 |
} |
| 88 |
if (!$have_xcom_stack){ |
| 89 |
--eval SET GLOBAL group_replication_group_seeds= "localhost:$SERVER_MYPORT_3,localhost:$SERVER_MYPORT_4" |
| 90 |
} |
| 91 |
--enable_query_log |
| 92 |
--source include/start_group_replication.inc |
| 93 |
|
| 94 |
|
| 95 |
--echo |
| 96 |
--echo # 3. Configure replica to manage the asynchronous connection |
| 97 |
--echo # to groups A and B. |
| 98 |
--echo |
| 99 |
--let $rpl_connection_name= server5 |
| 100 |
--source include/rpl_connection.inc |
| 101 |
|
| 102 |
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT $group_a GROUP_A |
| 103 |
--eval SELECT asynchronous_connection_failover_add_managed('ch1', 'GroupReplication', '$group_a', '127.0.0.1', $SERVER_MYPORT_2, '', 90, 70); |
| 104 |
|
| 105 |
--replace_result $SERVER_MYPORT_4 SERVER_MYPORT $group_b GROUP_B |
| 106 |
--eval SELECT asynchronous_connection_failover_add_managed('ch2', 'GroupReplication', '$group_b', '127.0.0.1', $SERVER_MYPORT_4, '', 85, 65); |
| 107 |
|
| 108 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server2' |
| 109 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_2, count, 1] = 1 |
| 110 |
--source include/assert.inc |
| 111 |
|
| 112 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover for server4' |
| 113 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover WHERE port=$SERVER_MYPORT_4, count, 1] = 1 |
| 114 |
--source include/assert.inc |
| 115 |
|
| 116 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group A' |
| 117 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_a", count, 1] = 1 |
| 118 |
--source include/assert.inc |
| 119 |
|
| 120 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover_managed for group B' |
| 121 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover_managed WHERE managed_name="$group_b", count, 1] = 1 |
| 122 |
--source include/assert.inc |
| 123 |
|
| 124 |
|
| 125 |
--echo |
| 126 |
--echo # 4. Create and start two managed channel. |
| 127 |
--echo |
| 128 |
--let $rpl_connection_name= server5 |
| 129 |
--source include/rpl_connection.inc |
| 130 |
--replace_result $SERVER_MYPORT_1 SERVER_1_PORT |
| 131 |
--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=1 FOR CHANNEL 'ch1' |
| 132 |
|
| 133 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 134 |
--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 'ch2' |
| 135 |
|
| 136 |
--let $rpl_channel_name='ch1' |
| 137 |
--source include/start_slave.inc |
| 138 |
--let $rpl_channel_name= |
| 139 |
|
| 140 |
--let $rpl_channel_name='ch2' |
| 141 |
--source include/start_slave.inc |
| 142 |
--let $rpl_channel_name= |
| 143 |
|
| 144 |
--let $wait_condition= SELECT COUNT(*)=4 FROM performance_schema.replication_asynchronous_connection_failover |
| 145 |
--source include/wait_condition.inc |
| 146 |
|
| 147 |
|
| 148 |
--echo |
| 149 |
--echo # 5. Stop one of the replicas and verify Monitor IO thread is still running. |
| 150 |
--echo |
| 151 |
--let $rpl_connection_name= server5 |
| 152 |
--source include/rpl_connection.inc |
| 153 |
--let $assert_text= Verify replica_monitor thread is running |
| 154 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 155 |
--source include/assert.inc |
| 156 |
|
| 157 |
--let $rpl_channel_name='ch1' |
| 158 |
--source include/stop_slave.inc |
| 159 |
|
| 160 |
--let $assert_text= Verify replica_monitor thread is running |
| 161 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 1; |
| 162 |
--source include/assert.inc |
| 163 |
|
| 164 |
|
| 165 |
--echo |
| 166 |
--echo # 6. Stop the primary of group A and validate the ch2 reconnects to |
| 167 |
--echo # the new primary (server4). |
| 168 |
--echo |
| 169 |
--let $rpl_connection_name= server3 |
| 170 |
--source include/rpl_connection.inc |
| 171 |
--source include/stop_group_replication.inc |
| 172 |
|
| 173 |
--let $rpl_connection_name= server5 |
| 174 |
--source include/rpl_connection.inc |
| 175 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='ch2' AND source_uuid='$server4_uuid'; |
| 176 |
--source include/wait_condition.inc |
| 177 |
|
| 178 |
|
| 179 |
--echo |
| 180 |
--echo # 7. Clean up. |
| 181 |
--echo |
| 182 |
|
| 183 |
--let $rpl_connection_name= server5 |
| 184 |
--source include/rpl_connection.inc |
| 185 |
|
| 186 |
SET SESSION sql_log_bin = 0; |
| 187 |
call mtr.add_suppression("The IO thread detected that the source .* does not belong to the group majority, thence the channel 'ch2' will try to connect to another source."); |
| 188 |
call mtr.add_suppression("The Monitor IO thread detected that the source .* does not belong to the group majority, thence the channel 'ch2' will try to connect to another source."); |
| 189 |
SET SESSION sql_log_bin = 1; |
| 190 |
|
| 191 |
--let $rpl_channel_name='ch2' |
| 192 |
--source include/stop_slave.inc |
| 193 |
|
| 194 |
--let $assert_text= Verify replica_monitor thread is not running |
| 195 |
--let $assert_cond= "[select count(*) FROM performance_schema.threads where NAME=\"thread/sql/replica_monitor\"]" = 0; |
| 196 |
--source include/assert.inc |
| 197 |
|
| 198 |
--let $rpl_reset_slave_all= 1 |
| 199 |
--let $rpl_multi_source= 1 |
| 200 |
--source include/rpl_reset_slave.inc |
| 201 |
--let $rpl_channel_name= |
| 202 |
--let $rpl_reset_slave_all= |
| 203 |
--let $rpl_multi_source= |
| 204 |
|
| 205 |
--let $rpl_channel_name='ch1' |
| 206 |
--let $rpl_reset_slave_all= 1 |
| 207 |
--let $rpl_multi_source= 1 |
| 208 |
--source include/rpl_reset_slave.inc |
| 209 |
--let $rpl_channel_name= |
| 210 |
--let $rpl_reset_slave_all= |
| 211 |
--let $rpl_multi_source= |
| 212 |
|
| 213 |
--replace_result $group_a GROUP_A |
| 214 |
--eval SELECT asynchronous_connection_failover_delete_managed('ch1', '$group_a') |
| 215 |
|
| 216 |
--replace_result $group_b GROUP_B |
| 217 |
--eval SELECT asynchronous_connection_failover_delete_managed('ch2', '$group_b') |
| 218 |
|
| 219 |
--let $rpl_connection_name= server4 |
| 220 |
--source include/rpl_connection.inc |
| 221 |
--source include/stop_group_replication.inc |
| 222 |
|
| 223 |
--let $rpl_connection_name= server2 |
| 224 |
--source include/rpl_connection.inc |
| 225 |
--source include/stop_group_replication.inc |
| 226 |
|
| 227 |
--let $rpl_connection_name= server1 |
| 228 |
--source include/rpl_connection.inc |
| 229 |
--source include/stop_group_replication.inc |
| 230 |
|
| 231 |
--source include/group_replication_end.inc |