| 1 |
################################################################################ |
| 2 |
# Verify following auto_increment behaviours: |
| 3 |
# |
| 4 |
# Test: |
| 5 |
# 0. This test starts with 4 non-started members. |
| 6 |
# 1. Check the defaults of group_replication_auto_increment_increment, |
| 7 |
# auto_increment_increment and auto_increment_offset. |
| 8 |
# 2. Check that the value of group_replication_auto_increment_increment |
| 9 |
# can be set before GR start, but its effects on |
| 10 |
# auto_increment_increment and auto_increment_offset do not happen. |
| 11 |
# 3. Check that the effects of group_replication_auto_increment_increment |
| 12 |
# on auto_increment_increment and auto_increment_offset happen on |
| 13 |
# starting GR. |
| 14 |
# 4. When the number of members is bigger than the auto_increment_increment |
| 15 |
# value, an error is logged. |
| 16 |
# 5. When auto_increment_increment and auto_increment_offset are not equal to 1, |
| 17 |
# group_replication should not update their value on START and STOP. |
| 18 |
# 6. When auto_increment_increment and auto_increment_offset are equal to 1, |
| 19 |
# then verify if plugin on start set auto_increment_increment variable |
| 20 |
# equal to group_replication_auto_increment_increment value. |
| 21 |
# 7. When group_replication is stopped verify that plugin reset |
| 22 |
# auto_increment_increment and auto_increment_offset values to 1. |
| 23 |
# 8. Verify start/stop group_replication plugin doesn't affect setting |
| 24 |
# auto_increment_increment from group_replication_auto_increment_increment |
| 25 |
# value. |
| 26 |
# 9. Verify server restart doesn't affect setting auto_increment_increment from |
| 27 |
# group_replication_auto_increment_increment value. |
| 28 |
# 10. Verify group_replication_auto_increment_increment can't be set when |
| 29 |
# group_replication plugin is running. |
| 30 |
# 11. Validate that when user tries to set invalid values a |
| 31 |
# error is thrown. |
| 32 |
# 12. Clean up. |
| 33 |
################################################################################ |
| 34 |
--source include/big_test.inc |
| 35 |
--source include/have_group_replication_plugin.inc |
| 36 |
--source include/force_restart.inc |
| 37 |
|
| 38 |
--let $rpl_skip_group_replication_start= 1 |
| 39 |
--let $rpl_server_count= 4 |
| 40 |
--source include/group_replication.inc |
| 41 |
|
| 42 |
--connection server1 |
| 43 |
--source include/start_and_bootstrap_group_replication.inc |
| 44 |
|
| 45 |
--connection server3 |
| 46 |
--source include/start_group_replication.inc |
| 47 |
|
| 48 |
--connection server4 |
| 49 |
--source include/start_group_replication.inc |
| 50 |
|
| 51 |
# Use server2 so that we can set |
| 52 |
# group_replication_auto_increment_increment-slave.opt |
| 53 |
--connection server2 |
| 54 |
|
| 55 |
# changing GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT for server2 |
| 56 |
# and so storing it only for server2 |
| 57 |
--let $_init_auto_increment= `SELECT @@GLOBAL.GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT` |
| 58 |
|
| 59 |
--echo ####################################################################### |
| 60 |
--echo # 1. Check the defaults of group_replication_auto_increment_increment, |
| 61 |
--echo # auto_increment_increment and auto_increment_offset. |
| 62 |
--echo ####################################################################### |
| 63 |
--let $assert_text= The default value of group_replication_auto_increment_increment for server2 should be 7 |
| 64 |
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 7 |
| 65 |
--source include/assert.inc |
| 66 |
--let $assert_text= The default value of auto_increment_increment for server2 should be 1 |
| 67 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1 |
| 68 |
--source include/assert.inc |
| 69 |
--let $assert_text= The default value of auto_increment_offset for server2 should be 1 |
| 70 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1 |
| 71 |
--source include/assert.inc |
| 72 |
|
| 73 |
--echo ####################################################################### |
| 74 |
--echo # 2. Check that the value of group_replication_auto_increment_increment |
| 75 |
--echo # can be set before GR start, but its effects on |
| 76 |
--echo # auto_increment_increment and auto_increment_offset do not happen. |
| 77 |
--echo ####################################################################### |
| 78 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 3; |
| 79 |
--let $assert_text= The value of group_replication_auto_increment_increment is set to 3 |
| 80 |
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 3 |
| 81 |
--source include/assert.inc |
| 82 |
--let $assert_text= The value of auto_increment_increment is not affected |
| 83 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1 |
| 84 |
--source include/assert.inc |
| 85 |
--let $assert_text= The value of auto_increment_offset is not affected |
| 86 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1 |
| 87 |
--source include/assert.inc |
| 88 |
|
| 89 |
--source include/start_group_replication.inc |
| 90 |
|
| 91 |
--echo ######################################################################### |
| 92 |
--echo # 3. Check that the effects of group_replication_auto_increment_increment |
| 93 |
--echo # on auto_increment_increment and auto_increment_offset happen on |
| 94 |
--echo # starting GR. |
| 95 |
--echo ######################################################################### |
| 96 |
--let $assert_text= The value of group_replication_auto_increment_increment is still 3 |
| 97 |
--let $assert_cond= [SELECT @@GLOBAL.group_replication_auto_increment_increment] = 3 |
| 98 |
--source include/assert.inc |
| 99 |
--let $assert_text= The value of auto_increment_increment is set to 3 |
| 100 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 3 |
| 101 |
--source include/assert.inc |
| 102 |
--let $assert_text= The value of auto_increment_offset is set to 2 |
| 103 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2 |
| 104 |
--source include/assert.inc |
| 105 |
|
| 106 |
|
| 107 |
--echo ############################################################ |
| 108 |
--echo # 4. When the number of members is bigger than |
| 109 |
--echo # the auto_increment_increment value, an error is logged. |
| 110 |
--echo ############################################################ |
| 111 |
|
| 112 |
--replace_regex /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][-+Z][0-9:]* *[0-9]* \[ERROR\] \[[^\]]*\] */DATE_TIME [ERROR] / |
| 113 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/group_replication_auto_increment_increment_log.err |
| 114 |
--let $grep_pattern=Group contains 4 members which is greater than group_replication_auto_increment_increment value of 3. This can lead to a higher transactional abort rate. |
| 115 |
--source include/grep_pattern.inc |
| 116 |
|
| 117 |
--echo ############################################################ |
| 118 |
--echo # 5. When auto_increment_increment and auto_increment_offset |
| 119 |
--echo # not set to default value |
| 120 |
--echo # i.e. auto_increment_increment= 1 |
| 121 |
--echo # auto_increment_offset= 1 |
| 122 |
--echo # group_replication should not update their value. |
| 123 |
--echo ############################################################ |
| 124 |
|
| 125 |
--source include/stop_group_replication.inc |
| 126 |
|
| 127 |
SET GLOBAL AUTO_INCREMENT_INCREMENT= 5; |
| 128 |
SET GLOBAL AUTO_INCREMENT_OFFSET= 5; |
| 129 |
|
| 130 |
--source include/start_group_replication.inc |
| 131 |
|
| 132 |
--let $assert_text= The value of auto_increment_increment for server2 should be 5 |
| 133 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 5 |
| 134 |
--source include/assert.inc |
| 135 |
|
| 136 |
--let $assert_text= The value of auto_increment_offset for server2 should be 5 |
| 137 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 5 |
| 138 |
--source include/assert.inc |
| 139 |
|
| 140 |
--source include/stop_group_replication.inc |
| 141 |
|
| 142 |
--let $assert_text= The value of auto_increment_increment for server2 should be 5 |
| 143 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 5 |
| 144 |
--source include/assert.inc |
| 145 |
|
| 146 |
--let $assert_text= The value of auto_increment_offset for server2 should be 5 |
| 147 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 5 |
| 148 |
--source include/assert.inc |
| 149 |
|
| 150 |
--echo ############################################################ |
| 151 |
--echo # 6. When auto_increment_increment and auto_increment_offset are equal |
| 152 |
--echo # to 1, then verify if plugin on start set auto_increment_increment |
| 153 |
--echo # variable equal to group_replication_auto_increment_increment value. |
| 154 |
--echo ############################################################ |
| 155 |
|
| 156 |
SET GLOBAL AUTO_INCREMENT_INCREMENT= 1; |
| 157 |
SET GLOBAL AUTO_INCREMENT_OFFSET= 1; |
| 158 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 4; |
| 159 |
|
| 160 |
--source include/start_group_replication.inc |
| 161 |
|
| 162 |
--let $assert_text= The value of auto_increment_increment for server2 should be 4 |
| 163 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 4 |
| 164 |
--source include/assert.inc |
| 165 |
|
| 166 |
--let $assert_text= The value of auto_increment_offset for server2 should be 2 |
| 167 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2 |
| 168 |
--source include/assert.inc |
| 169 |
|
| 170 |
--echo ############################################################ |
| 171 |
--echo # 7. When group_replication is stopped verify that plugin reset |
| 172 |
--echo # auto_increment_increment and auto_increment_offset values to 1. |
| 173 |
--echo ############################################################ |
| 174 |
|
| 175 |
--source include/stop_group_replication.inc |
| 176 |
|
| 177 |
--let $assert_text= The value of auto_increment_increment for server2 should be 1 |
| 178 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1 |
| 179 |
--source include/assert.inc |
| 180 |
|
| 181 |
--let $assert_text= The value of auto_increment_offset for server2 should be 1 |
| 182 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1 |
| 183 |
--source include/assert.inc |
| 184 |
|
| 185 |
# Set GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT to 1, so that it doesn't |
| 186 |
# affect when starting group_replication again. |
| 187 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 1; |
| 188 |
|
| 189 |
--echo ############################################################ |
| 190 |
--echo # 8. Verify start/stop group_replication plugin doesn't affect |
| 191 |
--echo # setting auto_increment_increment from |
| 192 |
--echo # group_replication_auto_increment_increment value. |
| 193 |
--echo ############################################################ |
| 194 |
|
| 195 |
--source include/start_group_replication.inc |
| 196 |
|
| 197 |
--let $assert_text= The value of auto_increment_increment for server2 should be 1 |
| 198 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1 |
| 199 |
--source include/assert.inc |
| 200 |
|
| 201 |
--let $assert_text= The value of auto_increment_offset for server2 should be 2 |
| 202 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2 |
| 203 |
--source include/assert.inc |
| 204 |
|
| 205 |
--source include/stop_group_replication.inc |
| 206 |
|
| 207 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 9; |
| 208 |
|
| 209 |
--source include/start_group_replication.inc |
| 210 |
|
| 211 |
--let $assert_text= The value of auto_increment_increment for server2 should be 9 |
| 212 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 9 |
| 213 |
--source include/assert.inc |
| 214 |
|
| 215 |
--let $assert_text= The value of auto_increment_offset for server2 should be 2 |
| 216 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2 |
| 217 |
--source include/assert.inc |
| 218 |
|
| 219 |
--echo ############################################################ |
| 220 |
--echo # 9. Verify server restart doesn't affect setting |
| 221 |
--echo # auto_increment_increment from |
| 222 |
--echo # group_replication_auto_increment_increment value. |
| 223 |
--echo ############################################################ |
| 224 |
|
| 225 |
--source include/stop_group_replication.inc |
| 226 |
|
| 227 |
--let $assert_text= The value of auto_increment_increment for server2 should be 1 |
| 228 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1 |
| 229 |
--source include/assert.inc |
| 230 |
|
| 231 |
--let $assert_text= The value of auto_increment_offset for server2 should be 1 |
| 232 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 1 |
| 233 |
--source include/assert.inc |
| 234 |
|
| 235 |
# Set GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT to 1, so that it doesn't |
| 236 |
# affect when starting group_replication again. |
| 237 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 1; |
| 238 |
|
| 239 |
--source include/start_group_replication.inc |
| 240 |
|
| 241 |
--let $assert_text= The value of auto_increment_increment for server2 should be 1 |
| 242 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 1 |
| 243 |
--source include/assert.inc |
| 244 |
|
| 245 |
--let $assert_text= The value of auto_increment_offset for server2 should be 2 |
| 246 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2 |
| 247 |
--source include/assert.inc |
| 248 |
|
| 249 |
# restart server |
| 250 |
--let $allow_rpl_inited= 1 |
| 251 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 252 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 253 |
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds |
| 254 |
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS |
| 255 |
--source include/restart_mysqld.inc |
| 256 |
|
| 257 |
# Needed as we are not using rpl_restart_server.inc |
| 258 |
--let $rpl_server_number= 2 |
| 259 |
--source include/rpl_reconnect.inc |
| 260 |
|
| 261 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 9; |
| 262 |
|
| 263 |
--source include/start_group_replication.inc |
| 264 |
|
| 265 |
--let $assert_text= The value of auto_increment_increment for server2 should be 9 |
| 266 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_increment] = 9 |
| 267 |
--source include/assert.inc |
| 268 |
|
| 269 |
--let $assert_text= The value of auto_increment_offset for server2 should be 2 |
| 270 |
--let $assert_cond= [SELECT @@GLOBAL.auto_increment_offset] = 2 |
| 271 |
--source include/assert.inc |
| 272 |
|
| 273 |
--echo ############################################################ |
| 274 |
--echo # 10. Verify group_replication_auto_increment_increment can't be set |
| 275 |
--echo # when group_replication plugin is running. |
| 276 |
--echo ############################################################ |
| 277 |
|
| 278 |
--error ER_GROUP_REPLICATION_RUNNING |
| 279 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 9; |
| 280 |
|
| 281 |
--echo ############################################################ |
| 282 |
--echo # 11. Validate that when user tries to set invalid values a |
| 283 |
--echo # error is thrown. |
| 284 |
--echo ############################################################ |
| 285 |
--connection server2 |
| 286 |
--source include/stop_group_replication.inc |
| 287 |
|
| 288 |
--error ER_WRONG_VALUE_FOR_VAR |
| 289 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= -1; |
| 290 |
|
| 291 |
--error ER_WRONG_VALUE_FOR_VAR |
| 292 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 65536; |
| 293 |
|
| 294 |
--error ER_WRONG_VALUE_FOR_VAR |
| 295 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 0; |
| 296 |
|
| 297 |
--error ER_WRONG_TYPE_FOR_VAR |
| 298 |
SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= 'a'; |
| 299 |
|
| 300 |
--echo ############################################################ |
| 301 |
--echo # 12. clean up and reset auto_increment variables value |
| 302 |
--echo ############################################################ |
| 303 |
--eval SET GLOBAL GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT= $_init_auto_increment |
| 304 |
--source include/group_replication_end.inc |