|
| 1 | +################################################################################ |
| 2 | +# Validate that View_change_log_event can be logged in a different order from |
| 3 | +# the group communication order without breaking the group transactions ids |
| 4 | +# generation. |
| 5 | +# |
| 6 | +# Steps: |
| 7 | +# 1. Create a group with 3 members. |
| 8 | +# 2. Start 2 servers. |
| 9 | +# Only setup recovery_user on server2 for force server3 |
| 10 | +# to recover from it. |
| 11 | +# 3. Stop applier on server 2 to force the delayed |
| 12 | +# View_change_log_event log to binary log. |
| 13 | +# 4. Start Group Replication on server3. |
| 14 | +# It will recover from server2 and will stay on |
| 15 | +# RECOVERING state waiting for View_change_log_event log. |
| 16 | +# 5. Execute 2 transactions on server1 and 2 while server3 |
| 17 | +# is on RECOVERING. |
| 18 | +# Transaction on server2 will validate the |
| 19 | +# group_replication_gtid_assignment_block_size option. |
| 20 | +# 6. Server 3 will apply INSERT (2) through recovery. |
| 21 | +# INSERT(1) will only be applied after member is ONLINE. |
| 22 | +# 7. Start applier on server2. |
| 23 | +# Server3 state will change to ONLINE. |
| 24 | +# 8. Sync all group members. |
| 25 | +# 9. Execute more transactions on all members. |
| 26 | +# Transactions on server2 and 3 will validate the |
| 27 | +# group_replication_gtid_assignment_block_size option. |
| 28 | +# 10. Sync all group members. |
| 29 | +# 11. Clean up. |
| 30 | +# |
| 31 | +# ==== Usage ==== |
| 32 | +# |
| 33 | +# --let $view_change_uuid = AUTOMATIC | UUID |
| 34 | +# --source ../include/gr_delayed_view_change_uuid_local_commit.inc |
| 35 | +# |
| 36 | +# Parameters: |
| 37 | +# $view_change_uuid |
| 38 | +# The group_replication_view_change_uuid parameter for Group Replication |
| 39 | +################################################################################ |
| 40 | +--source include/big_test.inc |
| 41 | +--source include/have_group_replication_plugin.inc |
| 42 | + |
| 43 | +--echo |
| 44 | +--echo ############################################################ |
| 45 | +--echo # 1. Create a group with 3 members. |
| 46 | +--let $rpl_skip_group_replication_start= 1 |
| 47 | +--let $rpl_server_count= 3 |
| 48 | +--source include/group_replication.inc |
| 49 | + |
| 50 | +--let $recovery_user= recovery_user |
| 51 | +--let $recovery_password= recovery_password |
| 52 | +--let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT |
| 53 | +--let $gtid_assignment_block_size = `SELECT @@GLOBAL.group_replication_gtid_assignment_block_size;` |
| 54 | + |
| 55 | +--echo |
| 56 | +--echo ############################################################ |
| 57 | +--echo # 2. Start 2 servers. |
| 58 | +--echo # Only setup recovery_user on server2 for force server3 |
| 59 | +--echo # to recover from it. |
| 60 | +--let $rpl_connection_name= server1 |
| 61 | +--source include/rpl_connection.inc |
| 62 | + |
| 63 | +SET sql_log_bin = 0; |
| 64 | +--source include/gtid_utils.inc |
| 65 | +SET sql_log_bin = 1; |
| 66 | + |
| 67 | +SET @group_replication_view_change_uuid_save= @@GLOBAL.group_replication_view_change_uuid; |
| 68 | +--eval SET @@GLOBAL.group_replication_view_change_uuid = "$view_change_uuid" |
| 69 | + |
| 70 | +--source include/start_and_bootstrap_group_replication.inc |
| 71 | +CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 72 | +INSERT INTO t1 VALUES (0); |
| 73 | + |
| 74 | +--let $rpl_connection_name= server2 |
| 75 | +--source include/rpl_connection.inc |
| 76 | +--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 77 | + |
| 78 | +SET sql_log_bin = 0; |
| 79 | +--source include/gtid_utils.inc |
| 80 | +SET sql_log_bin = 1; |
| 81 | + |
| 82 | +SET SESSION sql_log_bin= 0; |
| 83 | +--eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password" |
| 84 | +--eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user" |
| 85 | +FLUSH PRIVILEGES; |
| 86 | +SET SESSION sql_log_bin= 1; |
| 87 | + |
| 88 | +SET @group_replication_view_change_uuid_save= @@GLOBAL.group_replication_view_change_uuid; |
| 89 | +--eval SET @@GLOBAL.group_replication_view_change_uuid = "$view_change_uuid" |
| 90 | + |
| 91 | +--source include/start_group_replication.inc |
| 92 | + |
| 93 | + |
| 94 | +--echo |
| 95 | +--echo ############################################################ |
| 96 | +--echo # 3. Stop applier on server 2 to force the delayed |
| 97 | +--echo # View_change_log_event log to binary log. |
| 98 | +--let $rpl_connection_name= server2 |
| 99 | +--source include/rpl_connection.inc |
| 100 | + |
| 101 | +STOP SLAVE SQL_THREAD FOR CHANNEL "group_replication_applier"; |
| 102 | +--let $wait_condition= SELECT service_state="OFF" FROM performance_schema.replication_applier_status WHERE channel_name="group_replication_applier" |
| 103 | +--source include/wait_condition.inc |
| 104 | + |
| 105 | + |
| 106 | +--echo |
| 107 | +--echo ############################################################ |
| 108 | +--echo # 4. Start Group Replication on server3. |
| 109 | +--echo # It will recover from server2 and will stay on |
| 110 | +--echo # RECOVERING state waiting for View_change_log_event log. |
| 111 | +--let $rpl_connection_name= server3 |
| 112 | +--source include/rpl_connection.inc |
| 113 | + |
| 114 | + |
| 115 | +SET sql_log_bin = 0; |
| 116 | +--source include/gtid_utils.inc |
| 117 | +SET sql_log_bin = 1; |
| 118 | + |
| 119 | +SET SESSION sql_log_bin= 0; |
| 120 | +call mtr.add_suppression("There was an error when connecting to the donor server.*"); |
| 121 | +call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Slave I/O for channel group_replication_recovery."); |
| 122 | +SET SESSION sql_log_bin= 1; |
| 123 | + |
| 124 | +--disable_warnings |
| 125 | +--eval CHANGE REPLICATION SOURCE TO SOURCE_USER= '$recovery_user', SOURCE_PASSWORD= '$recovery_password' FOR CHANNEL 'group_replication_recovery' |
| 126 | +--enable_warnings |
| 127 | + |
| 128 | +SET @group_replication_view_change_uuid_save= @@GLOBAL.group_replication_view_change_uuid; |
| 129 | +--eval SET @@GLOBAL.group_replication_view_change_uuid = "$view_change_uuid"; |
| 130 | + |
| 131 | +--let $group_replication_start_member_state= RECOVERING |
| 132 | +--source include/start_group_replication.inc |
| 133 | + |
| 134 | +# Wait for server2 as donor |
| 135 | +--let $wait_condition= SELECT source_uuid="$server2_uuid" FROM performance_schema.replication_connection_status WHERE channel_name="group_replication_recovery" AND service_state="ON" |
| 136 | +--source include/wait_condition.inc |
| 137 | + |
| 138 | + |
| 139 | +--echo |
| 140 | +--echo ############################################################ |
| 141 | +--echo # 5. Execute 2 transactions on server1 and 1 while server3 |
| 142 | +--echo # is on RECOVERING. |
| 143 | +--echo # Transaction on server2 will validate the |
| 144 | +--echo # group_replication_gtid_assignment_block_size option. |
| 145 | +--let $rpl_connection_name= server1 |
| 146 | +--source include/rpl_connection.inc |
| 147 | +INSERT INTO t1 VALUES (1); |
| 148 | + |
| 149 | +--let $rpl_connection_name= server2 |
| 150 | +--source include/rpl_connection.inc |
| 151 | +INSERT INTO t1 VALUES (2); |
| 152 | + |
| 153 | +# View change (s1) # Create table # Insert # View change (s2) # Insert |
| 154 | +--let $event_sequence= $vcle_seq # !Gtid_transaction # !Gtid_transaction # $vcle_seq # !Gtid_transaction |
| 155 | +--source include/assert_binlog_events.inc |
| 156 | + |
| 157 | + |
| 158 | +--echo |
| 159 | +--echo ############################################################ |
| 160 | +--echo # 6. Server 3 will apply INSERT (2) through recovery. |
| 161 | +--echo # INSERT(1) will only be applied after member is ONLINE. |
| 162 | +--let $rpl_connection_name= server3 |
| 163 | +--source include/rpl_connection.inc |
| 164 | + |
| 165 | +# Wait for INSERT (2) to reach server 3 as GNO 7 |
| 166 | + |
| 167 | +if ($view_change_uuid == AUTOMATIC) { |
| 168 | + --let $expected_gtid_set= $group_replication_group_name:1-4:7 |
| 169 | + if ($gtid_assignment_block_size == 1000000) |
| 170 | + { |
| 171 | + --let $expected_gtid_set= $group_replication_group_name:1-4:1000005 |
| 172 | + } |
| 173 | +} |
| 174 | + |
| 175 | +if ($view_change_uuid != AUTOMATIC) { |
| 176 | + --let $expected_gtid_set= $group_replication_group_name:1-2:4, $view_change_uuid:1-2 |
| 177 | + if ($gtid_assignment_block_size == 1000000) |
| 178 | + { |
| 179 | + --let $expected_gtid_set= $group_replication_group_name:1-2:1000003, $view_change_uuid:1-2 |
| 180 | + } |
| 181 | +} |
| 182 | + |
| 183 | + |
| 184 | +--disable_query_log |
| 185 | +--disable_result_log |
| 186 | +--eval SELECT WAIT_FOR_EXECUTED_GTID_SET("$expected_gtid_set") |
| 187 | +--enable_query_log |
| 188 | +--enable_result_log |
| 189 | + |
| 190 | +# View change (s1) # Create table # Insert # View change (s2) # Insert |
| 191 | +--let $event_sequence= $vcle_seq # !Gtid_transaction # !Gtid_transaction # $vcle_seq # !Gtid_transaction |
| 192 | +--source include/assert_binlog_events.inc |
| 193 | + |
| 194 | +--let $assert_text= 'There is no value 1 in table t1' |
| 195 | +--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 0 |
| 196 | +--source include/assert.inc |
| 197 | + |
| 198 | +--let $assert_text= 'There is a value 2 in table t1' |
| 199 | +--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=2, count, 1] = 1 |
| 200 | +--source include/assert.inc |
| 201 | + |
| 202 | + |
| 203 | +--echo |
| 204 | +--echo ############################################################ |
| 205 | +--echo # 7. Start applier on server2. |
| 206 | +--echo # Server3 state will change to ONLINE. |
| 207 | +--let $rpl_connection_name= server2 |
| 208 | +--source include/rpl_connection.inc |
| 209 | +START SLAVE SQL_THREAD FOR CHANNEL "group_replication_applier"; |
| 210 | +--let $wait_condition= SELECT service_state="ON" FROM performance_schema.replication_applier_status WHERE channel_name="group_replication_applier" |
| 211 | +--source include/wait_condition.inc |
| 212 | + |
| 213 | +--let $rpl_connection_name= server3 |
| 214 | +--source include/rpl_connection.inc |
| 215 | +--let $group_replication_member_state= ONLINE |
| 216 | +--source include/gr_wait_for_member_state.inc |
| 217 | + |
| 218 | + |
| 219 | +--echo |
| 220 | +--echo ############################################################ |
| 221 | +--echo # 8. Sync all group members. |
| 222 | +--let $rpl_connection_name= server1 |
| 223 | +--source include/rpl_connection.inc |
| 224 | + |
| 225 | +if ($view_change_uuid == AUTOMATIC) { |
| 226 | + --let $expected_gtid_set= $group_replication_group_name:1-7 |
| 227 | + if ($gtid_assignment_block_size == 1000000) |
| 228 | + { |
| 229 | + --let $expected_gtid_set= $group_replication_group_name:1-6:1000005 |
| 230 | + } |
| 231 | +} |
| 232 | + |
| 233 | +if ($view_change_uuid != AUTOMATIC) { |
| 234 | + --let $expected_gtid_set= $group_replication_group_name:1-3, $view_change_uuid:1-3 |
| 235 | + if ($gtid_assignment_block_size == 1000000) |
| 236 | + { |
| 237 | + --let $expected_gtid_set= $group_replication_group_name:1-3:1000003, $view_change_uuid:1-3 |
| 238 | + } |
| 239 | +} |
| 240 | +--disable_query_log |
| 241 | +--disable_result_log |
| 242 | +--eval SELECT WAIT_FOR_EXECUTED_GTID_SET("$expected_gtid_set") |
| 243 | +--enable_query_log |
| 244 | +--enable_result_log |
| 245 | + |
| 246 | +--let $rpl_connection_name= server2 |
| 247 | +--source include/rpl_connection.inc |
| 248 | +--disable_query_log |
| 249 | +--disable_result_log |
| 250 | +--eval SELECT WAIT_FOR_EXECUTED_GTID_SET("$expected_gtid_set") |
| 251 | +--enable_query_log |
| 252 | +--enable_result_log |
| 253 | + |
| 254 | +--let $rpl_connection_name= server3 |
| 255 | +--source include/rpl_connection.inc |
| 256 | +--disable_query_log |
| 257 | +--disable_result_log |
| 258 | +--eval SELECT WAIT_FOR_EXECUTED_GTID_SET("$expected_gtid_set") |
| 259 | +--enable_query_log |
| 260 | +--enable_result_log |
| 261 | + |
| 262 | +# View change (s1) # Create table # Insert # View change (s2) # Insert # View change (s3) # Insert |
| 263 | +--let $event_sequence= $vcle_seq # !Gtid_transaction # !Gtid_transaction # $vcle_seq # !Gtid_transaction # $vcle_seq # !Gtid_transaction |
| 264 | +--source include/assert_binlog_events.inc |
| 265 | + |
| 266 | + |
| 267 | +--echo |
| 268 | +--echo ############################################################ |
| 269 | +--echo # 9. Execute more transactions on all members. |
| 270 | +--echo # Transactions on server2 and 3 will validate the |
| 271 | +--echo # group_replication_gtid_assignment_block_size option. |
| 272 | +--let $rpl_connection_name= server1 |
| 273 | +--source include/rpl_connection.inc |
| 274 | +INSERT INTO t1 VALUES (11); |
| 275 | + |
| 276 | +--let $rpl_connection_name= server2 |
| 277 | +--source include/rpl_connection.inc |
| 278 | +INSERT INTO t1 VALUES (22); |
| 279 | + |
| 280 | +--let $rpl_connection_name= server3 |
| 281 | +--source include/rpl_connection.inc |
| 282 | +INSERT INTO t1 VALUES (33); |
| 283 | +--source include/rpl_sync.inc |
| 284 | + |
| 285 | + |
| 286 | +--echo |
| 287 | +--echo ############################################################ |
| 288 | +--echo # 10. Sync all group members. |
| 289 | +--let $rpl_connection_name= server1 |
| 290 | +--source include/rpl_connection.inc |
| 291 | + |
| 292 | +if ($view_change_uuid == AUTOMATIC) { |
| 293 | + --let $expected_gtid_set= $group_replication_group_name:1-10 |
| 294 | + if ($gtid_assignment_block_size == 1000000) |
| 295 | + { |
| 296 | + --let $expected_gtid_set= $group_replication_group_name:1-7:1000005-1000006:2000005 |
| 297 | + } |
| 298 | +} |
| 299 | + |
| 300 | +if ($view_change_uuid != AUTOMATIC) { |
| 301 | + --let $expected_gtid_set= $group_replication_group_name:1-7, $view_change_uuid:1-3 |
| 302 | + if ($gtid_assignment_block_size == 1000000) |
| 303 | + { |
| 304 | + --let $expected_gtid_set= $group_replication_group_name:1-4:1000003-1000004:2000003, $view_change_uuid:1-3 |
| 305 | + } |
| 306 | +} |
| 307 | +--let $assert_text= GTID_EXECUTED must contain all committed GTIDs |
| 308 | +--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$expected_gtid_set") |
| 309 | +--source include/assert.inc |
| 310 | + |
| 311 | +--let $assert_text= 'There are 6 values in table t1' |
| 312 | +--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 6 |
| 313 | +--source include/assert.inc |
| 314 | + |
| 315 | +--let $rpl_connection_name= server2 |
| 316 | +--source include/rpl_connection.inc |
| 317 | +--let $assert_text= GTID_EXECUTED must contain all committed GTIDs |
| 318 | +--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$expected_gtid_set") |
| 319 | +--source include/assert.inc |
| 320 | + |
| 321 | +--let $assert_text= 'There are 6 values in table t1' |
| 322 | +--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 6 |
| 323 | +--source include/assert.inc |
| 324 | + |
| 325 | +--let $rpl_connection_name= server3 |
| 326 | +--source include/rpl_connection.inc |
| 327 | +--let $assert_text= GTID_EXECUTED must contain all committed GTIDs |
| 328 | +--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$expected_gtid_set") |
| 329 | +--source include/assert.inc |
| 330 | + |
| 331 | +--let $assert_text= 'There are 6 values in table t1' |
| 332 | +--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 6 |
| 333 | +--source include/assert.inc |
| 334 | + |
| 335 | + |
| 336 | +--echo |
| 337 | +--echo ############################################################ |
| 338 | +--echo # 11. Clean up. |
| 339 | +--let $rpl_connection_name= server2 |
| 340 | +--source include/rpl_connection.inc |
| 341 | +DROP TABLE t1; |
| 342 | + |
| 343 | +SET SESSION sql_log_bin= 0; |
| 344 | +--eval DROP USER "$recovery_user" |
| 345 | +SET SESSION sql_log_bin= 1; |
| 346 | + |
| 347 | +--source include/stop_group_replication.inc |
| 348 | +SET @@GLOBAL.group_replication_view_change_uuid= @group_replication_view_change_uuid_save; |
| 349 | + |
| 350 | +SET sql_log_bin = 0; |
| 351 | +--source include/gtid_utils_end.inc |
| 352 | +SET sql_log_bin = 1; |
| 353 | + |
| 354 | +--let $rpl_connection_name= server1 |
| 355 | +--source include/rpl_connection.inc |
| 356 | + |
| 357 | +--source include/stop_group_replication.inc |
| 358 | +SET @@GLOBAL.group_replication_view_change_uuid= @group_replication_view_change_uuid_save; |
| 359 | + |
| 360 | +SET sql_log_bin = 0; |
| 361 | +--source include/gtid_utils_end.inc |
| 362 | +SET sql_log_bin = 1; |
| 363 | + |
| 364 | +--let $rpl_connection_name= server3 |
| 365 | +--source include/rpl_connection.inc |
| 366 | + |
| 367 | +--source include/stop_group_replication.inc |
| 368 | +SET @@GLOBAL.group_replication_view_change_uuid= @group_replication_view_change_uuid_save; |
| 369 | + |
| 370 | +SET sql_log_bin = 0; |
| 371 | +--source include/gtid_utils_end.inc |
| 372 | +SET sql_log_bin = 1; |
| 373 | + |
| 374 | +--source include/group_replication_end.inc |
0 commit comments