| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# Test actions on network partitions. |
| 4 |
# Simulate a situation where the primary being elected stops responding. |
| 5 |
# The member shall be expelled and election continues with another primary |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. This test requires three servers in multi primary mode |
| 9 |
# 1. Save pid from server1 to be able to freeze it |
| 10 |
# 2. Create table t1 |
| 11 |
# 3. Lock table t1 on server2 to block action |
| 12 |
# 4. Server1 insert value on t1 |
| 13 |
# 5. Execute action switch to single primary mode |
| 14 |
# 6. Freeze server1 sending a SIGSTOP signal |
| 15 |
# 7. Wait server1 is expelled from group |
| 16 |
# 8. Unlock table to action continue |
| 17 |
# 9. Send signal to server continue its process |
| 18 |
# 10. The action is aborted on server1 |
| 19 |
# 11. Wait that server2 terminate execution of primary election |
| 20 |
# 12. Assert primary and secondary role of members |
| 21 |
# 13. Cleanup |
| 22 |
# |
| 23 |
############################################################################### |
| 24 |
|
| 25 |
--source include/big_test.inc |
| 26 |
--source include/not_valgrind.inc |
| 27 |
--source include/linux.inc |
| 28 |
--source include/have_group_replication_plugin.inc |
| 29 |
--let $rpl_server_count= 3 |
| 30 |
--source include/group_replication.inc |
| 31 |
|
| 32 |
SET SESSION sql_log_bin=0; |
| 33 |
call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR."); |
| 34 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 35 |
call mtr.add_suppression("The function 'group_replication_switch_to_single_primary_mode' failed. Member has left the group. This operation was locally aborted and for that reason terminated."); |
| 36 |
call mtr.add_suppression("read failed"); |
| 37 |
call mtr.add_suppression("\\[GCS\\] Unable to resolve peer address."); |
| 38 |
SET SESSION sql_log_bin=1; |
| 39 |
|
| 40 |
--echo |
| 41 |
--echo # 1. Save pid from server1 to be able to freeze it |
| 42 |
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 43 |
|
| 44 |
SET SESSION sql_log_bin = 0; |
| 45 |
CREATE TABLE pid_table(pid_no INT PRIMARY KEY); |
| 46 |
--let $pid_file=`SELECT @@pid_file` |
| 47 |
--replace_result $pid_file pid_file |
| 48 |
--eval LOAD DATA LOCAL INFILE '$pid_file' INTO TABLE pid_table |
| 49 |
--let $server_pid=`SELECT pid_no FROM pid_table` |
| 50 |
DROP TABLE pid_table; |
| 51 |
SET SESSION sql_log_bin = 1; |
| 52 |
|
| 53 |
--echo |
| 54 |
--echo # 2. Create table t1 |
| 55 |
|
| 56 |
CREATE TABLE test.t1 (a INT PRIMARY KEY); |
| 57 |
--source include/rpl_sync.inc |
| 58 |
|
| 59 |
--echo |
| 60 |
--echo # 3. Lock table t1 on server2 to block action |
| 61 |
|
| 62 |
--let $rpl_connection_name= server2 |
| 63 |
--source include/rpl_connection.inc |
| 64 |
--let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 65 |
|
| 66 |
LOCK TABLE t1 READ; |
| 67 |
|
| 68 |
--let $rpl_connection_name= server3 |
| 69 |
--source include/rpl_connection.inc |
| 70 |
--let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 71 |
|
| 72 |
--echo |
| 73 |
--echo # 4. Server1 insert value on t1 |
| 74 |
|
| 75 |
--let $rpl_connection_name= server1 |
| 76 |
--source include/rpl_connection.inc |
| 77 |
|
| 78 |
INSERT INTO t1 VALUES (1); |
| 79 |
|
| 80 |
--echo |
| 81 |
--echo # 5. Execute action switch to single primary mode |
| 82 |
|
| 83 |
--replace_result $member1_uuid MEMBER1_UUID |
| 84 |
--send_eval SELECT group_replication_switch_to_single_primary_mode("$member1_uuid") |
| 85 |
|
| 86 |
--echo |
| 87 |
--echo # 6. Freeze server1 sending a SIGSTOP signal |
| 88 |
|
| 89 |
--let $rpl_connection_name= server_1 |
| 90 |
--source include/rpl_connection.inc |
| 91 |
|
| 92 |
# Wait for it to start the election process to make the test deterministic |
| 93 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch: executing Primary election%" |
| 94 |
--source include/wait_condition.inc |
| 95 |
|
| 96 |
--exec kill -19 $server_pid |
| 97 |
|
| 98 |
--echo |
| 99 |
--echo # 7. Wait server1 is expelled from group |
| 100 |
|
| 101 |
--let $rpl_connection_name= server2 |
| 102 |
--source include/rpl_connection.inc |
| 103 |
|
| 104 |
--let $group_replication_number_of_members= 2 |
| 105 |
--source include/gr_wait_for_number_of_members.inc |
| 106 |
|
| 107 |
--echo |
| 108 |
--echo # 8. Unlock table to action continue |
| 109 |
|
| 110 |
UNLOCK TABLES; |
| 111 |
|
| 112 |
--echo |
| 113 |
--echo # 9. Send signal to server continue its process |
| 114 |
|
| 115 |
--let $rpl_connection_name= server_1 |
| 116 |
--source include/rpl_connection.inc |
| 117 |
|
| 118 |
--exec kill -18 $server_pid |
| 119 |
|
| 120 |
--echo |
| 121 |
--echo # 10. The action is aborted on server1 |
| 122 |
|
| 123 |
--let $rpl_connection_name= server1 |
| 124 |
--source include/rpl_connection.inc |
| 125 |
|
| 126 |
--replace_result $member1_uuid MEMBER1_UUID |
| 127 |
--error ER_GRP_RPL_UDF_ERROR |
| 128 |
--reap |
| 129 |
|
| 130 |
--echo |
| 131 |
--echo # 11. Wait that server2 terminate execution of primary election |
| 132 |
|
| 133 |
--let $rpl_connection_name= server2 |
| 134 |
--source include/rpl_connection.inc |
| 135 |
|
| 136 |
--let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" |
| 137 |
--source include/wait_condition.inc |
| 138 |
|
| 139 |
--let $rpl_connection_name= server3 |
| 140 |
--source include/rpl_connection.inc |
| 141 |
|
| 142 |
--let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" |
| 143 |
--source include/wait_condition.inc |
| 144 |
|
| 145 |
--echo |
| 146 |
--echo # 12. Assert primary and secondary role of members |
| 147 |
|
| 148 |
--let $server_primary= server2 |
| 149 |
--let $server_secondary= server3 |
| 150 |
|
| 151 |
if(`SELECT "$member2_uuid" > "$member3_uuid"`) |
| 152 |
{ |
| 153 |
--let $server_primary= server3 |
| 154 |
--let $server_secondary= server2 |
| 155 |
} |
| 156 |
|
| 157 |
--connection $server_secondary |
| 158 |
|
| 159 |
--source include/gr_assert_secondary_member.inc |
| 160 |
|
| 161 |
--connection $server_primary |
| 162 |
|
| 163 |
--source include/gr_assert_primary_member.inc |
| 164 |
|
| 165 |
--echo |
| 166 |
--echo # 13. Cleanup |
| 167 |
|
| 168 |
--let $rpl_connection_name= server1 |
| 169 |
--source include/rpl_connection.inc |
| 170 |
|
| 171 |
--source include/stop_group_replication.inc |
| 172 |
SET GLOBAL group_replication_enforce_update_everywhere_checks= FALSE; |
| 173 |
SET GLOBAL group_replication_single_primary_mode= TRUE; |
| 174 |
--source include/start_group_replication.inc |
| 175 |
|
| 176 |
--connection $server_primary |
| 177 |
|
| 178 |
DROP TABLE t1; |
| 179 |
|
| 180 |
--let $rpl_group_replication_single_primary_mode=1 |
| 181 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 182 |
--source include/group_replication_end.inc |