| 1 |
################################################################################ |
| 2 |
# This test evaluates that whenever the donor has purged GTIDs that causes |
| 3 |
# errors in the joiner, a failover to another donor will happen. |
| 4 |
# |
| 5 |
# The test steps are: |
| 6 |
# 0) The test requires three servers. |
| 7 |
# 1) Bootstrap start group on server1. Add some data. Start GR on server2. |
| 8 |
# 2) Purge some GTIDs on server1 by flushing and purging binary log. |
| 9 |
# Create a replication user for recovery. |
| 10 |
# 3) Start server3 with the configured replication user and watch it fail as |
| 11 |
# 1. Server1 has purged GTIDs |
| 12 |
# 2. Server2 does not has the correct replication user |
| 13 |
# 4) Create the recovery user on server2. |
| 14 |
# The joiner (server3) should now connect to server2 when failing over. |
| 15 |
# 5) The joiner (server3) should become online. Validate data. |
| 16 |
# 6) Clean up. |
| 17 |
################################################################################ |
| 18 |
--source include/big_test.inc |
| 19 |
--source include/have_group_replication_plugin.inc |
| 20 |
--let $rpl_skip_group_replication_start= 1 |
| 21 |
--let $rpl_server_count= 3 |
| 22 |
--source include/group_replication.inc |
| 23 |
|
| 24 |
--let $recovery_user= recovery_user |
| 25 |
--let $recovery_password= recovery_password |
| 26 |
|
| 27 |
--echo # |
| 28 |
--echo # Setup a new 2 member group |
| 29 |
--echo # |
| 30 |
|
| 31 |
--connection server1 |
| 32 |
--source include/start_and_bootstrap_group_replication.inc |
| 33 |
|
| 34 |
#insert some data |
| 35 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 36 |
INSERT INTO t1 VALUES (1); |
| 37 |
|
| 38 |
--connection server2 |
| 39 |
|
| 40 |
SET SESSION sql_log_bin= 0; |
| 41 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 42 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 43 |
FLUSH PRIVILEGES; |
| 44 |
SET SESSION sql_log_bin= 1; |
| 45 |
|
| 46 |
--source include/start_group_replication.inc |
| 47 |
|
| 48 |
--echo # |
| 49 |
--echo # Purge member 1 binlog after a flush and create a replication user |
| 50 |
--echo # |
| 51 |
|
| 52 |
--connection server1 |
| 53 |
|
| 54 |
--let $server_binlog_file_prev= query_get_value(SHOW MASTER STATUS, File, 1) |
| 55 |
FLUSH BINARY LOGS; |
| 56 |
--let $server_binlog_file_cur= query_get_value(SHOW MASTER STATUS, File, 1) |
| 57 |
|
| 58 |
# |
| 59 |
# At this point the dump thread spawned to attend the |
| 60 |
# recovery procedure for server2 must have stopped or |
| 61 |
# is about to. We make sure that it is so we can purge |
| 62 |
# the binary log successfully - note that |
| 63 |
# start_group_replication.inc waits for the member to |
| 64 |
# be ONLINE. |
| 65 |
# |
| 66 |
# Otherwise the test could fail since the purge |
| 67 |
# command might not be able to remove the file because, |
| 68 |
# the lingering dump thread could still clinging on |
| 69 |
# to it. |
| 70 |
# |
| 71 |
--source include/stop_dump_threads.inc |
| 72 |
|
| 73 |
# |
| 74 |
# And just to make sure that the file is indeed not |
| 75 |
# being used. |
| 76 |
# |
| 77 |
--let $wait_file_name=$server_binlog_file_prev |
| 78 |
--source include/wait_for_file_closed.inc |
| 79 |
|
| 80 |
--disable_query_log |
| 81 |
--eval PURGE BINARY LOGS TO '$server_binlog_file_cur' |
| 82 |
--enable_query_log |
| 83 |
|
| 84 |
SET SESSION sql_log_bin= 0; |
| 85 |
CALL mtr.add_suppression("Cannot replicate to server with server_uuid*"); |
| 86 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 87 |
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 88 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 89 |
FLUSH PRIVILEGES; |
| 90 |
SET SESSION sql_log_bin= 1; |
| 91 |
|
| 92 |
--echo # |
| 93 |
--echo # Start recovery and watch it fail for a bit as: |
| 94 |
--echo # 1) Server 1 has purged GTIDs |
| 95 |
--echo # 2) Server 2 does not has the correct replication user |
| 96 |
--echo # |
| 97 |
|
| 98 |
--connection server3 |
| 99 |
|
| 100 |
SET SESSION sql_log_bin= 0; |
| 101 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 102 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 103 |
FLUSH PRIVILEGES; |
| 104 |
|
| 105 |
call mtr.add_suppression("There was an error when connecting to the donor*"); |
| 106 |
call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Replica I/O for channel group_replication_recovery."); |
| 107 |
call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Got fatal error 1236*"); |
| 108 |
call mtr.add_suppression("Error while starting the group replication incremental recovery receiver/applier threads"); |
| 109 |
call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Source command COM_REGISTER_REPLICA failed: Access denied for user 'recovery_user'.*"); |
| 110 |
call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Source command COM_REGISTER_REPLICA failed: failed registering on source, reconnecting to try again.*"); |
| 111 |
call mtr.add_suppression("Replica I/O thread couldn't register on source"); |
| 112 |
call mtr.add_suppression("Error while creating the group replication recovery channel with donor.*"); |
| 113 |
call mtr.add_suppression("Error when configuring the asynchronous recovery channel connection to the donor.*"); |
| 114 |
SET SESSION sql_log_bin= 1; |
| 115 |
|
| 116 |
--disable_warnings |
| 117 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER= '$recovery_user', SOURCE_PASSWORD= '$recovery_password' FOR CHANNEL 'group_replication_recovery' |
| 118 |
--enable_warnings |
| 119 |
|
| 120 |
SET @debug_save_rec_int= @@GLOBAL.group_replication_recovery_reconnect_interval; |
| 121 |
|
| 122 |
--eval SET GLOBAL group_replication_recovery_reconnect_interval= 1 # seconds |
| 123 |
|
| 124 |
--disable_query_log |
| 125 |
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"; |
| 126 |
--enable_query_log |
| 127 |
--source include/start_group_replication_command.inc |
| 128 |
|
| 129 |
#give it time to fail several times |
| 130 |
--sleep 5 |
| 131 |
|
| 132 |
--let $group_replication_member_state= RECOVERING |
| 133 |
--source include/gr_wait_for_member_state.inc |
| 134 |
|
| 135 |
--echo # |
| 136 |
--echo # Create the recovery user on server 2 |
| 137 |
--echo # The joiner should now be able to connect to server 2 when failing over. |
| 138 |
--echo # |
| 139 |
|
| 140 |
--connection server2 |
| 141 |
SET SESSION sql_log_bin= 0; |
| 142 |
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 143 |
FLUSH PRIVILEGES; |
| 144 |
SET SESSION sql_log_bin= 1; |
| 145 |
|
| 146 |
--connection server3 |
| 147 |
|
| 148 |
--let $group_replication_member_state= ONLINE |
| 149 |
--source include/gr_wait_for_member_state.inc |
| 150 |
|
| 151 |
--let $assert_text= On the recovered member, the table should exist and have 1 elements |
| 152 |
--let $assert_cond= [SELECT COUNT(*) FROM t1] = 1; |
| 153 |
--source include/assert.inc |
| 154 |
|
| 155 |
--echo # |
| 156 |
--echo # Cleaning up |
| 157 |
--echo # |
| 158 |
|
| 159 |
SET @@GLOBAL.group_replication_recovery_reconnect_interval= @debug_save_rec_int; |
| 160 |
|
| 161 |
DROP TABLE t1; |
| 162 |
|
| 163 |
SET SESSION sql_log_bin= 0; |
| 164 |
--eval DROP USER "$recovery_user" |
| 165 |
SET SESSION sql_log_bin= 1; |
| 166 |
|
| 167 |
--connection server2 |
| 168 |
|
| 169 |
SET SESSION sql_log_bin= 0; |
| 170 |
--eval DROP USER "$recovery_user" |
| 171 |
SET SESSION sql_log_bin= 1; |
| 172 |
|
| 173 |
--connection server1 |
| 174 |
|
| 175 |
SET SESSION sql_log_bin= 0; |
| 176 |
--eval DROP USER "$recovery_user" |
| 177 |
SET SESSION sql_log_bin= 1; |
| 178 |
|
| 179 |
--source include/group_replication_end.inc |