| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# To execute a configuration change the member must be on ONLINE |
| 4 |
# state and belong to a reachable group majority. |
| 5 |
# |
| 6 |
# Also tested: |
| 7 |
# You cannot execute configuration changes when there is an active |
| 8 |
# table lock |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0. The test requires two servers: M1 and M2. |
| 12 |
# 1. Execute a switch to multi primary mode, it must be a no op since the |
| 13 |
# group is already on multi primary mode. |
| 14 |
# 2. Executing a mode change or primary election on an OFFLINE member must |
| 15 |
# fail. |
| 16 |
# 3. Executing a mode change or primary election on a RECOVERING member |
| 17 |
# must fail. |
| 18 |
# 4. Allow recovery to complete. |
| 19 |
# 5. Executing a mode change or primary election on an ERRORed member must |
| 20 |
# fail. Rectify the cause of error and bring back member ONLINE. |
| 21 |
# 6. Lock a table and try to execute a mode change. It must fail. |
| 22 |
# 7. Kill server1 to create a network partition on group. |
| 23 |
# 8. Executing a mode change or primary election on a network partition |
| 24 |
# must fail. |
| 25 |
# 9. Cleanup. |
| 26 |
# |
| 27 |
############################################################################### |
| 28 |
|
| 29 |
--source include/have_debug_sync.inc |
| 30 |
--source include/have_group_replication_plugin.inc |
| 31 |
--let $rpl_skip_group_replication_start= 1 |
| 32 |
--source include/group_replication.inc |
| 33 |
|
| 34 |
--source include/start_and_bootstrap_group_replication.inc |
| 35 |
|
| 36 |
--echo |
| 37 |
--echo # 1. Execute a switch to multi primary mode, it must be a no op since the |
| 38 |
--echo # group is already on multi primary mode. |
| 39 |
|
| 40 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 41 |
|
| 42 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 43 |
|
| 44 |
--let $rpl_connection_name= server2 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
|
| 47 |
--echo |
| 48 |
--echo # 2. Executing a mode change or primary election on an OFFLINE member |
| 49 |
--echo # must fail. |
| 50 |
|
| 51 |
--replace_result $server1_uuid MEMBER1_UUID |
| 52 |
--error ER_CANT_INITIALIZE_UDF |
| 53 |
--eval SELECT group_replication_set_as_primary("$server1_uuid") |
| 54 |
|
| 55 |
--error ER_CANT_INITIALIZE_UDF |
| 56 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 57 |
|
| 58 |
--error ER_CANT_INITIALIZE_UDF |
| 59 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 60 |
|
| 61 |
--replace_result $server1_uuid MEMBER1_UUID |
| 62 |
--error ER_CANT_INITIALIZE_UDF |
| 63 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 64 |
|
| 65 |
--echo |
| 66 |
--echo # 3. Executing a mode change or primary election on a RECOVERING member |
| 67 |
--echo # must fail. |
| 68 |
|
| 69 |
--let $rpl_connection_name= server2 |
| 70 |
--source include/rpl_connection.inc |
| 71 |
|
| 72 |
SET @@GLOBAL.DEBUG='+d,recovery_thread_wait_before_finish'; |
| 73 |
|
| 74 |
--let $group_replication_start_member_state= RECOVERING |
| 75 |
--source include/start_group_replication.inc |
| 76 |
|
| 77 |
--replace_result $server1_uuid MEMBER1_UUID |
| 78 |
--error ER_CANT_INITIALIZE_UDF |
| 79 |
--eval SELECT group_replication_set_as_primary("$server1_uuid") |
| 80 |
|
| 81 |
--error ER_CANT_INITIALIZE_UDF |
| 82 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 83 |
|
| 84 |
--error ER_CANT_INITIALIZE_UDF |
| 85 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 86 |
|
| 87 |
--replace_result $server1_uuid MEMBER1_UUID |
| 88 |
--error ER_CANT_INITIALIZE_UDF |
| 89 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 90 |
|
| 91 |
--echo |
| 92 |
--echo # 4. Allow recovery to complete. |
| 93 |
--let $rpl_connection_name= server2 |
| 94 |
--source include/rpl_connection.inc |
| 95 |
|
| 96 |
SET DEBUG_SYNC= "now WAIT_FOR signal.recovery_thread_wait_before_finish_reached"; |
| 97 |
SET @@GLOBAL.DEBUG='-d,recovery_thread_wait_before_finish'; |
| 98 |
SET DEBUG_SYNC= "now SIGNAL signal.recovery_end"; |
| 99 |
|
| 100 |
--let $group_replication_member_state= ONLINE |
| 101 |
--source include/gr_wait_for_member_state.inc |
| 102 |
|
| 103 |
SET DEBUG_SYNC= 'RESET'; |
| 104 |
|
| 105 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 106 |
|
| 107 |
--echo |
| 108 |
--echo # 5. Executing a mode change or primary election on an ERRORed member |
| 109 |
--echo # must fail. |
| 110 |
|
| 111 |
CREATE TABLE test.t1 (a INT PRIMARY KEY); |
| 112 |
|
| 113 |
set session sql_log_bin=0; |
| 114 |
INSERT INTO test.t1 VALUES (1); |
| 115 |
set session sql_log_bin=1; |
| 116 |
|
| 117 |
--source include/rpl_sync.inc |
| 118 |
|
| 119 |
--let $rpl_connection_name= server1 |
| 120 |
--source include/rpl_connection.inc |
| 121 |
INSERT INTO test.t1 VALUES (1); |
| 122 |
|
| 123 |
--let $rpl_connection_name= server2 |
| 124 |
--source include/rpl_connection.inc |
| 125 |
|
| 126 |
--let $group_replication_member_state= ERROR |
| 127 |
--source include/gr_wait_for_member_state.inc |
| 128 |
|
| 129 |
--replace_result $server1_uuid MEMBER1_UUID |
| 130 |
--error ER_CANT_INITIALIZE_UDF |
| 131 |
--eval SELECT group_replication_set_as_primary("$server1_uuid") |
| 132 |
|
| 133 |
--error ER_CANT_INITIALIZE_UDF |
| 134 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 135 |
|
| 136 |
--error ER_CANT_INITIALIZE_UDF |
| 137 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 138 |
|
| 139 |
--replace_result $server1_uuid MEMBER1_UUID |
| 140 |
--error ER_CANT_INITIALIZE_UDF |
| 141 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 142 |
|
| 143 |
--echo |
| 144 |
--echo # Rectify the cause of error and bring back member ONLINE. |
| 145 |
--source include/stop_group_replication.inc |
| 146 |
|
| 147 |
set session sql_log_bin=0; |
| 148 |
TRUNCATE TABLE t1; |
| 149 |
set session sql_log_bin=1; |
| 150 |
|
| 151 |
--let $group_replication_start_member_state= ONLINE |
| 152 |
--source include/start_group_replication.inc |
| 153 |
|
| 154 |
--echo |
| 155 |
--echo # 6. Lock a table and try to execute a mode change. It must fail. |
| 156 |
|
| 157 |
LOCK TABLE t1 WRITE; |
| 158 |
|
| 159 |
--replace_result $server1_uuid MEMBER1_UUID |
| 160 |
--error ER_CANT_INITIALIZE_UDF |
| 161 |
--eval SELECT group_replication_set_as_primary("$server1_uuid") |
| 162 |
|
| 163 |
--error ER_CANT_INITIALIZE_UDF |
| 164 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 165 |
|
| 166 |
--error ER_CANT_INITIALIZE_UDF |
| 167 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 168 |
|
| 169 |
--replace_result $server1_uuid MEMBER1_UUID |
| 170 |
--error ER_CANT_INITIALIZE_UDF |
| 171 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 172 |
|
| 173 |
UNLOCK TABLES; |
| 174 |
|
| 175 |
DROP TABLE t1; |
| 176 |
|
| 177 |
--source include/rpl_sync.inc |
| 178 |
|
| 179 |
--echo |
| 180 |
--echo # 7. Kill server1 to create a network partition on group. |
| 181 |
|
| 182 |
--let $rpl_connection_name= server1 |
| 183 |
--source include/rpl_connection.inc |
| 184 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 185 |
--shutdown_server 0 |
| 186 |
--source include/wait_until_disconnected.inc |
| 187 |
|
| 188 |
--let $rpl_connection_name= server2 |
| 189 |
--source include/rpl_connection.inc |
| 190 |
|
| 191 |
--let $group_replication_member_state= UNREACHABLE |
| 192 |
--let $group_replication_member_id= $server1_uuid |
| 193 |
--source include/gr_wait_for_member_state.inc |
| 194 |
|
| 195 |
--echo |
| 196 |
--echo # 8. Executing a mode change or primary election on a network partition |
| 197 |
--echo # must fail. |
| 198 |
|
| 199 |
--replace_result $server1_uuid MEMBER1_UUID |
| 200 |
--error ER_CANT_INITIALIZE_UDF |
| 201 |
--eval SELECT group_replication_set_as_primary("$server1_uuid") |
| 202 |
|
| 203 |
--error ER_CANT_INITIALIZE_UDF |
| 204 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 205 |
|
| 206 |
--error ER_CANT_INITIALIZE_UDF |
| 207 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 208 |
|
| 209 |
--replace_result $server1_uuid MEMBER1_UUID |
| 210 |
--error ER_CANT_INITIALIZE_UDF |
| 211 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 212 |
|
| 213 |
--echo |
| 214 |
--echo # 9. Cleanup. |
| 215 |
|
| 216 |
--let $rpl_connection_name= server_1 |
| 217 |
--source include/rpl_connection.inc |
| 218 |
|
| 219 |
--let $rpl_server_number= 1 |
| 220 |
--source include/rpl_reconnect.inc |
| 221 |
|
| 222 |
--let $rpl_connection_name= server2 |
| 223 |
--source include/rpl_connection.inc |
| 224 |
|
| 225 |
set session sql_log_bin=0; |
| 226 |
call mtr.add_suppression("Timeout while waiting for the group communication engine to exit!"); |
| 227 |
call mtr.add_suppression("The member has failed to gracefully leave the group."); |
| 228 |
call mtr.add_suppression("read failed"); |
| 229 |
call mtr.add_suppression("Could not execute Write_rows event on table test.t1"); |
| 230 |
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group."); |
| 231 |
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group."); |
| 232 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 233 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 234 |
call mtr.add_suppression("The replica coordinator and worker threads are stopped"); |
| 235 |
set session sql_log_bin=1; |
| 236 |
|
| 237 |
--let $rpl_group_replication_single_primary_mode=1 |
| 238 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 239 |
--source include/group_replication_end.inc |