1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
|
################################################################################
#
# WL#10412: GR: notify listener services on relevant group events
#
# This test case checks that the correct notifications are
# triggered to the listeners registered in the service registry.
#
# For that it relies on a table that is updated by a listener
# through the SQL service API.
#
# This file covers the scenarios where QUORUM is lost.
#
# |------------+----+---------------------------------------------+------------+--------|
# | Tested | | Scenario\Where | | |
# | in this | | | Server | Others |
# | file | | | triggering | |
# | | | | event | |
# |------------+----+---------------------------------------------+------------+--------|
# | | 1 | SERVER BOOTSTRAPS GROUP | VC,2xSC | N/A |
# | | 2 | SERVER JOINS and STARTS RECOVERY | VC,SC | VC,SC |
# | | 3 | SERVER RECOVERED | SC | SC |
# | | 4 | SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)| VC,SC | VC |
# |------------+----+---------------------------------------------+------------+--------|
# | | 5 | SERVER BOOTSTRAPS+RECOVERS+PRIMARY ELECTION | VC,RC,2xSC | |
# | | 6 | PRIMARY LEAVES | VC,SC,RC | VC,RC |
# |------------+----+---------------------------------------------+------------+--------|
# | x | 7 | A SERVER BECOMES UNREACHABLE | SC, VC | N/A |
# | x | 8 | MAJORITY UNREACHABLE | QL, SC | N/A |
# | x | 9 | MAJORITY UNREACHABLE+FORCE MEMBERS | VC | N/A |
# | x | 10 | MAJORITY UNREACHABLE+STOP | VC, SC | N/A |
# |------------+----+---------------------------------------------+------------+--------|
#
# Legend:
# - QL - Quorum Lost event
# - VC - View Changed event
# - RC - Role Changed event
# - SC - State Changed event
#
# To test the cases above, the test sets up a group of
# 3 servers in multi-master mode and proceeds to testing
# the different scenarios. These are highlighted in the
# test file.
#
################################################################################
--source include/have_debug.inc
--source include/not_valgrind.inc
--source include/force_restart.inc
--source include/big_test.inc
--source include/not_have_privilege_checks_user.inc
--source include/have_group_replication_plugin.inc
###
### Sets up the group with three servers: server1, server2 and server3
###
--let $rpl_server_count= 3
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
# server 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $debug_point= register_gms_listener_example
--source include/add_debug_point.inc
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address`
--let $group_seeds_server1= `SELECT @@global.group_replication_group_seeds`
--disable_query_log
SET SQL_LOG_BIN=0;
CREATE TABLE test.gms_listener_example(log_message TEXT);
call mtr.add_suppression("The member has failed to gracefully leave the group.");
call mtr.add_suppression("Timeout while waiting for the group communication");
call mtr.add_suppression("read failed");
SET SQL_LOG_BIN=1;
--enable_query_log
# server 2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $debug_point= register_gms_listener_example
--source include/add_debug_point.inc
--let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address`
--let $group_seeds_server2= `SELECT @@global.group_replication_group_seeds`
SET SQL_LOG_BIN=0;
CREATE TABLE test.gms_listener_example(log_message TEXT);
SET SQL_LOG_BIN=1;
# server 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $debug_point= register_gms_listener_example
--source include/add_debug_point.inc
--let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--let $local_address_server3= `SELECT @@GLOBAL.group_replication_local_address`
--let $group_seeds_server3= `SELECT @@global.group_replication_group_seeds`
SET SQL_LOG_BIN=0;
CREATE TABLE test.gms_listener_example(log_message TEXT);
SET SQL_LOG_BIN=1;
--echo ### Scenario 7: SERVER UNREACHABLE
--echo ### Expected:
--echo ### - Correct Servers: 1 STATE CHANGED (and eventually a VIEW CHANGED)
--echo ### - Failed server: N/A
--echo ##########################################################
# server1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_and_bootstrap_group_replication.inc
# server2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/start_group_replication.inc
# server3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/start_group_replication.inc
# wait for the new view to be installed
--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc
# server2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
# wait for the new view to be installed
--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc
# server1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# wait for the new view to be installed
--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc
# clear notification table everywhere
TRUNCATE gms_listener_example;
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
--source include/rpl_sync.inc
--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--enable_reconnect
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/kill_and_restart_mysqld.inc
--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--source include/wait_until_connected_again.inc
--disable_reconnect
# server2
# There is no point in asserting for server2 that the member
# state has changed, since the local view may not be delivered
# before the view change is received. I.e., server2 may not
# have a chance to check locally for possibly detected members
# before it gets the view change triggered by server1 (the
# killer node, the one that expels)
# server1
#
# server1 will always suspect (deliver a local view) and trigger
# a view change by sending the global view. Therefore we can assert
# that an UNREACHABLE notification is performed. The assumption here
# is that server1 is the "leader" node on xcom that sends the global
# view.
#
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# wait for the new view to be installed
--let $group_replication_number_of_members= 2
--source include/gr_wait_for_number_of_members.inc
--let $expected_notifications= 1,STATE %:3|1,VIEW %:4
--source ../include/assert_notifications.inc
--echo ### Scenario 8: MAJORITY UNREACHABLE
--echo ### Expected:
--echo ### - Correct Servers: 1 QUORUM LOST, 1 STATE CHANGED
--echo ### - Failed Servers: N/A
--echo ##########################################################
# server2
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--enable_reconnect
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/kill_and_restart_mysqld.inc
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/wait_until_connected_again.inc
--disable_reconnect
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# wait for server2 to become unreachable
# at this point we have lost quorum
--let $group_replication_member_state= UNREACHABLE
--let $group_replication_member_id= $member2_uuid
--source include/gr_wait_for_member_state.inc
# assert that notification is triggered
--let $expected_notifications= 1,QUORUM LOST: %:4|1,STATE %:4
--source ../include/assert_notifications.inc
--echo ### Scenario 9: MAJORITY UNREACHABLE + FORCE MEMBERS
--echo ### Expected:
--echo ### - Correct Servers: 1 VIEW CHANGED
--echo ### - Failed Servers: N/A
--echo ##########################################################
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
# Unblock the group by reconfiguring it forcefully to a
# single server.
--disable_query_log
--eval SET GLOBAL group_replication_force_members= "$local_address_server1"
--enable_query_log
--let $assert_text= group_replication_force_members is correct
--let $assert_cond= @@GLOBAL.group_replication_force_members = "$local_address_server1"
--source include/assert.inc
# verify that the table has now only 1 member
--let $group_replication_number_of_members= 1
--source include/gr_wait_for_number_of_members.inc
--disable_query_log
SET GLOBAL group_replication_force_members= "";
--enable_query_log
# no more unreachable entries in the table
--let $res= `SELECT COUNT(*)=0 FROM performance_schema.replication_group_members WHERE member_state="UNREACHABLE"`
--let $assert_text= No more unreachable servers in the P_S table.
--let $assert_cond= $res = 1
--source include/assert.inc
# assert that notification is triggered
--let $expected_notifications= 1,VIEW %:5
--source ../include/assert_notifications.inc
--source include/stop_group_replication.inc
--echo ### Scenario 10: MAJORITY UNREACHABLE + STOP
--echo ### Expected:
--echo ### - Correct Servers: 1 VIEW CHANGED, 1 STATE CHANGED
--echo ### - Failed Servers: N/A
--echo ##########################################################
# start1: start group
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--disable_query_log
RESET MASTER;
--eval SET @@global.group_replication_group_seeds="$group_seeds_server1"
--eval SET @@global.group_replication_local_address="$local_address_server1"
--eval SET @@global.group_replication_group_name="$group_replication_group_name"
--enable_query_log
--source include/start_and_bootstrap_group_replication.inc
# server2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--disable_query_log
RESET MASTER;
--eval SET @@global.group_replication_group_seeds="$group_seeds_server2"
--eval SET @@global.group_replication_local_address="$local_address_server2"
--eval SET @@global.group_replication_group_name="$group_replication_group_name"
--enable_query_log
--source include/start_group_replication.inc
# server3: Do not start server3. We don't need it to create the quorum loss.
# server2
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--enable_reconnect
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/kill_and_restart_mysqld.inc
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/wait_until_connected_again.inc
--disable_reconnect
# server1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# wait for server2 to become unreachable.
# at this point we have lost quorum
--let $group_replication_member_state= UNREACHABLE
--let $group_replication_member_id= $member2_uuid
--source include/gr_wait_for_member_state.inc
# wait for 4 group change broadcast.
# 1. View_id change(member2 join).
# 2. Recovery state change.
# 3. Unreachable state change.
# 4. Quorum lost.
--let $wait_condition= SELECT COUNT(*)=4 FROM test.gms_listener_example WHERE log_message LIKE 'QUORUM LOST: %:2' OR log_message LIKE 'STATE CHANGED: %:2';
--source include/wait_condition.inc
--disable_query_log
SET SQL_LOG_BIN=0;
TRUNCATE gms_listener_example;
SET SQL_LOG_BIN=1;
--enable_query_log
--source include/stop_group_replication.inc
# assert that notification is triggered
--let $expected_notifications= 1,VIEW %: |1,STATE %:%
--source ../include/assert_notifications.inc
###
### Clean up and bail out
###
# server1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $debug_point= register_gms_listener_example
--source include/remove_debug_point.inc
--disable_query_log
RESET MASTER;
--eval SET @@global.group_replication_group_seeds="$group_seeds_server1"
--eval SET @@global.group_replication_local_address="$local_address_server1"
--eval SET @@global.group_replication_group_name="$group_replication_group_name"
--enable_query_log
--source include/start_and_bootstrap_group_replication.inc
# server2
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--disable_query_log
RESET MASTER;
--eval SET @@global.group_replication_group_seeds="$group_seeds_server2"
--eval SET @@global.group_replication_local_address="$local_address_server2"
--eval SET @@global.group_replication_group_name="$group_replication_group_name"
--enable_query_log
--source include/start_group_replication.inc
# server3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--disable_query_log
RESET MASTER;
--eval SET @@global.group_replication_group_seeds="$group_seeds_server3"
--eval SET @@global.group_replication_local_address="$local_address_server3"
--eval SET @@global.group_replication_group_name="$group_replication_group_name"
--enable_query_log
--source include/start_group_replication.inc
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
DROP TABLE gms_listener_example;
--source include/rpl_sync.inc
--source include/group_replication_end.inc
|