| 1 |
############################################################################### |
| 2 |
# This test validates that when the primary has some load from the old primary |
| 3 |
# to apply, it wont unset the read mode. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. Test requires 3 servers. |
| 7 |
# 1. Configure server 3 recovery user, so it is the only viable donor for |
| 8 |
# server1 on step #4 |
| 9 |
# 2. Lock the table on server 2 and insert data server 1. This will prevent |
| 10 |
# server2 from applying the old data when it is elected as primary. |
| 11 |
# 3. Stop server 1 (primary) and validate thar server 2 is the new primary. |
| 12 |
# 4. Configure server 1 with recovery credentials from server 3 and start group |
| 13 |
# replication. |
| 14 |
# 5. Try to do a transaction on server 2. Since the server is still in read mode, |
| 15 |
# the insert will fail. |
| 16 |
# 6. Clean up. |
| 17 |
# |
| 18 |
############################################################################### |
| 19 |
|
| 20 |
--source include/have_group_replication_xcom_communication_stack.inc |
| 21 |
--source include/have_group_replication_plugin.inc |
| 22 |
--let $rpl_server_count= 3 |
| 23 |
--let $rpl_skip_group_replication_start= 1 |
| 24 |
--let $rpl_group_replication_single_primary_mode=1 |
| 25 |
--source include/group_replication.inc |
| 26 |
|
| 27 |
--let $recovery_user= recovery_user |
| 28 |
--let $recovery_password= recovery_password |
| 29 |
|
| 30 |
--let $rpl_connection_name= server1 |
| 31 |
--source include/rpl_connection.inc |
| 32 |
|
| 33 |
set session sql_log_bin=0; |
| 34 |
call mtr.add_suppression("There was an error when connecting to the donor*"); |
| 35 |
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."); |
| 36 |
set session sql_log_bin=1; |
| 37 |
|
| 38 |
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 39 |
|
| 40 |
--source include/start_and_bootstrap_group_replication.inc |
| 41 |
|
| 42 |
--let $rpl_connection_name= server2 |
| 43 |
--source include/rpl_connection.inc |
| 44 |
|
| 45 |
# next primary should be server2 in step3, so setting member weight as 70 |
| 46 |
# higher then default member_weight value of 50. |
| 47 |
--eval SET GLOBAL group_replication_member_weight= 70 |
| 48 |
--let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 49 |
|
| 50 |
--source include/start_group_replication.inc |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo ############################################################ |
| 54 |
--echo # 1. Configure server 3 recovery user, so it is the only |
| 55 |
--echo # viable donor for server1 on step #4 |
| 56 |
|
| 57 |
--let $rpl_connection_name= server3 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
|
| 60 |
SET SESSION sql_log_bin= 0; |
| 61 |
--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 62 |
--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 63 |
SET SESSION sql_log_bin= 1; |
| 64 |
|
| 65 |
--let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 66 |
|
| 67 |
--source include/start_group_replication.inc |
| 68 |
|
| 69 |
--let $rpl_connection_name= server1 |
| 70 |
--source include/rpl_connection.inc |
| 71 |
|
| 72 |
# Making sure this is the primary server |
| 73 |
--let $group_replication_expected_uuid= $member1_uuid |
| 74 |
--source include/gr_wait_primary_member_uuid.inc |
| 75 |
|
| 76 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY, c2 INT) ENGINE=InnoDB; |
| 77 |
|
| 78 |
--source include/rpl_sync.inc |
| 79 |
|
| 80 |
--echo |
| 81 |
--echo ########################################################### |
| 82 |
--echo # 2. Lock the table on server 2 and insert data server 1. |
| 83 |
--echo # This will prevent server2 from from applying the old data |
| 84 |
--echo # once it is elected as primary. |
| 85 |
|
| 86 |
--let $rpl_connection_name= server_2 |
| 87 |
--source include/rpl_connection.inc |
| 88 |
|
| 89 |
LOCK TABLE t1 READ; |
| 90 |
|
| 91 |
--let $rpl_connection_name= server1 |
| 92 |
--source include/rpl_connection.inc |
| 93 |
|
| 94 |
INSERT INTO t1 VALUES(1,1); |
| 95 |
|
| 96 |
--echo |
| 97 |
--echo ########################################################### |
| 98 |
--echo # 3. Stop server 1 (primary) and validate thar server 2 is |
| 99 |
--echo # the new primary. |
| 100 |
|
| 101 |
--source include/stop_group_replication.inc |
| 102 |
|
| 103 |
--let $rpl_connection_name= server2 |
| 104 |
--source include/rpl_connection.inc |
| 105 |
|
| 106 |
# server1 is stopped, so only server2 and 3 should be in the group |
| 107 |
--let $group_replication_number_of_members= 2 |
| 108 |
--source include/gr_wait_for_number_of_members.inc |
| 109 |
|
| 110 |
# Make sure server2 is the primary now |
| 111 |
--let $assert_text= Verify group_replication_primary_member is SERVER_UUID |
| 112 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "$member2_uuid" |
| 113 |
--source include/assert.inc |
| 114 |
|
| 115 |
|
| 116 |
--echo |
| 117 |
--echo ########################################################### |
| 118 |
--echo # 4. Configure server 1 with recovery credentials from server |
| 119 |
--echo # 3 and start group replication. |
| 120 |
|
| 121 |
|
| 122 |
--let $rpl_connection_name= server1 |
| 123 |
--source include/rpl_connection.inc |
| 124 |
|
| 125 |
--disable_warnings |
| 126 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_USER='$recovery_user', SOURCE_PASSWORD='$recovery_password' FOR CHANNEL 'group_replication_recovery' |
| 127 |
--enable_warnings |
| 128 |
|
| 129 |
--source include/start_group_replication.inc |
| 130 |
|
| 131 |
--echo |
| 132 |
--echo ########################################################### |
| 133 |
--echo # 5. Insert a transaction on server 2. Since the server is |
| 134 |
--echo # still in read mode, it shall fail. |
| 135 |
|
| 136 |
--let $rpl_connection_name= server2 |
| 137 |
--source include/rpl_connection.inc |
| 138 |
|
| 139 |
--error 1290 |
| 140 |
INSERT INTO t1 VALUES(1,2); |
| 141 |
|
| 142 |
--let $rpl_connection_name= server_2 |
| 143 |
--source include/rpl_connection.inc |
| 144 |
|
| 145 |
UNLOCK TABLES; |
| 146 |
|
| 147 |
#Waiting for the data to be applied |
| 148 |
--let $wait_condition= SELECT COUNT(*)=1 FROM t1 |
| 149 |
--source include/wait_condition.inc |
| 150 |
|
| 151 |
--let $negatively_certified= query_get_value(SELECT Count_conflicts_detected FROM performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid), Count_conflicts_detected, 1) |
| 152 |
--let $assert_text= 'The value of Count_conflicts_detected should be 0 on server 2' |
| 153 |
--let $assert_cond= $negatively_certified = 0 |
| 154 |
--source include/assert.inc |
| 155 |
|
| 156 |
#Now table is unlocked, wait for member to reset read_only |
| 157 |
--let $wait_condition= SELECT @@GLOBAL.read_only = '0' |
| 158 |
--source include/wait_condition_or_abort.inc |
| 159 |
|
| 160 |
--echo |
| 161 |
--echo ########################################################### |
| 162 |
--echo # 6. Clean up. |
| 163 |
|
| 164 |
--let $rpl_connection_name= server3 |
| 165 |
--source include/rpl_connection.inc |
| 166 |
|
| 167 |
SET SESSION sql_log_bin= 0; |
| 168 |
SET GLOBAL read_only= 0; |
| 169 |
--eval DROP USER $recovery_user |
| 170 |
SET GLOBAL super_read_only= 1; |
| 171 |
SET SESSION sql_log_bin= 1; |
| 172 |
|
| 173 |
--let $rpl_connection_name= server2 |
| 174 |
--source include/rpl_connection.inc |
| 175 |
|
| 176 |
DROP TABLE t1; |
| 177 |
|
| 178 |
SET GLOBAL group_replication_member_weight= DEFAULT; |
| 179 |
|
| 180 |
--source include/group_replication_end.inc |
| 181 |
|