| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Test replication errors that depend on GTID_MODE. |
| 4 |
# |
| 5 |
# The following classes of errors are tested: |
| 6 |
# |
| 7 |
# - Errors generated when the server starts. |
| 8 |
# - GTID_MODE and ENFORCE_GTID_CONSISTENCY are incompatible. |
| 9 |
# - todo: GTID_MODE and AUTO_POSITION are incompatible. |
| 10 |
# - Errors generated by the master in the replication protocol |
| 11 |
# handshake. |
| 12 |
# - todo: GTID_MODE on master is incompatible with AUTO_POSITION. |
| 13 |
# - Errors generated by the slave in the replication protocol |
| 14 |
# handshake. |
| 15 |
# - GTID_MODE on master and slave are incompatible. |
| 16 |
# - GTID_MODE on master is incompatible with AUTO_POSITION. |
| 17 |
# - GTID_MODE on slave is incompatibale with AUTO_POSITION. |
| 18 |
# - Slave receiver thread can not start in AUTO_POSITION mode because |
| 19 |
# slave has GTID-MODE = OFF. |
| 20 |
# - Errors generated by a running sender thread. |
| 21 |
# - Cannot replicate GTID-transaction when GTID_MODE = OFF. |
| 22 |
# - Cannot replicate anonymous transaction when GTID_MODE = ON. |
| 23 |
# - Cannot replicate anonymous transaction when AUTO_POSITION = 1. |
| 24 |
# - Errors generated by a running receiver thread. |
| 25 |
# - Cannot replicate GTID-transaction when GTID_MODE = OFF. |
| 26 |
# - Cannot replicate anonymous transaction when GTID_MODE = ON. |
| 27 |
# - Cannot replicate anonymous transaction when AUTO_POSITION = 1. |
| 28 |
# - GTID_NEXT cannot be set to ANONYMOUS when @@GLOBAL.GTID_MODE = ON. |
| 29 |
# - Errors when rotate fails while setting gtid_mode. |
| 30 |
# |
| 31 |
# ==== References ==== |
| 32 |
# |
| 33 |
# WL#3584: Global Transaction Identifiers |
| 34 |
# - Added in this worklog |
| 35 |
# WL#7083: GTIDs: Set GTID_MODE=ON online |
| 36 |
# - Rewrote the test. |
| 37 |
|
| 38 |
--source include/no_valgrind_without_big.inc |
| 39 |
--source include/have_debug_sync.inc |
| 40 |
--source include/have_debug.inc |
| 41 |
# include/assert_command_output.inc doesn't work for mysqld on windows |
| 42 |
--source include/not_windows.inc |
| 43 |
--source include/not_group_replication_plugin.inc |
| 44 |
--let $rpl_gtid_utils= 1 |
| 45 |
--source include/master-slave.inc |
| 46 |
|
| 47 |
--echo ==== Initialize ==== |
| 48 |
|
| 49 |
call mtr.add_suppression("Replica I/O for channel '': The replication receiver thread cannot start"); |
| 50 |
call mtr.add_suppression("Replica I/O for channel '': The replica IO thread stops"); |
| 51 |
call mtr.add_suppression("Replica I/O for channel '': Got fatal error 1236 from source when reading data from binary log: 'Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF"); |
| 52 |
call mtr.add_suppression("Replica I/O for channel '': Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF"); |
| 53 |
call mtr.add_suppression("GTID_LOG_EVENT or ANONYMOUS_GTID_LOG_EVENT is not expected in an event stream after a GTID_LOG_EVENT or an ANONYMOUS_GTID_LOG_EVENT."); |
| 54 |
call mtr.add_suppression("An unexpected event sequence was detected by the IO thread while queuing the event received from source"); |
| 55 |
call mtr.add_suppression("Detected misconfiguration: replication channel '' was configured with AUTO_POSITION = 1, but the server was started with --gtid-mode=off."); |
| 56 |
call mtr.add_suppression("Replica I/O for channel '': Relay log write failure: could not queue event from source"); |
| 57 |
call mtr.add_suppression("Got fatal error 1236 from source when reading data from binary log: 'Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON"); |
| 58 |
call mtr.add_suppression("Replica I/O for channel '': Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON"); |
| 59 |
call mtr.add_suppression("Replica I/O for channel '': Cannot replicate anonymous transaction when AUTO_POSITION = 1"); |
| 60 |
call mtr.add_suppression("Got fatal error 1236 from source when reading data from binary log: 'Cannot replicate anonymous transaction when AUTO_POSITION = 1,"); |
| 61 |
call mtr.add_suppression("Replica I/O for channel '': The source uses an unknown GTID_MODE 'on_something'. Treating it as 'ON'."); |
| 62 |
call mtr.add_suppression("Replica I/O for channel '': The source uses an unknown GTID_MODE 'off_something'. Treating it as 'OFF'."); |
| 63 |
call mtr.add_suppression("Could not open .* for logging.*. Turning logging off for the whole duration of the MySQL server process."); |
| 64 |
|
| 65 |
--let $saved_binlog_error_action=`SELECT @@GLOBAL.binlog_error_action` |
| 66 |
|
| 67 |
--source include/sync_slave_sql_with_master.inc |
| 68 |
--source include/stop_slave.inc |
| 69 |
|
| 70 |
--let $saved_innodb_page_size_server2=`SELECT @@innodb_page_size` |
| 71 |
--connection master |
| 72 |
--let $saved_innodb_page_size_server1=`SELECT @@innodb_page_size` |
| 73 |
|
| 74 |
--let $server1_cmd= $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --innodb-page-size=$saved_innodb_page_size_server1 |
| 75 |
|
| 76 |
--let $server2_cmd= $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --default-storage-engine=InnoDB --default-tmp-storage-engine=InnoDB --innodb-page-size=$saved_innodb_page_size_server2 |
| 77 |
|
| 78 |
--echo ==== Checks performed at server start ==== |
| 79 |
|
| 80 |
--echo ---- gtid-mode=ON requires enforce-gtid-consistency ---- |
| 81 |
|
| 82 |
--let $rpl_server_number= 2 |
| 83 |
--source include/rpl_stop_server.inc |
| 84 |
|
| 85 |
--let $assert_command= $server2_cmd --gtid-mode=on 2>&1 |
| 86 |
--let $assert_regex= GTID_MODE = ON requires ENFORCE_GTID_CONSISTENCY = ON |
| 87 |
--let $assert_status= 1 |
| 88 |
--source include/assert_command_output.inc |
| 89 |
|
| 90 |
--let $rpl_server_number= 2 |
| 91 |
--let $rpl_start_with_gtids= 0 |
| 92 |
--source include/rpl_start_server.inc |
| 93 |
|
| 94 |
--echo ==== Master-slave handshake checks ==== |
| 95 |
|
| 96 |
--source include/rpl_connection_master.inc |
| 97 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON; |
| 98 |
--source include/rpl_connection_slave.inc |
| 99 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON; |
| 100 |
|
| 101 |
# Prevent rpl_set_gtid_mode.inc from trying to sync. |
| 102 |
--let $rpl_skip_sync= 1 |
| 103 |
|
| 104 |
--let $master_gtid_mode= 0 |
| 105 |
while ($master_gtid_mode <= 3) |
| 106 |
{ |
| 107 |
--let $rpl_gtid_mode= $master_gtid_mode |
| 108 |
--let $rpl_server_numbers= 1 |
| 109 |
--source include/rpl_set_gtid_mode.inc |
| 110 |
|
| 111 |
--let $slave_gtid_mode= 0 |
| 112 |
while ($slave_gtid_mode <= 3) |
| 113 |
{ |
| 114 |
--let $rpl_gtid_mode= $slave_gtid_mode |
| 115 |
--let $rpl_server_numbers= 2 |
| 116 |
--source include/rpl_set_gtid_mode.inc |
| 117 |
|
| 118 |
--connection slave |
| 119 |
|
| 120 |
# Master and slave gtid_mode compatibility. |
| 121 |
--let $gtid_modes_compatible= 1 |
| 122 |
if ($slave_gtid_mode == 0) |
| 123 |
{ |
| 124 |
if ($master_gtid_mode >= 2) |
| 125 |
{ |
| 126 |
--let $gtid_modes_compatible= 0 |
| 127 |
} |
| 128 |
} |
| 129 |
if ($slave_gtid_mode == 3) |
| 130 |
{ |
| 131 |
if ($master_gtid_mode <= 1) |
| 132 |
{ |
| 133 |
--let $gtid_modes_compatible= 0 |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
START SLAVE IO_THREAD; |
| 138 |
if ($gtid_modes_compatible) |
| 139 |
{ |
| 140 |
--source include/wait_for_slave_io_to_start.inc |
| 141 |
--source include/stop_slave_io.inc |
| 142 |
} |
| 143 |
if (!$gtid_modes_compatible) |
| 144 |
{ |
| 145 |
--let $slave_io_errno= convert_error(ER_REPLICA_FATAL_ERROR) |
| 146 |
--source include/wait_for_slave_io_error.inc |
| 147 |
} |
| 148 |
|
| 149 |
# Auto_position compatible with slave and/or master |
| 150 |
if ($slave_gtid_mode == 0) |
| 151 |
{ |
| 152 |
--error ER_AUTO_POSITION_REQUIRES_GTID_MODE_NOT_OFF |
| 153 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 1; |
| 154 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 0; |
| 155 |
} |
| 156 |
|
| 157 |
if ($slave_gtid_mode != 0) |
| 158 |
{ |
| 159 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 1; |
| 160 |
START SLAVE IO_THREAD; |
| 161 |
if ($master_gtid_mode != 3) |
| 162 |
{ |
| 163 |
--let $slave_io_errno= convert_error(ER_REPLICA_FATAL_ERROR) |
| 164 |
--source include/wait_for_slave_io_error.inc |
| 165 |
} |
| 166 |
if ($master_gtid_mode == 3) |
| 167 |
{ |
| 168 |
--source include/wait_for_slave_io_to_start.inc |
| 169 |
--source include/stop_slave_io.inc |
| 170 |
} |
| 171 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 0; |
| 172 |
} |
| 173 |
|
| 174 |
--inc $slave_gtid_mode |
| 175 |
} |
| 176 |
--inc $master_gtid_mode |
| 177 |
} |
| 178 |
|
| 179 |
# |
| 180 |
# In all the test cases below for catching an error in sender thread, |
| 181 |
# we follow the steps (1-2) mentioned below. |
| 182 |
# Before the steps, lets look at some theory: |
| 183 |
# |
| 184 |
# 0. The way we report errors in sender (aka dump) thread is this: |
| 185 |
# |
| 186 |
# a) Relay the error in sender thread to receiver thread. |
| 187 |
# |
| 188 |
# b) Receiver thread prefixes 'Got fatal error 1236 from master |
| 189 |
# when reading data from binary log...' to the error that it |
| 190 |
# received from sender thread. Let call this concatenated |
| 191 |
# message '$concated_message' |
| 192 |
# |
| 193 |
# c) Receiver thread reports this error in |
| 194 |
# performance_schema.replication_connection_status as |
| 195 |
# c.1. LAST_ERROR_NUMBER= 1236 |
| 196 |
# c.2. LAST_ERROR_MESSAGE= '$concated_message'. |
| 197 |
# |
| 198 |
# And now the steps: |
| 199 |
# |
| 200 |
# 1. Wait until receiver thread reports error number 1236 in |
| 201 |
# performance_schema.rpelication_connection_status::LAST_ERROR_MESSAGE |
| 202 |
# This is merely a synchronization point for us to wait until |
| 203 |
# the error was generated. This is done using |
| 204 |
# include/wait_for_slave_io_error.inc |
| 205 |
# |
| 206 |
# 2. Check that 1236 was reported for the exact sender thread error |
| 207 |
# that we are testing This is done using include/assert.inc to |
| 208 |
# make sure the correct error messsage was passed from sender |
| 209 |
# thread. |
| 210 |
|
| 211 |
--echo # |
| 212 |
--echo # Test for ER_CANT_REPLICATE_GTID_WITH_GTID_MODE_OFF |
| 213 |
--echo # eng "Cannot replicate GTID-transaction when GTID_MODE = OFF, at file %.512s, position %lld. Found a Gtid_log_event when @@GLOBAL.GTID_MODE = OFF. |
| 214 |
--echo # |
| 215 |
|
| 216 |
--echo # |
| 217 |
--echo # Case 1: Error on Master(sender thread) |
| 218 |
--echo # |
| 219 |
|
| 220 |
--let $rpl_server_numbers= 1 |
| 221 |
--let $rpl_skip_sync= 1 |
| 222 |
--let $rpl_gtid_mode= ON |
| 223 |
--source include/rpl_set_gtid_mode.inc |
| 224 |
|
| 225 |
--source include/rpl_connection_master.inc |
| 226 |
CREATE TABLE t1 (a int); |
| 227 |
|
| 228 |
--let $rpl_server_numbers= 1,2 |
| 229 |
--let $rpl_gtid_mode= OFF |
| 230 |
--source include/rpl_set_gtid_mode.inc |
| 231 |
|
| 232 |
--source include/rpl_connection_slave.inc |
| 233 |
START SLAVE IO_THREAD; |
| 234 |
|
| 235 |
--let $slave_io_errno= 13114 # ER_CANT_REPLICATE_GTID_WITH_GTID_MODE_OFF |
| 236 |
--source include/wait_for_slave_io_error.inc |
| 237 |
|
| 238 |
--let $assert_text= sender thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF. |
| 239 |
--let $assert_cond= COUNT(*) = 1 FROM performance_schema.replication_connection_status WHERE LAST_ERROR_MESSAGE LIKE "%Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF%"; |
| 240 |
--source include/assert.inc |
| 241 |
|
| 242 |
--let $assert_text= Receiver thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF. |
| 243 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 244 |
--let $assert_select= Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF |
| 245 |
--let $assert_only_after= Replica I/O thread for channel '': connected to source |
| 246 |
--let $assert_count= 2 |
| 247 |
--source include/assert_grep.inc |
| 248 |
|
| 249 |
--source include/rpl_connection_master.inc |
| 250 |
DROP TABLE t1; |
| 251 |
|
| 252 |
RESET MASTER; |
| 253 |
--source include/rpl_connection_slave.inc |
| 254 |
RESET SLAVE; |
| 255 |
|
| 256 |
--echo # |
| 257 |
--echo # Case 2: Error on Slave(receiver thread) |
| 258 |
--echo # |
| 259 |
|
| 260 |
--let $rpl_server_numbers= 1,2 |
| 261 |
--let $rpl_skip_sync= 1 |
| 262 |
--let $rpl_gtid_mode= ON |
| 263 |
--source include/rpl_set_gtid_mode.inc |
| 264 |
|
| 265 |
--source include/rpl_connection_slave.inc |
| 266 |
--source include/start_slave.inc |
| 267 |
|
| 268 |
--let $rpl_server_numbers= 2 |
| 269 |
--let $rpl_gtid_mode= OFF |
| 270 |
--source include/rpl_set_gtid_mode.inc |
| 271 |
|
| 272 |
--source include/rpl_connection_master.inc |
| 273 |
CREATE TABLE t2(a int); |
| 274 |
|
| 275 |
--source include/rpl_connection_slave.inc |
| 276 |
|
| 277 |
# Errors in queue_event() are overwritten in SHOW SLAVE STATUS/P_S |
| 278 |
# by (13122 ER_REPLICA_RELAY_LOG_WRITE_FAILURE). |
| 279 |
# So the only place where old error exists is slave error log. |
| 280 |
# Grep error log to look for old error. |
| 281 |
|
| 282 |
--let $slave_io_errno= 13122 # ER_REPLICA_RELAY_LOG_WRITE_FAILURE |
| 283 |
--source include/wait_for_slave_io_error.inc |
| 284 |
|
| 285 |
--let $assert_text= Receiver thread should report - Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF. |
| 286 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 287 |
--let $assert_select= Cannot replicate GTID-transaction when @@GLOBAL.GTID_MODE = OFF |
| 288 |
--let $assert_only_after= Replica receiver thread for channel '': connected to source |
| 289 |
--let $assert_count= 1 |
| 290 |
--source include/assert_grep.inc |
| 291 |
|
| 292 |
--source include/rpl_connection_master.inc |
| 293 |
DROP TABLE t2; |
| 294 |
|
| 295 |
--source include/rpl_connection_slave.inc |
| 296 |
|
| 297 |
--let $rpl_server_numbers= 2 |
| 298 |
--let $rpl_gtid_mode= ON |
| 299 |
--source include/rpl_set_gtid_mode.inc |
| 300 |
|
| 301 |
--source include/start_slave.inc |
| 302 |
|
| 303 |
--echo # |
| 304 |
--echo # Warning: "Detected misconfiguration: replication channel '%.192s' was configured with AUTO_POSITION = 1, but the server was started with --gtid-mode=off. Either reconfigure replication using CHANGE MASTER TO MASTER_AUTO_POSITION = 0 FOR CHANNEL '%.192s', or change GTID_MODE to some value other than OFF, before starting the slave receiver thread." |
| 305 |
--echo # |
| 306 |
|
| 307 |
--let $rpl_server_numbers= 1,2 |
| 308 |
--let $rpl_skip_sync= 1 |
| 309 |
--let $rpl_gtid_mode= ON |
| 310 |
--source include/rpl_set_gtid_mode.inc |
| 311 |
|
| 312 |
--source include/rpl_connection_slave.inc |
| 313 |
--source include/stop_slave.inc |
| 314 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 1; |
| 315 |
|
| 316 |
--let $rpl_server_number=2 |
| 317 |
--let $rpl_start_with_gtids= 0 |
| 318 |
--source include/rpl_restart_server.inc |
| 319 |
|
| 320 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON; |
| 321 |
|
| 322 |
--let $assert_text= While AUTO_POSITION is set, attempt to restart the slave with gtid-mode= off to get ER_STARTING_WITH_GTID_MODE_OFF_AND_AUTO_POSITION. |
| 323 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 324 |
--let $assert_select= Detected misconfiguration: replication channel '' was configured with AUTO_POSITION = 1, but the server was started with --gtid-mode=off |
| 325 |
--let $assert_count= 1 |
| 326 |
--source include/assert_grep.inc |
| 327 |
|
| 328 |
--echo # |
| 329 |
--echo # ER_CANT_USE_AUTO_POSITION_WITH_GTID_MODE_OFF |
| 330 |
--echo # eng "The replication receiver thread for channel '%s' cannot start in AUTO_POSITION mode: this server uses GTID_MODE = OFF." |
| 331 |
--echo # |
| 332 |
|
| 333 |
# This should follow the previous test case of warning for the detected misconfiguration between autposition and gtid-mode. |
| 334 |
|
| 335 |
--error ER_CANT_USE_AUTO_POSITION_WITH_GTID_MODE_OFF |
| 336 |
START SLAVE IO_THREAD; |
| 337 |
|
| 338 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0; |
| 339 |
|
| 340 |
--echo # |
| 341 |
--echo # ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON |
| 342 |
--echo # eng "Cannot replicate anonymous transaction when GTID_MODE = ON, at file %.512s, position %lld." |
| 343 |
|
| 344 |
--echo # |
| 345 |
--echo # Case 1: Error on master(sender thread) |
| 346 |
--echo # |
| 347 |
|
| 348 |
--let $rpl_server_numbers= 1 |
| 349 |
--let $rpl_skip_sync= 1 |
| 350 |
--let $rpl_gtid_mode= OFF |
| 351 |
--source include/rpl_set_gtid_mode.inc |
| 352 |
|
| 353 |
--source include/rpl_connection_master.inc |
| 354 |
CREATE TABLE t3(a int); |
| 355 |
|
| 356 |
--let $rpl_server_numbers= 1,2 |
| 357 |
--let $rpl_gtid_mode= ON |
| 358 |
--source include/rpl_set_gtid_mode.inc |
| 359 |
|
| 360 |
--source include/rpl_connection_slave.inc |
| 361 |
START SLAVE IO_THREAD; |
| 362 |
|
| 363 |
--let $slave_io_errno= 13114 # ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON |
| 364 |
--source include/wait_for_slave_io_error.inc |
| 365 |
|
| 366 |
--let $assert_text= sender thread should report - Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON. |
| 367 |
--let $assert_cond= COUNT(*) = 1 FROM performance_schema.replication_connection_status WHERE LAST_ERROR_MESSAGE LIKE "%Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON%"; |
| 368 |
--source include/assert.inc |
| 369 |
|
| 370 |
--let $assert_text= While gtid-mode=on, slave expects an anonymous event to get ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON. |
| 371 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 372 |
--let $assert_select= Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON |
| 373 |
--let $assert_only_after= Replica receiver thread for channel '': connected to source |
| 374 |
--let $assert_count= 2 |
| 375 |
--source include/assert_grep.inc |
| 376 |
|
| 377 |
--source include/rpl_connection_master.inc |
| 378 |
DROP TABLE t3; |
| 379 |
|
| 380 |
--let $slave_io_errno= convert_error(ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG) |
| 381 |
--source include/rpl_reset.inc |
| 382 |
|
| 383 |
--echo # |
| 384 |
--echo # Case 2: Error on slave(receiver thread) |
| 385 |
--echo # |
| 386 |
|
| 387 |
--let $rpl_server_numbers= 1 |
| 388 |
--let $rpl_gtid_mode= OFF |
| 389 |
--source include/rpl_set_gtid_mode.inc |
| 390 |
|
| 391 |
--source include/rpl_connection_master.inc |
| 392 |
CREATE TABLE t4(a int); |
| 393 |
|
| 394 |
--source include/rpl_connection_slave.inc |
| 395 |
|
| 396 |
--let $slave_io_errno= 13122 # ER_REPLICA_RELAY_LOG_WRITE_FAILURE |
| 397 |
--source include/wait_for_slave_io_error.inc |
| 398 |
|
| 399 |
--let $assert_text= While gtid-mode=on, slave expects an anonymous event to get ER_CANT_REPLICATE_ANONYMOUS_WITH_GTID_MODE_ON. |
| 400 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 401 |
--let $assert_select= Cannot replicate anonymous transaction when @@GLOBAL.GTID_MODE = ON |
| 402 |
--let $assert_only_after= Replica receiver thread for channel '': connected to source |
| 403 |
--let $assert_count= 1 |
| 404 |
--source include/assert_grep.inc |
| 405 |
|
| 406 |
--source include/stop_slave_sql.inc |
| 407 |
|
| 408 |
--let $rpl_server_numbers= 2 |
| 409 |
--let $rpl_skip_sync= 1 |
| 410 |
--let $rpl_gtid_mode= OFF |
| 411 |
--source include/rpl_set_gtid_mode.inc |
| 412 |
|
| 413 |
--source include/rpl_connection_master.inc |
| 414 |
DROP TABLE t4; |
| 415 |
RESET MASTER; |
| 416 |
|
| 417 |
--source include/rpl_connection_slave.inc |
| 418 |
RESET SLAVE; |
| 419 |
--source include/start_slave.inc |
| 420 |
|
| 421 |
--source include/rpl_connection_master.inc |
| 422 |
--source include/sync_slave_sql_with_master.inc |
| 423 |
|
| 424 |
--echo # |
| 425 |
--echo # ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION |
| 426 |
--echo # eng "Cannot replicate anonymous transaction when AUTO_POSITION = 1, at file %.512s, position %lld." |
| 427 |
--echo # |
| 428 |
|
| 429 |
--echo # |
| 430 |
--echo # Case 1: Error on master(sender thread). |
| 431 |
--echo # |
| 432 |
|
| 433 |
--let $rpl_server_numbers= 1,2 |
| 434 |
--let $rpl_skip_sync= 1 |
| 435 |
--let $rpl_gtid_mode= ON |
| 436 |
--source include/rpl_set_gtid_mode.inc |
| 437 |
|
| 438 |
--source include/rpl_connection_master.inc |
| 439 |
CREATE TABLE t5(a int); # gtid1 |
| 440 |
|
| 441 |
# sync here so that we are sure table exists on slave, so we can sync DROP TABLE later. |
| 442 |
--source include/sync_slave_sql_with_master.inc |
| 443 |
--source include/stop_slave.inc |
| 444 |
|
| 445 |
--source include/rpl_connection_master.inc |
| 446 |
# Generate at least one GTID transaction before the anonymous for autoposition |
| 447 |
# to start from here and then discover the anonymous transaction in binary log. |
| 448 |
INSERT INTO t5 VALUES(2); |
| 449 |
|
| 450 |
--let $rpl_server_numbers= 1 |
| 451 |
--let $rpl_skip_sync= 1 |
| 452 |
--let $rpl_gtid_mode= ON_PERMISSIVE |
| 453 |
--source include/rpl_set_gtid_mode.inc |
| 454 |
|
| 455 |
SET @@SESSION.GTID_NEXT = 'ANONYMOUS'; |
| 456 |
INSERT INTO t5 VALUES(1); # anonymous transaction |
| 457 |
|
| 458 |
--let $rpl_server_numbers= 1 |
| 459 |
--let $rpl_gtid_mode= ON |
| 460 |
--source include/rpl_set_gtid_mode.inc |
| 461 |
|
| 462 |
--let $rpl_server_numbers= 2 |
| 463 |
--let $rpl_gtid_mode= ON |
| 464 |
--source include/rpl_set_gtid_mode.inc |
| 465 |
|
| 466 |
--source include/rpl_connection_slave.inc |
| 467 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 1; |
| 468 |
START SLAVE IO_THREAD; |
| 469 |
|
| 470 |
--let $slave_io_errno= 13114 # ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION |
| 471 |
--source include/wait_for_slave_io_error.inc |
| 472 |
|
| 473 |
--let $assert_text= sender thread should report - Cannot replicate anonymous transaction when AUTO_POSITION = 1. |
| 474 |
--let $assert_cond= COUNT(*) = 1 FROM performance_schema.replication_connection_status WHERE LAST_ERROR_MESSAGE LIKE "%Cannot replicate anonymous transaction when AUTO_POSITION = 1%"; |
| 475 |
--source include/assert.inc |
| 476 |
|
| 477 |
--let $assert_text= While AUTO_POSITION is enabled, Master sends an anonymous transaction resulting into ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION. |
| 478 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 479 |
--let $assert_select= Cannot replicate anonymous transaction when AUTO_POSITION = 1 |
| 480 |
--let $assert_count= 2 |
| 481 |
--source include/assert_grep.inc |
| 482 |
|
| 483 |
--let $rpl_server_number=1 |
| 484 |
--let $rpl_start_with_gtids= 0 |
| 485 |
--source include/rpl_restart_server.inc |
| 486 |
|
| 487 |
--source include/rpl_connection_master.inc |
| 488 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON; |
| 489 |
|
| 490 |
--source include/rpl_connection_slave.inc |
| 491 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0; |
| 492 |
|
| 493 |
--let $rpl_server_numbers= 2 |
| 494 |
--let $rpl_gtid_mode= OFF |
| 495 |
--source include/rpl_set_gtid_mode.inc |
| 496 |
|
| 497 |
--source include/rpl_connection_master.inc |
| 498 |
DROP TABLE t5; |
| 499 |
RESET MASTER; |
| 500 |
|
| 501 |
--source include/rpl_connection_slave.inc |
| 502 |
DROP TABLE t5; |
| 503 |
RESET SLAVE; |
| 504 |
|
| 505 |
--let $rpl_skip_sync=0 |
| 506 |
--source include/start_slave.inc |
| 507 |
--source include/rpl_connection_master.inc |
| 508 |
--source include/sync_slave_sql_with_master.inc |
| 509 |
|
| 510 |
--echo # |
| 511 |
--echo # Case 2: Error on Slave(receiver thread). |
| 512 |
--echo # |
| 513 |
|
| 514 |
# Same test as Case 1 but this time we disable the error in sender thread |
| 515 |
# using DBUG_EXECUTE_IF so that receiver thread sees this error now. |
| 516 |
# We next verify that the same error is also caught by receiver thread. |
| 517 |
|
| 518 |
--source include/rpl_connection_master.inc |
| 519 |
SET @debug_saved= @@GLOBAL.DEBUG; |
| 520 |
|
| 521 |
SET GLOBAL DEBUG= "+d,skip_sender_anon_autoposition_error"; |
| 522 |
|
| 523 |
--let $rpl_server_numbers= 1,2 |
| 524 |
--let $rpl_skip_sync= 1 |
| 525 |
--let $rpl_gtid_mode= ON |
| 526 |
--source include/rpl_set_gtid_mode.inc |
| 527 |
|
| 528 |
--source include/rpl_connection_master.inc |
| 529 |
CREATE TABLE t6(a int); # gtid1 |
| 530 |
|
| 531 |
# sync here so that we are sure table exists on slave, so we can sync DROP TABLE later. |
| 532 |
--source include/sync_slave_sql_with_master.inc |
| 533 |
--source include/stop_slave.inc |
| 534 |
|
| 535 |
--source include/rpl_connection_master.inc |
| 536 |
# Generate at least one GTID transaction before the anonymous for autoposition |
| 537 |
# to start from here and then discover the anonymous transaction in binary log. |
| 538 |
INSERT INTO t6 VALUES(2); |
| 539 |
|
| 540 |
--let $rpl_server_numbers= 1 |
| 541 |
--let $rpl_skip_sync= 1 |
| 542 |
--let $rpl_gtid_mode= ON_PERMISSIVE |
| 543 |
--source include/rpl_set_gtid_mode.inc |
| 544 |
|
| 545 |
SET @@SESSION.GTID_NEXT = 'ANONYMOUS'; |
| 546 |
INSERT INTO t6 VALUES(1); # anonymous transaction |
| 547 |
|
| 548 |
--let $rpl_server_numbers= 1 |
| 549 |
--let $rpl_gtid_mode= ON |
| 550 |
--source include/rpl_set_gtid_mode.inc |
| 551 |
|
| 552 |
--let $rpl_server_numbers= 2 |
| 553 |
--let $rpl_gtid_mode= ON |
| 554 |
--source include/rpl_set_gtid_mode.inc |
| 555 |
|
| 556 |
--source include/rpl_connection_slave.inc |
| 557 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 1; |
| 558 |
START SLAVE IO_THREAD; |
| 559 |
|
| 560 |
--let $slave_io_errno= 13122 # ER_REPLICA_RELAY_LOG_WRITE_FAILURE |
| 561 |
--source include/wait_for_slave_io_error.inc |
| 562 |
|
| 563 |
--let $assert_text= While AUTO_POSITION is enabled, Master sends an anonymous transaction resulting into ER_CANT_REPLICATE_ANONYMOUS_WITH_AUTO_POSITION. |
| 564 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 565 |
--let $assert_select= Cannot replicate anonymous transaction when AUTO_POSITION = 1 |
| 566 |
--let $assert_count= 1 |
| 567 |
--source include/assert_grep.inc |
| 568 |
|
| 569 |
--source include/rpl_connection_slave.inc |
| 570 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0; |
| 571 |
|
| 572 |
--let $rpl_server_numbers= 1,2 |
| 573 |
--let $rpl_gtid_mode= OFF |
| 574 |
--source include/rpl_set_gtid_mode.inc |
| 575 |
|
| 576 |
--source include/rpl_connection_master.inc |
| 577 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 578 |
SET DEBUG_SYNC= 'RESET'; |
| 579 |
DROP TABLE t6; |
| 580 |
RESET MASTER; |
| 581 |
|
| 582 |
--source include/rpl_connection_slave.inc |
| 583 |
RESET SLAVE; |
| 584 |
|
| 585 |
--let $rpl_skip_sync=0 |
| 586 |
--source include/start_slave.inc |
| 587 |
--source include/rpl_connection_master.inc |
| 588 |
--source include/sync_slave_sql_with_master.inc |
| 589 |
|
| 590 |
# It is enough to run this test on 1 server, no replication required. |
| 591 |
|
| 592 |
--echo # |
| 593 |
--echo # Verify the behaviour when rotate fails while setting gtid_mode. |
| 594 |
--echo # |
| 595 |
|
| 596 |
--source include/rpl_connection_slave.inc |
| 597 |
--source include/start_slave.inc |
| 598 |
|
| 599 |
--source include/rpl_connection_master.inc |
| 600 |
call mtr.add_suppression("Could not open * for logging"); |
| 601 |
--source include/sync_slave_sql_with_master.inc |
| 602 |
|
| 603 |
--source include/stop_slave.inc |
| 604 |
|
| 605 |
SET @debug_saved= @@GLOBAL.DEBUG; |
| 606 |
SET GLOBAL DEBUG= "+d,fault_injection_new_file_rotate_event"; |
| 607 |
|
| 608 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 609 |
|
| 610 |
--error ER_ERROR_ON_WRITE |
| 611 |
SET @@GLOBAL.GTID_MODE= OFF_PERMISSIVE; |
| 612 |
|
| 613 |
# Cleanup |
| 614 |
SET @@GLOBAL.GTID_MODE= OFF; |
| 615 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 616 |
--eval SET GLOBAL binlog_error_action= $saved_binlog_error_action |
| 617 |
|
| 618 |
# Binlog was closed as a result of the error, restart server to recover. |
| 619 |
--let $rpl_server_number= 1 |
| 620 |
--source include/rpl_restart_server.inc |
| 621 |
|
| 622 |
--source include/rpl_connection_master.inc |
| 623 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON; |
| 624 |
|
| 625 |
--echo # |
| 626 |
--echo # ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON |
| 627 |
--echo # generated when re-acquiring anonymous ownership |
| 628 |
--echo # |
| 629 |
|
| 630 |
--source include/rpl_connection_master.inc |
| 631 |
SET GTID_NEXT='ANONYMOUS'; |
| 632 |
CREATE TABLE t7(a int); |
| 633 |
|
| 634 |
--let $rpl_server_numbers= 1 |
| 635 |
--let $rpl_skip_sync= 1 |
| 636 |
--let $rpl_gtid_mode= ON |
| 637 |
--source include/rpl_set_gtid_mode.inc |
| 638 |
|
| 639 |
--error ER_CANT_SET_GTID_NEXT_TO_ANONYMOUS_WHEN_GTID_MODE_IS_ON |
| 640 |
INSERT INTO t7 values (1); |
| 641 |
|
| 642 |
SET GTID_NEXT='AUTOMATIC'; |
| 643 |
DROP TABLE t7; |
| 644 |
|
| 645 |
RESET MASTER; |
| 646 |
--let $rpl_server_numbers= 1 |
| 647 |
--let $rpl_skip_sync= 1 |
| 648 |
--let $rpl_gtid_mode= OFF |
| 649 |
--source include/rpl_set_gtid_mode.inc |
| 650 |
|
| 651 |
|
| 652 |
# Get rid of the manually generated slave error log file. |
| 653 |
#--remove_file $MYSQLTEST_VARDIR/tmp/slave-rpl-gtid-mode.err |
| 654 |
|
| 655 |
--echo # |
| 656 |
--echo # Error generated if master has an unknown gtid_mode |
| 657 |
--echo # |
| 658 |
|
| 659 |
--connection slave |
| 660 |
--source include/stop_slave.inc |
| 661 |
RESET SLAVE; |
| 662 |
SET @@GLOBAL.DEBUG= '+d,simulate_source_has_unknown_gtid_mode'; |
| 663 |
START SLAVE IO_THREAD; |
| 664 |
--let $slave_io_errno= convert_error(ER_REPLICA_FATAL_ERROR) |
| 665 |
--let $show_slave_io_error= 1 |
| 666 |
--source include/wait_for_slave_io_error.inc |
| 667 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 668 |
|
| 669 |
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE; |
| 670 |
RESET SLAVE; |
| 671 |
|
| 672 |
--echo # |
| 673 |
--echo # ER_CANT_SET_GTID_MODE generated because AUTO_POSITION = 1. |
| 674 |
--echo # |
| 675 |
|
| 676 |
--let $rpl_server_numbers= 1 |
| 677 |
--let $rpl_gtid_mode= ON |
| 678 |
--let $rpl_skip_sync= 1 |
| 679 |
--source include/rpl_set_gtid_mode.inc |
| 680 |
|
| 681 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 1; |
| 682 |
--error ER_CANT_SET_GTID_MODE |
| 683 |
SET @@GLOBAL.GTID_MODE = OFF; |
| 684 |
|
| 685 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 0; |
| 686 |
SET @@GLOBAL.GTID_MODE = OFF; |
| 687 |
--let $rpl_server_numbers= 1 |
| 688 |
--let $rpl_gtid_mode= OFF |
| 689 |
--source include/rpl_set_gtid_mode.inc |
| 690 |
|
| 691 |
--source include/rpl_connection_master.inc |
| 692 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = OFF; |
| 693 |
--source include/rpl_connection_slave.inc |
| 694 |
SET GLOBAL ENFORCE_GTID_CONSISTENCY = OFF; |
| 695 |
|
| 696 |
--let $rpl_skip_sync= 0 |
| 697 |
--let $rpl_only_running_threads= 1 |
| 698 |
--source include/rpl_end.inc |