| 1 |
################################################################################ |
| 2 |
# WL#9426: Single PRIMARY Mode in Group Replication |
| 3 |
# |
| 4 |
# This test checks the status variable group_replication_primary_member with |
| 5 |
# different member_states when group_replication_single_primary_mode is OFF. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. The test requires two servers: M1 and M2. |
| 9 |
# 1. Test that group_replication_primary_member shows EMPTY in all the following |
| 10 |
# cases: |
| 11 |
# a) server1 is in ONLINE state. |
| 12 |
# b) server2 is in OFFLINE state. |
| 13 |
# c) server2 is in RECOVERING state. |
| 14 |
# d) server2 is in ERROR state. |
| 15 |
# e) server2 is in ONLINE state. |
| 16 |
# 2. Clean up. |
| 17 |
################################################################################ |
| 18 |
|
| 19 |
--source include/big_test.inc |
| 20 |
--source include/have_debug_sync.inc |
| 21 |
--source include/have_group_replication_plugin.inc |
| 22 |
--let $rpl_skip_group_replication_start= 1 |
| 23 |
--let $rpl_group_replication_single_primary_mode=0 |
| 24 |
--source include/group_replication.inc |
| 25 |
|
| 26 |
--echo # |
| 27 |
--echo # a) Server1 is in ONLINE state. Expect group_replication_primary_member EMPTY. |
| 28 |
--echo # |
| 29 |
--let $rpl_connection_name= server1 |
| 30 |
--source include/rpl_connection.inc |
| 31 |
--source include/start_and_bootstrap_group_replication.inc |
| 32 |
--let $server1_uuid= `SELECT @@server_uuid` |
| 33 |
|
| 34 |
--let $group_replication_member_state= ONLINE |
| 35 |
--source include/gr_wait_for_member_state.inc |
| 36 |
|
| 37 |
--let $assert_text= Verify MEMBER_STATE is ONLINE |
| 38 |
--let $assert_cond= "[SELECT MEMBER_STATE FROM performance_schema.replication_group_members WHERE MEMBER_ID=\'$server1_uuid\', MEMBER_STATE, 1]" = "ONLINE" |
| 39 |
--source include/assert.inc |
| 40 |
|
| 41 |
--let $assert_text= Verify group_replication_primary_member is EMPTY("") |
| 42 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "" |
| 43 |
--source include/assert.inc |
| 44 |
|
| 45 |
--echo # |
| 46 |
--echo # b) Server2 is in OFFLINE state. Expect group_replication_primary_member EMPTY. |
| 47 |
--echo # |
| 48 |
--let $rpl_connection_name= server2 |
| 49 |
--source include/rpl_connection.inc |
| 50 |
--let $server2_uuid= `SELECT @@server_uuid` |
| 51 |
|
| 52 |
SET SESSION sql_log_bin= 0; |
| 53 |
call mtr.add_suppression("Table 't1' already exists"); |
| 54 |
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group"); |
| 55 |
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group."); |
| 56 |
call mtr.add_suppression("Unable to ensure the execution of group transactions received during recovery."); |
| 57 |
call mtr.add_suppression("Fatal error during the Recovery process of Group Replication. The server will leave the group."); |
| 58 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 59 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 60 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped,*"); |
| 61 |
SET SESSION sql_log_bin= 1; |
| 62 |
|
| 63 |
--let $assert_text= Verify MEMBER_STATE is OFFLINE |
| 64 |
--let $assert_cond= "[SELECT MEMBER_STATE FROM performance_schema.replication_group_members, MEMBER_STATE, 1]" = "OFFLINE" |
| 65 |
--source include/assert.inc |
| 66 |
|
| 67 |
--let $assert_text= Verify group_replication_primary_member is EMPTY("") |
| 68 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "" |
| 69 |
--source include/assert.inc |
| 70 |
|
| 71 |
--echo # |
| 72 |
--echo # c) Server2 is in RECOVERING state. Expect group_replication_primary_member EMPTY. |
| 73 |
--echo # |
| 74 |
|
| 75 |
# For later use in 'd)' to send server2 to ERROR state. |
| 76 |
SET sql_log_bin=0; |
| 77 |
CREATE TABLE t1 (a INT PRIMARY KEY NOT NULL); |
| 78 |
SET sql_log_bin=1; |
| 79 |
|
| 80 |
SET @@GLOBAL.DEBUG='+d,recovery_thread_wait_before_finish'; |
| 81 |
|
| 82 |
--let $group_replication_start_member_state= RECOVERING |
| 83 |
--source include/start_group_replication.inc |
| 84 |
|
| 85 |
--let $assert_text= Verify MEMBER_STATE is RECOVERING |
| 86 |
--let $assert_cond= "[SELECT MEMBER_STATE FROM performance_schema.replication_group_members WHERE MEMBER_ID=\'$server2_uuid\', MEMBER_STATE, 1]" = "RECOVERING" |
| 87 |
--source include/assert.inc |
| 88 |
|
| 89 |
--let $assert_text= Verify group_replication_primary_member is EMPTY("") |
| 90 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "" |
| 91 |
--source include/assert.inc |
| 92 |
|
| 93 |
--echo # |
| 94 |
--echo # d) Server2 is in ERROR state. Expect group_replication_primary_member EMPTY. |
| 95 |
--echo # |
| 96 |
--let $rpl_connection_name= server2 |
| 97 |
--source include/rpl_connection.inc |
| 98 |
SET DEBUG_SYNC= "now WAIT_FOR signal.recovery_thread_wait_before_finish_reached"; |
| 99 |
SET @@GLOBAL.DEBUG='-d,recovery_thread_wait_before_finish'; |
| 100 |
SET DEBUG_SYNC= "now SIGNAL signal.recovery_end"; |
| 101 |
|
| 102 |
--let $group_replication_member_state= ONLINE |
| 103 |
--source include/gr_wait_for_member_state.inc |
| 104 |
|
| 105 |
SET DEBUG_SYNC= 'RESET'; |
| 106 |
|
| 107 |
--let $rpl_connection_name= server1 |
| 108 |
--source include/rpl_connection.inc |
| 109 |
CREATE TABLE t1 (a INT PRIMARY KEY NOT NULL); |
| 110 |
|
| 111 |
--let $rpl_connection_name= server2 |
| 112 |
--source include/rpl_connection.inc |
| 113 |
|
| 114 |
--let $group_replication_member_state= ERROR |
| 115 |
--source include/gr_wait_for_member_state.inc |
| 116 |
|
| 117 |
# To ensure that member is not in transition state and shows only itself. |
| 118 |
--let $group_replication_number_of_members= 1 |
| 119 |
--source include/gr_wait_for_number_of_members.inc |
| 120 |
|
| 121 |
--let $assert_text= Verify MEMBER_STATE is ERROR |
| 122 |
--let $assert_cond= "[SELECT MEMBER_STATE FROM performance_schema.replication_group_members WHERE MEMBER_ID=\'$server2_uuid\', MEMBER_STATE, 1]" = "ERROR" |
| 123 |
--source include/assert.inc |
| 124 |
|
| 125 |
--let $assert_text= Verify group_replication_primary_member is EMPTY("") |
| 126 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "" |
| 127 |
--source include/assert.inc |
| 128 |
|
| 129 |
--echo # |
| 130 |
--echo # e) Server2 is in ONLINE state. Expect group_replication_primary_member EMPTY. |
| 131 |
--echo # |
| 132 |
--source include/stop_group_replication.inc |
| 133 |
SET sql_log_bin=0; |
| 134 |
DROP TABLE t1; |
| 135 |
SET sql_log_bin=1; |
| 136 |
--source include/start_group_replication.inc |
| 137 |
|
| 138 |
--let $group_replication_member_state= ONLINE |
| 139 |
--source include/gr_wait_for_member_state.inc |
| 140 |
|
| 141 |
--let $assert_text= Verify MEMBER_STATE is ONLINE |
| 142 |
--let $assert_cond= "[SELECT MEMBER_STATE FROM performance_schema.replication_group_members WHERE MEMBER_ID=\'$server2_uuid\', MEMBER_STATE, 1]" = "ONLINE" |
| 143 |
--source include/assert.inc |
| 144 |
|
| 145 |
--let $assert_text= Verify group_replication_primary_member is EMPTY("") |
| 146 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "" |
| 147 |
--source include/assert.inc |
| 148 |
|
| 149 |
# Clean up |
| 150 |
--let $rpl_connection_name= server1 |
| 151 |
--source include/rpl_connection.inc |
| 152 |
DROP TABLE t1; |
| 153 |
--source include/group_replication_end.inc |