| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# When switching to a primary server or changing mode to single primary |
| 4 |
# with an appointed primary, P, if P leaves or fails under a majority, |
| 5 |
# before the election starts, the configuration change must abort. |
| 6 |
# |
| 7 |
# The test has scenarios for each mode, Single Primary and Multi Primary mode. |
| 8 |
# |
| 9 |
# Test: |
| 10 |
# 0. This test needs three servers |
| 11 |
# 1. Multi Primary |
| 12 |
# 1.1. On server1 enable group_replication_block_group_action debug |
| 13 |
# point |
| 14 |
# 1.2. On server2 execute action to change to single primary with |
| 15 |
# server1 as primary |
| 16 |
# 1.3. Verify that server2 is checking group pre-conditions |
| 17 |
# 1.4. Stop server 1 |
| 18 |
# 1.5. Reap action to switch to single primary and it returns error as |
| 19 |
# server1 was killed |
| 20 |
# 1.6. Add suppression on server3 for action failure |
| 21 |
# 1.7. Confirm that group replication is on Multi primary server |
| 22 |
# 1.8. Cleanup to run Single Primary test |
| 23 |
# |
| 24 |
# 2. Single Primary |
| 25 |
# 2.1. Execute action to switch to single primary with server1 as |
| 26 |
# primary |
| 27 |
# 2.2. Create table on Group Replication |
| 28 |
# 2.3. Begin a transaction on server1 |
| 29 |
# 2.4. Execute action to set as primary server2 |
| 30 |
# 2.5. Verify server is waiting for pending transactions to finish in |
| 31 |
# order to conclude action |
| 32 |
# 2.6. Stop server 2 |
| 33 |
# 2.7. Verify the action executed on server1 failed, the selected server |
| 34 |
# exited from the group |
| 35 |
# 2.8. Verify that server1 is the primary |
| 36 |
# 2.9. Cleanup |
| 37 |
# |
| 38 |
############################################################################### |
| 39 |
|
| 40 |
--source include/big_test.inc |
| 41 |
--source include/have_debug_sync.inc |
| 42 |
--source include/have_group_replication_plugin.inc |
| 43 |
--let $rpl_server_count= 3 |
| 44 |
--source include/group_replication.inc |
| 45 |
|
| 46 |
--echo |
| 47 |
--echo # 1. Multi Primary |
| 48 |
|
| 49 |
--echo |
| 50 |
--echo # 1.1. On server1 enable group_replication_block_group_action debug |
| 51 |
--echo # point |
| 52 |
|
| 53 |
set session sql_log_bin=0; |
| 54 |
call mtr.add_suppression("Error while executing a group configuration operation: This operation was locally aborted and for that reason terminated."); |
| 55 |
call mtr.add_suppression("The function 'group_replication_set_as_primary' failed. Primary assigned for election left the group, this operation will be aborted*"); |
| 56 |
set session sql_log_bin=1; |
| 57 |
|
| 58 |
SET @@GLOBAL.DEBUG= '+d,group_replication_block_group_action'; |
| 59 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 60 |
|
| 61 |
--echo |
| 62 |
--echo # 1.2. On server2 execute action to change to single primary with |
| 63 |
--echo # server1 as primary |
| 64 |
|
| 65 |
--let $rpl_connection_name= server2 |
| 66 |
--source include/rpl_connection.inc |
| 67 |
|
| 68 |
set session sql_log_bin=0; |
| 69 |
call mtr.add_suppression("Error while executing a group configuration operation: This operation was locally aborted and for that reason terminated."); |
| 70 |
set session sql_log_bin=1; |
| 71 |
|
| 72 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 73 |
|
| 74 |
set session sql_log_bin=0; |
| 75 |
call mtr.add_suppression("The function 'group_replication_switch_to_single_primary_mode' failed. Primary assigned for election left the group, this operation will be aborted."); |
| 76 |
set session sql_log_bin=1; |
| 77 |
|
| 78 |
--replace_result $server1_uuid MEMBER1_UUID |
| 79 |
--send_eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 80 |
|
| 81 |
--echo |
| 82 |
--echo # 1.3. Verify that server2 is checking group pre-conditions |
| 83 |
|
| 84 |
--let $rpl_connection_name= server_2 |
| 85 |
--source include/rpl_connection.inc |
| 86 |
|
| 87 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch: checking%" |
| 88 |
--source include/wait_condition.inc |
| 89 |
|
| 90 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 91 |
--let $assert_text= stage/group_rpl/Single-primary Switch: checking group pre-conditions |
| 92 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Single-primary Switch: checking group pre-conditions" |
| 93 |
--source include/assert.inc |
| 94 |
|
| 95 |
--echo |
| 96 |
--echo # 1.4. Stop server 1 |
| 97 |
|
| 98 |
--let $rpl_connection_name= server_1 |
| 99 |
--source include/rpl_connection.inc |
| 100 |
|
| 101 |
--send STOP GROUP_REPLICATION |
| 102 |
|
| 103 |
--let $rpl_connection_name= server_2 |
| 104 |
--source include/rpl_connection.inc |
| 105 |
|
| 106 |
--let $group_replication_number_of_members= 2 |
| 107 |
--source include/gr_wait_for_number_of_members.inc |
| 108 |
|
| 109 |
--let $rpl_connection_name= server1 |
| 110 |
--source include/rpl_connection.inc |
| 111 |
|
| 112 |
SET DEBUG_SYNC= "now SIGNAL signal.action_continue"; |
| 113 |
SET @@GLOBAL.DEBUG= '-d,group_replication_block_group_action'; |
| 114 |
|
| 115 |
--let $rpl_connection_name= server_1 |
| 116 |
--source include/rpl_connection.inc |
| 117 |
|
| 118 |
--reap |
| 119 |
|
| 120 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err |
| 121 |
--let $assert_count = 1 |
| 122 |
--let $assert_select = Error while executing a group configuration operation: This operation was locally aborted and for that reason terminated. |
| 123 |
--let $assert_text = Found the expected error about the operation abort |
| 124 |
--source include/assert_grep.inc |
| 125 |
|
| 126 |
--let $assert_text= group_replication_enforce_update_everywhere_checks is ON |
| 127 |
--let $assert_cond= "[SELECT @@GLOBAL.group_replication_enforce_update_everywhere_checks]" = 1 |
| 128 |
--source include/assert.inc |
| 129 |
|
| 130 |
--let $assert_text= The single primary mode should be 0 here. |
| 131 |
--let $assert_cond= "[SELECT @@GLOBAL.group_replication_single_primary_mode]" = 0; |
| 132 |
--source include/assert.inc |
| 133 |
|
| 134 |
--echo |
| 135 |
--echo # 1.5. Reap action to switch to single primary and it returns error as |
| 136 |
--echo # server1 was killed |
| 137 |
|
| 138 |
--let $rpl_connection_name= server2 |
| 139 |
--source include/rpl_connection.inc |
| 140 |
|
| 141 |
--error ER_GRP_RPL_UDF_ERROR |
| 142 |
--reap |
| 143 |
|
| 144 |
--echo |
| 145 |
--echo # 1.6. Add suppression on server3 for action failure |
| 146 |
|
| 147 |
--let $rpl_connection_name= server3 |
| 148 |
--source include/rpl_connection.inc |
| 149 |
|
| 150 |
set session sql_log_bin=0; |
| 151 |
call mtr.add_suppression("Error while executing a group configuration operation: Primary assigned for election left the group, this operation will be aborted."); |
| 152 |
set session sql_log_bin=1; |
| 153 |
|
| 154 |
--echo |
| 155 |
--echo # 1.7. Confirm that group replication is on Multi primary server |
| 156 |
|
| 157 |
--source include/gr_assert_multi_primary_mode.inc |
| 158 |
|
| 159 |
--let $rpl_connection_name= server2 |
| 160 |
--source include/rpl_connection.inc |
| 161 |
--source include/gr_assert_multi_primary_mode.inc |
| 162 |
|
| 163 |
--echo |
| 164 |
--echo # 1.8. Cleanup to run Single Primary test |
| 165 |
|
| 166 |
--let $rpl_connection_name= server1 |
| 167 |
--source include/rpl_connection.inc |
| 168 |
|
| 169 |
--source include/start_group_replication.inc |
| 170 |
|
| 171 |
--echo |
| 172 |
--echo # 2. Single Primary |
| 173 |
|
| 174 |
--echo |
| 175 |
--echo # 2.1. Execute action to switch to single primary with server1 as |
| 176 |
--echo # primary |
| 177 |
|
| 178 |
--replace_result $server1_uuid MEMBER1_UUID |
| 179 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 180 |
|
| 181 |
--echo |
| 182 |
--echo # 2.2. Create table on Group Replication |
| 183 |
|
| 184 |
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY , b INT); |
| 185 |
|
| 186 |
--echo |
| 187 |
--echo # 2.3. Begin a transaction on server1 |
| 188 |
|
| 189 |
BEGIN; |
| 190 |
INSERT INTO test.t1 (b) VALUES (1); |
| 191 |
|
| 192 |
--echo |
| 193 |
--echo # 2.4. Execute action to set as primary server2 |
| 194 |
|
| 195 |
--let $rpl_connection_name= server_1 |
| 196 |
--source include/rpl_connection.inc |
| 197 |
|
| 198 |
--replace_result $server2_uuid MEMBER2_UUID |
| 199 |
--send_eval SELECT group_replication_set_as_primary("$server2_uuid") |
| 200 |
|
| 201 |
--echo |
| 202 |
--echo # 2.5. Verify server is waiting for pending transactions to finish in |
| 203 |
--echo # order to conclude action |
| 204 |
|
| 205 |
--let $rpl_connection_name= server_1_1 |
| 206 |
--source include/rpl_connection.inc |
| 207 |
|
| 208 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Primary Switch: waiting for pending transactions to finish" |
| 209 |
--source include/wait_condition.inc |
| 210 |
|
| 211 |
--echo |
| 212 |
--echo # 2.6. Stop server 2 |
| 213 |
|
| 214 |
--let $rpl_connection_name= server2 |
| 215 |
--source include/rpl_connection.inc |
| 216 |
|
| 217 |
--source include/stop_group_replication.inc |
| 218 |
|
| 219 |
--echo |
| 220 |
--echo # 2.7. Verify the action executed on server1 failed, |
| 221 |
--echo # the selected server exited from the group |
| 222 |
|
| 223 |
--let $rpl_connection_name= server_1 |
| 224 |
--source include/rpl_connection.inc |
| 225 |
|
| 226 |
--error ER_GRP_RPL_UDF_ERROR |
| 227 |
--reap |
| 228 |
|
| 229 |
--echo |
| 230 |
--echo # 2.8. Verify that server1 is the primary |
| 231 |
|
| 232 |
--source include/gr_assert_primary_member.inc |
| 233 |
|
| 234 |
--echo |
| 235 |
--echo # 2.9. Cleanup |
| 236 |
|
| 237 |
--let $rpl_connection_name= server1 |
| 238 |
--source include/rpl_connection.inc |
| 239 |
|
| 240 |
DROP TABLE t1; |
| 241 |
|
| 242 |
--let $rpl_connection_name= server2 |
| 243 |
--source include/rpl_connection.inc |
| 244 |
|
| 245 |
--source include/start_group_replication.inc |
| 246 |
|
| 247 |
--let $rpl_group_replication_single_primary_mode=1 |
| 248 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 249 |
--source include/group_replication_end.inc |