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