| 1 |
################################################################################ |
| 2 |
# Group Replication: cross-version policies |
| 3 |
# This test-case makes sure while using UDFs, change primary consider patch |
| 4 |
# version while selecting new primary. |
| 5 |
# 1. Only lowest server version becomes primary else error is thrown |
| 6 |
# 2. Among lowest member versions member weight is considered |
| 7 |
# 3. Among lowest member version and same weight lower server_uuid is choosen |
| 8 |
# Post multi-primary switch, only lowest member versions are writable. |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0. The test requires three servers: M1, M2, M3 |
| 12 |
# 1. Bootstrap M1. |
| 13 |
# Start GR on M2 with higher weight and patch version. |
| 14 |
# 2. Set M2 as primary, it fails due to higher patch version. |
| 15 |
# 3. Switch to single-primary mode. |
| 16 |
# M1 becomes primary due to lower version rule. |
| 17 |
# 4. Switch to multi-primary mode and start GR on M3. |
| 18 |
# 5. Switch to single primary mode holding elections. |
| 19 |
# M2 is not considered due to higher patch version, |
| 20 |
# even though it has higher member weight. |
| 21 |
# M1 and M3 has same version and weight, |
| 22 |
# lower server_uuid become primary. |
| 23 |
# Assert configurations are correct. |
| 24 |
# 6. Change primary, UDF fails if new primary has higher version. |
| 25 |
# Assert configurations are not changed. |
| 26 |
# 7. Switch to multi-primary mode. |
| 27 |
# Assert configurations are correct. |
| 28 |
# 8. Change primary to M3. |
| 29 |
# Assert configurations are correct. |
| 30 |
# 9. Change primary, UDF succedds if new primary has lowest version. |
| 31 |
# Assert configurations are correct. |
| 32 |
# 10. Make M3 weight higher and switch to SPM mode. M3 becomes primary. |
| 33 |
# Member weight is considered among lowest equal versions. |
| 34 |
# Assert configurations are correct. |
| 35 |
# 11. Cleanup. |
| 36 |
################################################################################ |
| 37 |
|
| 38 |
--source include/big_test.inc |
| 39 |
--source include/have_debug.inc |
| 40 |
--source include/have_group_replication_plugin.inc |
| 41 |
--let $rpl_skip_group_replication_start= 1 |
| 42 |
--let $rpl_server_count= 3 |
| 43 |
--source include/group_replication.inc |
| 44 |
|
| 45 |
--echo |
| 46 |
--echo # 1. Bootstrap M1. |
| 47 |
--echo # Start GR on M2 with higher weight and patch version. |
| 48 |
--echo |
| 49 |
--let $rpl_connection_name= server1 |
| 50 |
--source include/rpl_connection.inc |
| 51 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 52 |
SET SESSION sql_log_bin=0; |
| 53 |
call mtr.add_suppression("Error while executing a group configuration operation: Error processing configuration start message: The appointed primary member has a version that is greater than the one of some of the members in the group."); |
| 54 |
SET SESSION sql_log_bin=1; |
| 55 |
--source include/start_and_bootstrap_group_replication.inc |
| 56 |
|
| 57 |
--let $rpl_connection_name= server2 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 60 |
|
| 61 |
SET @member_weight2_save= @@GLOBAL.group_replication_member_weight; |
| 62 |
--eval SET GLOBAL group_replication_member_weight= 90 |
| 63 |
SET @debug2_save= @@GLOBAL.DEBUG; |
| 64 |
SET @@GLOBAL.DEBUG= 'd,group_replication_compatibility_higher_patch_version'; |
| 65 |
SET SESSION sql_log_bin=0; |
| 66 |
call mtr.add_suppression("Member version is read compatible with the group."); |
| 67 |
call mtr.add_suppression("Error while executing a group configuration operation: Error processing configuration start message: The appointed primary member has a version that is greater than the one of some of the members in the group."); |
| 68 |
call mtr.add_suppression("The function 'group_replication_switch_to_single_primary_mode' failed. Error processing configuration start message: The appointed primary member has a version that is greater than the one of some of the members in the group."); |
| 69 |
SET SESSION sql_log_bin=1; |
| 70 |
--source include/start_group_replication.inc |
| 71 |
|
| 72 |
|
| 73 |
--echo |
| 74 |
--echo # 2. Set M2 as primary, it fails due to higher patch version. |
| 75 |
--echo |
| 76 |
|
| 77 |
## STATUS - ASSUMING 8.0.17 is original version |
| 78 |
# Server - State - Version - Weight - R/W/P/S |
| 79 |
# M1 - ON - 8.0.17 - 50 - W |
| 80 |
# M2 - ON - 8.0.18 - 90 - R |
| 81 |
# M3 - OFF - 8.0.17 - 50 - R |
| 82 |
|
| 83 |
--replace_result $server2_uuid MEMBER_UUID |
| 84 |
--error ER_GRP_RPL_UDF_ERROR |
| 85 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server2_uuid"); |
| 86 |
|
| 87 |
--source include/gr_assert_mpm_consistency.inc |
| 88 |
|
| 89 |
|
| 90 |
--echo |
| 91 |
--echo # 3. Switch to single-primary mode. |
| 92 |
--echo # M1 becomes primary due to lower version rule. |
| 93 |
--echo |
| 94 |
|
| 95 |
# Server - State - Version - Weight - R/W/P/S |
| 96 |
# M1 - ON - 8.0.17 - 50 - W |
| 97 |
# M2 - ON - 8.0.18 - 90 - R |
| 98 |
# M3 - OFF - 8.0.17 - 50 - R |
| 99 |
|
| 100 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 101 |
--let $_primary_member_of_group= $server1_uuid |
| 102 |
--source include/gr_assert_spm_consistency.inc |
| 103 |
|
| 104 |
|
| 105 |
--echo |
| 106 |
--echo # 4. Switch to multi-primary mode and start GR on M3. |
| 107 |
--echo |
| 108 |
|
| 109 |
# Mode: Single-primary |
| 110 |
# Server - State - Version - Weight - R/W/P/S |
| 111 |
# M1 - ON - 8.0.17 - 50 - P |
| 112 |
# M2 - ON - 8.0.18 - 90 - S |
| 113 |
# M3 - OFF - 8.0.17 - 50 - S |
| 114 |
|
| 115 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 116 |
|
| 117 |
--let $rpl_connection_name= server3 |
| 118 |
--source include/rpl_connection.inc |
| 119 |
SET @member_weight3_save= @@GLOBAL.group_replication_member_weight; |
| 120 |
--let $server3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 121 |
|
| 122 |
# Later group will switch to single-primary mode and M3 will become read-only. |
| 123 |
# So add suppression now. |
| 124 |
SET SESSION sql_log_bin=0; |
| 125 |
call mtr.add_suppression("The function 'group_replication_set_as_primary' failed. Error processing configuration start message: The appointed primary member has a version that is greater than the one of some of the members in the group."); |
| 126 |
SET SESSION sql_log_bin=1; |
| 127 |
|
| 128 |
--source include/start_group_replication.inc |
| 129 |
--source include/gr_assert_mpm_consistency.inc |
| 130 |
|
| 131 |
--echo |
| 132 |
--echo # 5. Switch to single primary mode holding elections. |
| 133 |
--echo # M2 is not considered due to higher patch version, |
| 134 |
--echo # even though it has higher member weight. |
| 135 |
--echo # M1 and M3 has same version and weight, |
| 136 |
--echo # lower server_uuid become primary. |
| 137 |
--echo # Assert configurations are correct. |
| 138 |
--echo |
| 139 |
|
| 140 |
# Server - State - Version - Weight - R/W/P/S |
| 141 |
# M1 - ON - 8.0.17 - 50 - W |
| 142 |
# M2 - ON - 8.0.18 - 90 - R |
| 143 |
# M3 - ON - 8.0.17 - 50 - W |
| 144 |
|
| 145 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 146 |
--let $_next_primary_uuid= query_get_value("SELECT Member_id FROM performance_schema.replication_group_members WHERE Member_id <> '$server2_uuid' ORDER BY Member_id ASC LIMIT 1", Member_id, 1) |
| 147 |
|
| 148 |
--let $_primary_member_of_group= $_next_primary_uuid |
| 149 |
--source include/gr_assert_spm_consistency.inc |
| 150 |
|
| 151 |
|
| 152 |
--echo |
| 153 |
--echo # 6. Change primary, UDF fails if new primary has higher version. |
| 154 |
--echo # Assert configurations are not changed. |
| 155 |
--echo |
| 156 |
|
| 157 |
# Server - State - Version - Weight - R/W/P/S |
| 158 |
# M1 - ON - 8.0.17 - 50 - P/S (CANDIDATE) |
| 159 |
# M2 - ON - 8.0.18 - 90 - S |
| 160 |
# M3 - ON - 8.0.17 - 50 - P/S (CANDIDATE) |
| 161 |
|
| 162 |
--replace_result $server2_uuid MEMBER_UUID |
| 163 |
--error ER_GRP_RPL_UDF_ERROR |
| 164 |
--eval SELECT group_replication_set_as_primary("$server2_uuid"); |
| 165 |
|
| 166 |
--let $_primary_member_of_group= $_next_primary_uuid |
| 167 |
--source include/gr_assert_spm_consistency.inc |
| 168 |
|
| 169 |
|
| 170 |
--echo |
| 171 |
--echo # 7. Switch to multi-primary mode. |
| 172 |
--echo # Assert configurations are correct. |
| 173 |
--echo |
| 174 |
|
| 175 |
# Server - State - Version - Weight - R/W/P/S |
| 176 |
# M1 - ON - 8.0.17 - 50 - P/S (CANDIDATE) |
| 177 |
# M2 - ON - 8.0.18 - 90 - S |
| 178 |
# M3 - ON - 8.0.17 - 50 - P/S (CANDIDATE) |
| 179 |
|
| 180 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 181 |
|
| 182 |
--source include/gr_assert_mpm_consistency.inc |
| 183 |
|
| 184 |
|
| 185 |
--echo |
| 186 |
--echo # 8. Change primary to M3. |
| 187 |
--echo # Assert configurations are correct. |
| 188 |
--echo |
| 189 |
|
| 190 |
# Server - State - Version - Weight - R/W/P/S |
| 191 |
# M1 - ON - 8.0.17 - 50 - W |
| 192 |
# M2 - ON - 8.0.18 - 90 - R |
| 193 |
# M3 - ON - 8.0.17 - 50 - W |
| 194 |
|
| 195 |
--replace_result $server3_uuid MEMBER_UUID |
| 196 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server3_uuid"); |
| 197 |
|
| 198 |
--let $_primary_member_of_group= $server3_uuid |
| 199 |
--source include/gr_assert_spm_consistency.inc |
| 200 |
|
| 201 |
|
| 202 |
--echo |
| 203 |
--echo # 9. Change primary, UDF succedds if new primary has lowest version. |
| 204 |
--echo # Assert configurations are correct. |
| 205 |
--echo |
| 206 |
|
| 207 |
# Server - State - Version - Weight - R/W/P/S |
| 208 |
# M1 - ON - 8.0.17 - 50 - S |
| 209 |
# M2 - ON - 8.0.18 - 90 - S |
| 210 |
# M3 - ON - 8.0.17 - 50 - P |
| 211 |
|
| 212 |
--replace_result $server1_uuid MEMBER_UUID |
| 213 |
--eval SELECT group_replication_set_as_primary("$server1_uuid"); |
| 214 |
|
| 215 |
--let $_primary_member_of_group= $server1_uuid |
| 216 |
--source include/gr_assert_spm_consistency.inc |
| 217 |
|
| 218 |
|
| 219 |
--echo |
| 220 |
--echo # 10. Make M3 weight higher and switch to SPM mode. M3 becomes primary. |
| 221 |
--echo # Member weight is considered among lowest equal versions. |
| 222 |
--echo # Assert configurations are correct. |
| 223 |
--echo |
| 224 |
|
| 225 |
# Server - State - Version - Weight - R/W/P/S |
| 226 |
# M1 - ON - 8.0.17 - 50 - P |
| 227 |
# M2 - ON - 8.0.18 - 90 - S |
| 228 |
# M3 - ON - 8.0.17 - 50 - S |
| 229 |
|
| 230 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 231 |
|
| 232 |
--let $rpl_connection_name= server3 |
| 233 |
--source include/rpl_connection.inc |
| 234 |
|
| 235 |
--eval SET GLOBAL group_replication_member_weight= 60 |
| 236 |
|
| 237 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 238 |
|
| 239 |
--let $_primary_member_of_group= $server3_uuid |
| 240 |
--source include/gr_assert_spm_consistency.inc |
| 241 |
|
| 242 |
|
| 243 |
--echo |
| 244 |
--echo # 11. Cleanup. |
| 245 |
--echo |
| 246 |
|
| 247 |
# Server - State - Version - Weight - R/W/P/S |
| 248 |
# M1 - ON - 8.0.17 - 50 - S |
| 249 |
# M2 - ON - 8.0.18 - 90 - S |
| 250 |
# M3 - ON - 8.0.17 - 60 - P |
| 251 |
|
| 252 |
SET @@GLOBAL.group_replication_member_weight = @member_weight3_save; |
| 253 |
|
| 254 |
--let $rpl_connection_name= server2 |
| 255 |
--source include/rpl_connection.inc |
| 256 |
|
| 257 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 258 |
# Stop GR because version is different. |
| 259 |
--source include/stop_group_replication.inc |
| 260 |
SET @@GLOBAL.group_replication_member_weight = @member_weight2_save; |
| 261 |
SET @@GLOBAL.DEBUG= @debug2_save; |
| 262 |
--source include/start_group_replication.inc |
| 263 |
|
| 264 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 265 |
--source include/group_replication_end.inc |