| 1 |
################################################################################ |
| 2 |
# This test evaluates that whenever the donor has conflicting data 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: M1, M2 and M3. |
| 7 |
# 1) Bootstrap start M1 with no replication user for recovery. Insert some |
| 8 |
# data. |
| 9 |
# 2) Insert some extra data on M2 before starting. Create a replication user |
| 10 |
# recovery. |
| 11 |
# 3) Add conflicting data on M3 and start it with the configured replication |
| 12 |
# user and watch it fail as: |
| 13 |
# 1. M1 does not has the correct replication user. |
| 14 |
# 2. M2 has conflicting data. |
| 15 |
# 4) Create the recovery user on M1. The joiner M3 should now connect to M1 |
| 16 |
# when failing over. |
| 17 |
# 5) The joiner M3 should become ONLINE. Validate data on M3. |
| 18 |
# 6) Clean up. |
| 19 |
################################################################################ |
| 20 |
|
| 21 |
--source include/big_test.inc |
| 22 |
--let $group_replication_group_name=65b51c20-262d-11e5-867f-0800200c9a66 |
| 23 |
--source include/have_group_replication_plugin.inc |
| 24 |
--let $rpl_skip_group_replication_start= 1 |
| 25 |
--let $rpl_server_count= 3 |
| 26 |
--source include/group_replication.inc |
| 27 |
|
| 28 |
--let $recovery_user= recovery_user |
| 29 |
--let $recovery_password= recovery_password |
| 30 |
--let $fake_transaction_uuid= aaaaaaaa-bbbb-aaaa-bbbb-aaaaaaaaaaaa |
| 31 |
|
| 32 |
--echo # |
| 33 |
--echo # Start a new member with some group data but no replication user |
| 34 |
--echo # |
| 35 |
|
| 36 |
--connection server1 |
| 37 |
--source include/start_and_bootstrap_group_replication.inc |
| 38 |
|
| 39 |
#insert some data |
| 40 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 41 |
INSERT INTO t1 VALUES (1); |
| 42 |
|
| 43 |
# Log fake transactions to allow server2 to join the group with |
| 44 |
# extra data. |
| 45 |
--eval SET GTID_NEXT= "$fake_transaction_uuid:1" |
| 46 |
BEGIN; |
| 47 |
COMMIT; |
| 48 |
SET GTID_NEXT= "AUTOMATIC"; |
| 49 |
--eval SET GTID_NEXT= "$fake_transaction_uuid:2" |
| 50 |
BEGIN; |
| 51 |
COMMIT; |
| 52 |
SET GTID_NEXT= "AUTOMATIC"; |
| 53 |
|
| 54 |
--echo # |
| 55 |
--echo # Add some extra data on server 2 and then start group replication |
| 56 |
--echo # Create a replication user so recovery can connect |
| 57 |
--echo # |
| 58 |
|
| 59 |
--connection server2 |
| 60 |
|
| 61 |
--eval SET GTID_NEXT= "$fake_transaction_uuid:1" |
| 62 |
CREATE TABLE lost_test_table (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 63 |
SET GTID_NEXT= "AUTOMATIC"; |
| 64 |
--eval SET GTID_NEXT= "$fake_transaction_uuid:2" |
| 65 |
INSERT INTO lost_test_table VALUES (1); |
| 66 |
SET GTID_NEXT= "AUTOMATIC"; |
| 67 |
|
| 68 |
SET SESSION sql_log_bin= 0; |
| 69 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 70 |
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 71 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 72 |
FLUSH PRIVILEGES; |
| 73 |
SET SESSION sql_log_bin= 1; |
| 74 |
|
| 75 |
--source include/start_group_replication.inc |
| 76 |
|
| 77 |
--echo # |
| 78 |
--echo # Start recovery on member 3 and watch it fail for a bit as: |
| 79 |
--echo # 1) Server 1 does not has the correct replication user |
| 80 |
--echo # 2) Server 2 has conflicting data |
| 81 |
--echo # |
| 82 |
|
| 83 |
--connection server3 |
| 84 |
|
| 85 |
SET SESSION sql_log_bin= 0; |
| 86 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 87 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 88 |
FLUSH PRIVILEGES; |
| 89 |
SET SESSION sql_log_bin= 1; |
| 90 |
|
| 91 |
SET SESSION sql_log_bin= 0; |
| 92 |
call mtr.add_suppression("There was an error when connecting to the donor*"); |
| 93 |
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."); |
| 94 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_recovery': Error 'Table 'lost_test_table'*"); |
| 95 |
call mtr.add_suppression("Replica: Table 'lost_test_table' already exists Error_code:*"); |
| 96 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_recovery': Worker .* failed executing transaction .*; Error 'Table 'lost_test_table' already exists' on query."); |
| 97 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_recovery': ... The replica coordinator and worker threads are stopped.*"); |
| 98 |
call mtr.add_suppression("Error while starting the group replication incremental recovery receiver/applier threads"); |
| 99 |
call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Source command COM_REGISTER_REPLICA failed: Access denied for user 'recovery_user'.*"); |
| 100 |
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.*"); |
| 101 |
call mtr.add_suppression("Replica I/O thread couldn't register on source"); |
| 102 |
call mtr.add_suppression(".*This member has more executed transactions *.*"); |
| 103 |
call mtr.add_suppression("The member contains transactions not present in the group. It is only allowed to *.*"); |
| 104 |
SET SESSION sql_log_bin= 1; |
| 105 |
|
| 106 |
SET @debug_save_rec_int= @@GLOBAL.group_replication_recovery_reconnect_interval; |
| 107 |
|
| 108 |
--disable_warnings |
| 109 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='$recovery_user', SOURCE_PASSWORD='$recovery_password' FOR CHANNEL 'group_replication_recovery' |
| 110 |
--enable_warnings |
| 111 |
|
| 112 |
SET GLOBAL group_replication_recovery_reconnect_interval= 1; # 1 second |
| 113 |
|
| 114 |
SET SESSION sql_log_bin= 0; |
| 115 |
CREATE TABLE lost_test_table (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 116 |
INSERT INTO lost_test_table VALUES (1); |
| 117 |
SET SESSION sql_log_bin= 1; |
| 118 |
|
| 119 |
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" |
| 120 |
--source include/start_group_replication_command.inc |
| 121 |
|
| 122 |
#give it time to fail several times |
| 123 |
--sleep 5 |
| 124 |
|
| 125 |
--let $group_replication_member_state= RECOVERING |
| 126 |
--source include/gr_wait_for_member_state.inc |
| 127 |
|
| 128 |
--echo # |
| 129 |
--echo # Create the recovery user on server 1 |
| 130 |
--echo # The joiner should now connect to server 1 when failing over. |
| 131 |
--echo # |
| 132 |
|
| 133 |
--connection server1 |
| 134 |
SET SESSION sql_log_bin= 0; |
| 135 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 136 |
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 137 |
--eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%'; |
| 138 |
FLUSH PRIVILEGES; |
| 139 |
SET SESSION sql_log_bin= 1; |
| 140 |
|
| 141 |
--connection server3 |
| 142 |
|
| 143 |
--let $group_replication_member_state= ONLINE |
| 144 |
--source include/gr_wait_for_member_state.inc |
| 145 |
|
| 146 |
--let $assert_text= On the recovered member, the table should exist and have 1 elements |
| 147 |
--let $assert_cond= [select count(*) from t1] = 1; |
| 148 |
--source include/assert.inc |
| 149 |
|
| 150 |
--echo # |
| 151 |
--echo # Cleaning up |
| 152 |
--echo # We use RESET MASTER here due to deviations on all members GTID sets |
| 153 |
--echo # |
| 154 |
|
| 155 |
SET @@GLOBAL.group_replication_recovery_reconnect_interval= @debug_save_rec_int; |
| 156 |
|
| 157 |
DROP TABLE t1; |
| 158 |
|
| 159 |
--source include/stop_group_replication.inc |
| 160 |
|
| 161 |
DROP TABLE lost_test_table; |
| 162 |
|
| 163 |
RESET MASTER; |
| 164 |
|
| 165 |
SET SESSION sql_log_bin= 0; |
| 166 |
--eval DROP USER "$recovery_user" |
| 167 |
SET SESSION sql_log_bin= 1; |
| 168 |
|
| 169 |
--connection server2 |
| 170 |
|
| 171 |
--source include/stop_group_replication.inc |
| 172 |
|
| 173 |
SET SESSION sql_log_bin= 0; |
| 174 |
--eval DROP USER "$recovery_user" |
| 175 |
SET SESSION sql_log_bin= 1; |
| 176 |
|
| 177 |
DROP TABLE lost_test_table; |
| 178 |
|
| 179 |
RESET MASTER; |
| 180 |
|
| 181 |
--connection server1 |
| 182 |
|
| 183 |
--source include/stop_group_replication.inc |
| 184 |
|
| 185 |
SET SESSION sql_log_bin= 0; |
| 186 |
--eval DROP USER "$recovery_user" |
| 187 |
SET SESSION sql_log_bin= 1; |
| 188 |
|
| 189 |
RESET MASTER; |
| 190 |
|
| 191 |
--source include/group_replication_end.inc |