| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# When changing mode to single primary with an appointed primary, P, |
| 4 |
# if P leaves or fails under a majority, when the primary election began |
| 5 |
# but is not yet over, the change will not abort and |
| 6 |
# adapt to the new elected primary throwing a warning. |
| 7 |
# |
| 8 |
# Test: |
| 9 |
# 0. This test needs three servers starting in multi primary mode |
| 10 |
# 1. Create table for tests on a multi primary group |
| 11 |
# 2. Lock table on a server that will be a secondary and set its |
| 12 |
# weight to be chosen as primary on single primary mode |
| 13 |
# 3. Insert a row on a group |
| 14 |
# 4. Invoke a change to single primary selecting server3 as new primary |
| 15 |
# 5. Check that the other members are waiting to enable |
| 16 |
# super_read_only and executing primary election |
| 17 |
# 6. Kill the primary selected when action was executed. Configure as |
| 18 |
# single primary |
| 19 |
# 7. Wait group detect exit of server3 |
| 20 |
# 8. Unblock table on member that is blocked |
| 21 |
# 9. Check that the action finishes |
| 22 |
# 10. Confirm server2 is the new primary due its weight on member |
| 23 |
# election |
| 24 |
# 11. Cleanup |
| 25 |
# |
| 26 |
############################################################################### |
| 27 |
|
| 28 |
--source include/big_test.inc |
| 29 |
--source include/have_group_replication_plugin.inc |
| 30 |
--source include/not_valgrind.inc |
| 31 |
--let $rpl_server_count= 3 |
| 32 |
--source include/group_replication.inc |
| 33 |
|
| 34 |
--echo |
| 35 |
--echo # 1. Create table for tests on a multi primary group |
| 36 |
|
| 37 |
CREATE TABLE test.t1 (a INT PRIMARY KEY); |
| 38 |
|
| 39 |
--source include/rpl_sync.inc |
| 40 |
|
| 41 |
--let $rpl_connection_name= server3 |
| 42 |
--source include/rpl_connection.inc |
| 43 |
|
| 44 |
--let $server3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 45 |
|
| 46 |
--echo |
| 47 |
--echo # 2. Lock table on a server that will be a secondary and set its |
| 48 |
--echo # weight to be chosen as primary on single primary mode |
| 49 |
|
| 50 |
--let $rpl_connection_name= server2 |
| 51 |
--source include/rpl_connection.inc |
| 52 |
|
| 53 |
SET @@GLOBAL.group_replication_member_weight= 90; |
| 54 |
|
| 55 |
LOCK TABLE t1 READ; |
| 56 |
|
| 57 |
--echo |
| 58 |
--echo # 3. Insert a row on a group |
| 59 |
|
| 60 |
--let $rpl_connection_name= server1 |
| 61 |
--source include/rpl_connection.inc |
| 62 |
|
| 63 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 64 |
|
| 65 |
--eval INSERT INTO t1 VALUES (1) |
| 66 |
|
| 67 |
--echo |
| 68 |
--echo # 4. Invoke a change to single primary selecting server3 as new primary |
| 69 |
|
| 70 |
--replace_result $server3_uuid MEMBER3_UUID |
| 71 |
--send_eval SELECT group_replication_switch_to_single_primary_mode("$server3_uuid") |
| 72 |
|
| 73 |
--echo |
| 74 |
--echo # 5. Check that the other members are waiting to enable |
| 75 |
--echo # super_read_only and executing primary election |
| 76 |
|
| 77 |
--let $rpl_connection_name= server2 |
| 78 |
--source include/rpl_connection.inc |
| 79 |
|
| 80 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/sql/Waiting for global read lock%" |
| 81 |
--source include/wait_condition.inc |
| 82 |
|
| 83 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch%";` |
| 84 |
--let $assert_text= The stage should be "Single-primary Switch: executing Primary election" |
| 85 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Single-primary Switch: executing Primary election" |
| 86 |
--source include/assert.inc |
| 87 |
|
| 88 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%global read lock%";` |
| 89 |
--let $assert_text= The stage should be "stage/sql/Waiting for global read lock" |
| 90 |
--let $assert_cond= "$stage_name" = "stage/sql/Waiting for global read lock" |
| 91 |
--source include/assert.inc |
| 92 |
|
| 93 |
--let $rpl_connection_name= server_1 |
| 94 |
--source include/rpl_connection.inc |
| 95 |
|
| 96 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Waiting for members to enable super_read_only%" |
| 97 |
--source include/wait_condition.inc |
| 98 |
|
| 99 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch%";` |
| 100 |
--let $assert_text= The stage should be "Single-primary Switch: executing Primary election" |
| 101 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Single-primary Switch: executing Primary election" |
| 102 |
--source include/assert.inc |
| 103 |
|
| 104 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%super_read_only%";` |
| 105 |
--let $assert_text= The stage should be "Primary Election: waiting for members to enable super_read_only" |
| 106 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Primary Election: waiting for members to enable super_read_only" |
| 107 |
--source include/assert.inc |
| 108 |
|
| 109 |
--echo |
| 110 |
--echo # 6. Kill the primary selected when action was executed. Configure as |
| 111 |
--echo # single primary |
| 112 |
|
| 113 |
--let $rpl_connection_name= server3 |
| 114 |
--source include/rpl_connection.inc |
| 115 |
|
| 116 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 117 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 118 |
--let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack` |
| 119 |
|
| 120 |
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $_group_replication_comm_stack GROUP_REPLICATION_COMMUNICATION_STACK |
| 121 |
--let $restart_parameters=restart:--group-replication-start-on-boot=0 --group-replication-group-name=$group_replication_group_name --group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_single_primary_mode=TRUE --group_replication_enforce_update_everywhere_checks=FALSE --group_replication_communication_stack=$_group_replication_comm_stack |
| 122 |
--source include/kill_and_restart_mysqld.inc |
| 123 |
|
| 124 |
--let $rpl_server_number= 3 |
| 125 |
--source include/rpl_reconnect.inc |
| 126 |
|
| 127 |
--echo |
| 128 |
--echo # 7. Wait group detect exit of server3 |
| 129 |
|
| 130 |
--let $rpl_connection_name= server2 |
| 131 |
--source include/rpl_connection.inc |
| 132 |
|
| 133 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 134 |
|
| 135 |
--let $group_replication_number_of_members= 2 |
| 136 |
--source include/gr_wait_for_number_of_members.inc |
| 137 |
|
| 138 |
--echo |
| 139 |
--echo # 8. Unblock table on member that is blocked |
| 140 |
|
| 141 |
UNLOCK TABLES; |
| 142 |
|
| 143 |
--echo |
| 144 |
--echo # 9. Check that the action finishes |
| 145 |
|
| 146 |
--let $rpl_connection_name= server1 |
| 147 |
--source include/rpl_connection.inc |
| 148 |
|
| 149 |
--replace_result $server3_uuid MEMBER3_UUID |
| 150 |
--reap |
| 151 |
|
| 152 |
--echo |
| 153 |
--echo # 10. Confirm server2 is the new primary due its weight on member |
| 154 |
--echo # election |
| 155 |
|
| 156 |
--let $rpl_connection_name= server2 |
| 157 |
--source include/rpl_connection.inc |
| 158 |
|
| 159 |
--source include/gr_assert_primary_member.inc |
| 160 |
|
| 161 |
--let $rpl_connection_name= server1 |
| 162 |
--source include/rpl_connection.inc |
| 163 |
|
| 164 |
--source include/gr_assert_secondary_member.inc |
| 165 |
|
| 166 |
--echo |
| 167 |
--echo # 11. Cleanup |
| 168 |
|
| 169 |
--let $rpl_connection_name= server3 |
| 170 |
--source include/rpl_connection.inc |
| 171 |
|
| 172 |
--source include/start_group_replication.inc |
| 173 |
|
| 174 |
--let $rpl_connection_name= server2 |
| 175 |
--source include/rpl_connection.inc |
| 176 |
|
| 177 |
SET @@GLOBAL.group_replication_member_weight= DEFAULT; |
| 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 |