| 1 |
################################################################################ |
| 2 |
# This test validates that in a group with two members, if one of the members |
| 3 |
# goes away, the group will block. In addition, it also checks that if the |
| 4 |
# group is forcefully reconfigured the system will resume operations. |
| 5 |
# |
| 6 |
# It is a variation of other reconfiguration tests that we have deployed |
| 7 |
# already, except that this tests the case of 2 servers only. |
| 8 |
# |
| 9 |
# The test does the following: |
| 10 |
# 0. The test requires two servers: server1 and server2. |
| 11 |
# 1. Bootstrap start group on server1. Start GR on server2. Create table on |
| 12 |
# server2 for replicating data. |
| 13 |
# 2. Crashes one server: server2. |
| 14 |
# 3. Issue a transaction on the server1 that is still up and validate that it |
| 15 |
# blocks (best effort test). |
| 16 |
# 4. Validate that the group configuration still shows up as two servers. |
| 17 |
# 5. Unblock the group by reconfiguring it forcefully to a single server. |
| 18 |
# 6. Check that the pending transaction was unblocked. |
| 19 |
# 7. Validate that the configuration is now a single server. |
| 20 |
# 8. Issue a new transaction and validate that it completes. |
| 21 |
# 9. Join server2 again. |
| 22 |
# 10. Check that the group configuration has changed on both servers. |
| 23 |
# 11. Check that the contents of the replicated table are in sync. |
| 24 |
################################################################################ |
| 25 |
# This test does crashes servers, thence we skip it on valgrind. |
| 26 |
--source include/not_valgrind.inc |
| 27 |
--source include/big_test.inc |
| 28 |
--source include/force_restart.inc |
| 29 |
--source include/have_group_replication_plugin.inc |
| 30 |
|
| 31 |
### |
| 32 |
### 1. sets up the group with two servers: server1 and server2 |
| 33 |
### |
| 34 |
|
| 35 |
--let $rpl_server_count= 2 |
| 36 |
--let $rpl_skip_group_replication_start= 1 |
| 37 |
--source include/group_replication.inc |
| 38 |
|
| 39 |
--let $rpl_connection_name= server1 |
| 40 |
--source include/rpl_connection.inc |
| 41 |
--source include/start_and_bootstrap_group_replication.inc |
| 42 |
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 43 |
|
| 44 |
--let $rpl_connection_name= server2 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
--let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 47 |
|
| 48 |
SET SQL_LOG_BIN=0; |
| 49 |
call mtr.add_suppression("site definition is null"); |
| 50 |
SET SQL_LOG_BIN=1; |
| 51 |
|
| 52 |
# start the server |
| 53 |
--source include/start_group_replication.inc |
| 54 |
|
| 55 |
# save this, since it will be used to recover the server later on |
| 56 |
--let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address` |
| 57 |
--let $group_seeds_server2= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 58 |
|
| 59 |
# create a table for replicating data |
| 60 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 61 |
--source include/rpl_sync.inc |
| 62 |
|
| 63 |
### |
| 64 |
### 2. crashes one server: server2 |
| 65 |
### |
| 66 |
|
| 67 |
# |
| 68 |
# We do kill and restart the servers. We wait for the server to start. |
| 69 |
# |
| 70 |
# However, since the servers loose its GCS configuration they |
| 71 |
# will not rejoin the group. |
| 72 |
# |
| 73 |
--let $rpl_connection_name= server2 |
| 74 |
--source include/rpl_connection.inc |
| 75 |
|
| 76 |
--source include/kill_and_restart_mysqld.inc |
| 77 |
|
| 78 |
--let $rpl_connection_name= server_1 |
| 79 |
--source include/rpl_connection.inc |
| 80 |
|
| 81 |
# |
| 82 |
# Wait for the member state be unreachable, meaning |
| 83 |
# that we have lost quorum and we are conveying the |
| 84 |
# information to the user that the we are unable to |
| 85 |
# speak to server 2. |
| 86 |
# |
| 87 |
--let $group_replication_member_state= UNREACHABLE |
| 88 |
--let $group_replication_member_id= $member2_uuid |
| 89 |
--source include/gr_wait_for_member_state.inc |
| 90 |
# reset the group_replication_id var |
| 91 |
--let $group_replication_member_id= $member1_uuid |
| 92 |
|
| 93 |
--let $rpl_server_number= 2 |
| 94 |
--source include/rpl_reconnect.inc |
| 95 |
|
| 96 |
--let $rpl_connection_name= server_2 |
| 97 |
--source include/rpl_connection.inc |
| 98 |
|
| 99 |
--replace_result $group_seeds_server2 GROUP_SEEDS_SERVER2 |
| 100 |
--eval SET @@global.group_replication_group_seeds="$group_seeds_server2" |
| 101 |
--replace_result $local_address_server2 LOCAL_ADDRESS_SERVER2 |
| 102 |
--eval SET @@global.group_replication_local_address="$local_address_server2" |
| 103 |
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 104 |
--eval SET @@global.group_replication_group_name="$group_replication_group_name" |
| 105 |
|
| 106 |
### |
| 107 |
### 3. issue a transaction on the server that is still up |
| 108 |
### and validate that it blocks (best effort test) |
| 109 |
### |
| 110 |
# Group is blocked and so cannot change its configuration. |
| 111 |
--let $rpl_connection_name= server_1 |
| 112 |
--source include/rpl_connection.inc |
| 113 |
--let $group_replication_number_of_members= 2 |
| 114 |
--source include/gr_wait_for_number_of_members.inc |
| 115 |
|
| 116 |
# This transaction will be blocked since group lost its majority. |
| 117 |
# Though it needs to be delivered to the group when unblocked. |
| 118 |
--send INSERT INTO t1 VALUES (1) |
| 119 |
|
| 120 |
--let $rpl_connection_name= server1 |
| 121 |
--source include/rpl_connection.inc |
| 122 |
--let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address` |
| 123 |
|
| 124 |
# wait until the transaction blocks on "waiting for handler commit" |
| 125 |
--let $wait_condition= select PROCESSLIST_STATE="waiting for handler commit" from performance_schema.threads where processlist_INFO LIKE "INSERT INTO t1 VALUES (1)" |
| 126 |
--source include/wait_condition.inc |
| 127 |
|
| 128 |
### |
| 129 |
### 4. validate that the group configuration still shows |
| 130 |
### up as two servers (and one is unreachable) |
| 131 |
### |
| 132 |
|
| 133 |
# verify that there are still two members in the group |
| 134 |
--let $group_replication_number_of_members= 2 |
| 135 |
--source include/gr_wait_for_number_of_members.inc |
| 136 |
|
| 137 |
--let $assert_text= t1 does not have 2 inserted into it yet |
| 138 |
--let $assert_cond= COUNT(*)=0 FROM t1 |
| 139 |
--source include/assert.inc |
| 140 |
|
| 141 |
--let $res= `SELECT COUNT(*)=1 FROM performance_schema.replication_group_members WHERE member_id="$member2_uuid" AND member_state="UNREACHABLE"` |
| 142 |
--let $assert_text= server 2 is marked as unreachable |
| 143 |
--let $assert_cond= $res = 1 |
| 144 |
--source include/assert.inc |
| 145 |
|
| 146 |
### |
| 147 |
### 5. Unblock the group by reconfiguring it forcefully to a |
| 148 |
### single server. |
| 149 |
|
| 150 |
--disable_query_log |
| 151 |
--eval SET GLOBAL group_replication_force_members= "$local_address_server1" |
| 152 |
--enable_query_log |
| 153 |
|
| 154 |
--let $assert_text= group_replication_force_members is correct |
| 155 |
--let $assert_cond= "[SELECT @@GLOBAL.group_replication_force_members]" = "$local_address_server1" |
| 156 |
--source include/assert.inc |
| 157 |
|
| 158 |
# verify that the table has now only 1 member |
| 159 |
--let $group_replication_number_of_members= 1 |
| 160 |
--source include/gr_wait_for_number_of_members.inc |
| 161 |
|
| 162 |
# no more unreachable entries in the table |
| 163 |
--let $res= `SELECT COUNT(*)=0 FROM performance_schema.replication_group_members WHERE member_state="UNREACHABLE"` |
| 164 |
--let $assert_text= No more unreachable servers in the P_S table. |
| 165 |
--let $assert_cond= $res = 1 |
| 166 |
--source include/assert.inc |
| 167 |
|
| 168 |
### |
| 169 |
### 6. Check that the pending transaction was unblocked. |
| 170 |
### |
| 171 |
|
| 172 |
# the transaction will resume now |
| 173 |
--let $wait_condition= SELECT COUNT(*)=1 FROM t1 |
| 174 |
--source include/wait_condition.inc |
| 175 |
|
| 176 |
# reap the transaction that had been waiting for the majority |
| 177 |
--let $rpl_connection_name= server_1 |
| 178 |
--source include/rpl_connection.inc |
| 179 |
--reap |
| 180 |
|
| 181 |
### |
| 182 |
### 7. validate that the configuration is now a single server |
| 183 |
### |
| 184 |
|
| 185 |
--let $rpl_connection_name= server1 |
| 186 |
--source include/rpl_connection.inc |
| 187 |
|
| 188 |
--let $group_replication_number_of_members= 1 |
| 189 |
--source include/gr_wait_for_number_of_members.inc |
| 190 |
|
| 191 |
--let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 192 |
--let $assert_text= Server 1 must be present on group members |
| 193 |
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.replication_group_members WHERE member_id="$server_uuid"] = 1 |
| 194 |
--source include/assert.inc |
| 195 |
|
| 196 |
--let $raw_view_id= query_get_value(SELECT view_id FROM performance_schema.replication_group_member_stats, view_id, 1) |
| 197 |
--let $view_id= `SELECT RIGHT('$raw_view_id', 1)` |
| 198 |
--let $assert_text= The value of view_id must be random:3 |
| 199 |
--let $assert_cond= $view_id >= 3 |
| 200 |
--source include/assert.inc |
| 201 |
|
| 202 |
### |
| 203 |
### 8. issue a new transaction and validate that it completes. |
| 204 |
### |
| 205 |
--let $rpl_connection_name= server1 |
| 206 |
--source include/rpl_connection.inc |
| 207 |
INSERT INTO t1 VALUES (2); |
| 208 |
|
| 209 |
--let $assert_text= 'There are two values in table t1' |
| 210 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2 |
| 211 |
--source include/assert.inc |
| 212 |
|
| 213 |
### |
| 214 |
### 9. join server 2 again |
| 215 |
### |
| 216 |
|
| 217 |
--let $rpl_connection_name= server2 |
| 218 |
--source include/rpl_connection.inc |
| 219 |
|
| 220 |
# this already waits for recovery to happen |
| 221 |
--source include/start_group_replication.inc |
| 222 |
|
| 223 |
--let $rpl_connection_name= server1 |
| 224 |
--source include/rpl_connection.inc |
| 225 |
|
| 226 |
# sync just to make sure |
| 227 |
--source include/rpl_sync.inc |
| 228 |
|
| 229 |
### |
| 230 |
### 10. check that the group configuration has changed on both |
| 231 |
### servers |
| 232 |
|
| 233 |
# validate that there are two servers in the group |
| 234 |
--let $group_replication_number_of_members= 2 |
| 235 |
--source include/gr_wait_for_number_of_members.inc |
| 236 |
|
| 237 |
--let $rpl_connection_name= server2 |
| 238 |
--source include/rpl_connection.inc |
| 239 |
|
| 240 |
# validate that there are two servers in the group |
| 241 |
--let $group_replication_number_of_members= 2 |
| 242 |
--source include/gr_wait_for_number_of_members.inc |
| 243 |
|
| 244 |
### |
| 245 |
### 11. check that the contents of the replicated table are |
| 246 |
### in sync |
| 247 |
### |
| 248 |
|
| 249 |
# validate that the table content is in sync |
| 250 |
--let diff_tables=server1:test.t1,server2:test.t1 |
| 251 |
--source include/diff_tables.inc |
| 252 |
|
| 253 |
### Cleanup |
| 254 |
|
| 255 |
--let $rpl_connection_name= server1 |
| 256 |
--source include/rpl_connection.inc |
| 257 |
|
| 258 |
DROP table t1; |
| 259 |
|
| 260 |
--source include/group_replication_end.inc |