| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test will generate all expected transaction boundary parser warnings. |
| 4 |
# |
| 5 |
# It will disable GTID auto positioning and will make the IO thread to |
| 6 |
# retrieve an unexpected event by stopping the IO thread, changing the |
| 7 |
# master.info file manually and restarting the slave. |
| 8 |
# |
| 9 |
# ==== Related Bugs and Worklogs ==== |
| 10 |
# |
| 11 |
# BUG#17943188: SHOW SLAVE STATUS/RETRIEVED_GTID_SET MAY HAVE PARTIAL TRX OR |
| 12 |
# MISS COMPLETE TRX |
| 13 |
# |
| 14 |
|
| 15 |
# This test should run only on debug build |
| 16 |
--source include/have_debug.inc |
| 17 |
--source include/no_valgrind_without_big.inc |
| 18 |
# This test uses debug sync to stop the IO thread in the middle of a transaction |
| 19 |
--source include/have_debug_sync.inc |
| 20 |
|
| 21 |
# Error message suppression |
| 22 |
call mtr.add_suppression("Statement is unsafe because it is being used inside a XA transaction"); |
| 23 |
--source include/force_myisam_default.inc |
| 24 |
--source include/have_myisam.inc |
| 25 |
--source include/have_binlog_format_statement.inc |
| 26 |
--source include/set_privilege_checks_user_as_system_user.inc |
| 27 |
--source include/master-slave.inc |
| 28 |
|
| 29 |
--source include/rpl_connection_slave.inc |
| 30 |
# Error messages suppression on slave |
| 31 |
call mtr.add_suppression("An unexpected event sequence was detected by the IO thread"); |
| 32 |
call mtr.add_suppression("GTID_LOG_EVENT .* is not expected in an event stream"); |
| 33 |
call mtr.add_suppression("QUERY.* is not expected in an event stream"); |
| 34 |
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since*"); |
| 35 |
# Disable GTID auto positioning |
| 36 |
--source include/stop_slave.inc |
| 37 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0; |
| 38 |
#--source include/start_slave.inc |
| 39 |
|
| 40 |
--source include/rpl_connection_master.inc |
| 41 |
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 42 |
# Create a DDL with a USER_VAR event |
| 43 |
SET @var= 10; |
| 44 |
CREATE EVENT ev1 ON SCHEDULE EVERY @var HOUR DO INSERT INTO t1 VALUES (0); |
| 45 |
# Create a transactional and a non-transactional table with data |
| 46 |
CREATE TABLE t1 (c1 INT) ENGINE= InnoDB; |
| 47 |
INSERT INTO t1 VALUES (1); |
| 48 |
CREATE TABLE t2 (c1 INT) ENGINE= MyISAM; |
| 49 |
INSERT INTO t2 VALUES (1); |
| 50 |
#XA transaction |
| 51 |
--eval XA START 'xa_trx' |
| 52 |
INSERT INTO t1 VALUES(2); |
| 53 |
--eval XA END 'xa_trx' |
| 54 |
--eval XA PREPARE 'xa_trx' |
| 55 |
--eval XA ROLLBACK 'xa_trx' |
| 56 |
|
| 57 |
# Display all binlog events generated by the master |
| 58 |
--let $keep_gtid_events= 1 |
| 59 |
--replace_result $master_uuid MASTER_UUID |
| 60 |
# Make the non-GTID binlog event stream just like GTID one |
| 61 |
--let $mask_anonymous_gtid_events= 1 |
| 62 |
--source include/show_binlog_events.inc |
| 63 |
|
| 64 |
### |
| 65 |
### Set some parameter that will be used in the event count loop |
| 66 |
### |
| 67 |
--let $expected_amount_of_events= 26 |
| 68 |
--let $event_to_remove_debug_point= $expected_amount_of_events |
| 69 |
--dec $event_to_remove_debug_point |
| 70 |
|
| 71 |
# We always start counting by the second event, skipping slave's FD |
| 72 |
--let $event_counter= 2 |
| 73 |
--let $master_2nd_event_pos= query_get_value(SHOW BINLOG EVENTS IN 'master-bin.000001', Pos, 2) |
| 74 |
--let $master_pos= $master_2nd_event_pos |
| 75 |
|
| 76 |
### |
| 77 |
### Prepare to count the events queued the the IO thread |
| 78 |
### |
| 79 |
--source include/rpl_connection_slave.inc |
| 80 |
# Get the master.info file path (the $MYSQLD_SLAVE_DATADIR) |
| 81 |
--let $MYSQLD_SLAVE_DATADIR= `select @@datadir` |
| 82 |
--let $debug_point= pause_on_queuing_event |
| 83 |
--source include/add_debug_point.inc |
| 84 |
# Start the IO thread to start receiving events from master |
| 85 |
START SLAVE IO_THREAD; |
| 86 |
# Disabling query log during queue event counting |
| 87 |
--disable_query_log |
| 88 |
### |
| 89 |
### Counting events and generating master.info.backup files |
| 90 |
### |
| 91 |
while ($event_counter <= $expected_amount_of_events) |
| 92 |
{ |
| 93 |
# We need to wait for an event to be queued until the expected amount |
| 94 |
if ($event_counter < $expected_amount_of_events) |
| 95 |
{ |
| 96 |
SET DEBUG_SYNC='now WAIT_FOR reached_queuing_event'; |
| 97 |
} |
| 98 |
# For the last expected event we can just sync IO thread as there is |
| 99 |
# no more events to retrieved after it. |
| 100 |
if ($event_counter == $expected_amount_of_events) |
| 101 |
{ |
| 102 |
--source include/rpl_connection_master.inc |
| 103 |
--source include/sync_slave_io_with_master.inc |
| 104 |
} |
| 105 |
# For all retrieved events after the PREVIOUS_GTIDs |
| 106 |
if ($event_counter > 2) |
| 107 |
{ |
| 108 |
--echo # This is the event #$event_counter of current slave relay log file |
| 109 |
--let $master_pos= query_get_value(SHOW RELAYLOG EVENTS IN 'slave-relay-bin.000002' FROM $master_pos, Pos, 2) |
| 110 |
--let $binlog_start= $master_pos |
| 111 |
--let $binlog_file= slave-relay-bin.000002 |
| 112 |
--source include/show_relaylog_events.inc |
| 113 |
} |
| 114 |
# We can remove the debug point after reaching the event before |
| 115 |
# the last expected event |
| 116 |
if ($event_counter == $event_to_remove_debug_point) |
| 117 |
{ |
| 118 |
--source include/remove_debug_point.inc |
| 119 |
} |
| 120 |
# Generate a master.info.backup file pointing to the event to be queued |
| 121 |
--copy_file $MYSQLD_SLAVE_DATADIR/master.info $MYSQLD_SLAVE_DATADIR/master.backup.$event_counter |
| 122 |
# Let the event be queued and the IO thread to retrieve the next one |
| 123 |
if ($event_counter < $expected_amount_of_events) |
| 124 |
{ |
| 125 |
SET DEBUG_SYNC= 'now SIGNAL continue_queuing_event'; |
| 126 |
} |
| 127 |
--inc $event_counter |
| 128 |
} |
| 129 |
--enable_query_log |
| 130 |
|
| 131 |
### |
| 132 |
### Setup common GREP environment variables to display mysql error log entries |
| 133 |
### with the expected errors. |
| 134 |
### |
| 135 |
# File to GREP |
| 136 |
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err |
| 137 |
# Show entries only after the last occurrence of the following pattern |
| 138 |
--let $assert_only_after=.* \[Note\] \[[^]]*\] \[[^]]*\] Shutting down replica threads |
| 139 |
# Each test will log only one warning line |
| 140 |
--let $assert_count= 1 |
| 141 |
|
| 142 |
--echo |
| 143 |
--echo # |
| 144 |
--echo # Case 1: GTID_LOG_EVENT is not expected in an event stream after a GTID_LOG_EVENT. |
| 145 |
--echo # |
| 146 |
--let $stop_after= 8 |
| 147 |
--let $restart_at= 8 |
| 148 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 149 |
# Assert that there is the expected warning log line but just after the last restart |
| 150 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] GTID_LOG_EVENT .* is not expected.* |
| 151 |
--let $assert_text= Case 1 found the expected warning line in the error log. |
| 152 |
--source include/assert_grep.inc |
| 153 |
|
| 154 |
--echo |
| 155 |
--echo # |
| 156 |
--echo # Case 2: GTID_LOG_EVENT is not expected in an event stream in the middle of a DDL. |
| 157 |
--echo # |
| 158 |
--let $stop_after= 6 |
| 159 |
--let $restart_at= 8 |
| 160 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 161 |
# Assert that there is the expected warning log line but just after the last restart |
| 162 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] GTID_LOG_EVENT .* is not expected.* |
| 163 |
--let $assert_text= Case 2 found the expected warning line in the error log. |
| 164 |
--source include/assert_grep.inc |
| 165 |
|
| 166 |
--echo |
| 167 |
--echo # |
| 168 |
--echo # Case 3: GTID_LOG_EVENT is not expected in an event stream in the middle of a DML. |
| 169 |
--echo # |
| 170 |
--let $stop_after= 11 |
| 171 |
--let $restart_at= 10 |
| 172 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 173 |
# Assert that there is the expected warning log line but just after the last restart |
| 174 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] GTID_LOG_EVENT .* is not expected.* |
| 175 |
--let $assert_text= Case 3 found the expected warning line in the error log. |
| 176 |
--source include/assert_grep.inc |
| 177 |
|
| 178 |
--echo |
| 179 |
--echo # |
| 180 |
--echo # Case 4: QUERY(BEGIN) is not expected in an event stream in the middle of a DDL. |
| 181 |
--echo # |
| 182 |
--let $stop_after= 6 |
| 183 |
--let $restart_at= 11 |
| 184 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 185 |
# Assert that there is the expected warning log line but just after the last restart |
| 186 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(BEGIN\) is not expected.* |
| 187 |
--let $assert_text= Case 4 found the expected warning line in the error log. |
| 188 |
--source include/assert_grep.inc |
| 189 |
|
| 190 |
--echo |
| 191 |
--echo # |
| 192 |
--echo # Case 5: QUERY(BEGIN) is not expected in an event stream in the middle of a DML. |
| 193 |
--echo # |
| 194 |
--let $stop_after= 11 |
| 195 |
--let $restart_at= 11 |
| 196 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 197 |
# Assert that there is the expected warning log line but just after the last restart |
| 198 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(BEGIN\) is not expected.* |
| 199 |
--let $assert_text= Case 5 found the expected warning line in the error log. |
| 200 |
--source include/assert_grep.inc |
| 201 |
|
| 202 |
--echo |
| 203 |
--echo # |
| 204 |
--echo # Case 6.a: QUERY(COMMIT or ROLLBACK) or XID_LOG_EVENT is not expected in an event stream outside a transaction. |
| 205 |
--echo # |
| 206 |
--let $stop_after= 9 |
| 207 |
--let $restart_at= 13 |
| 208 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 209 |
# Assert that there is the expected warning log line but just after the last restart |
| 210 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(COMMIT or ROLLBACK\) or XID_LOG_EVENT is not expected.* |
| 211 |
--let $assert_text= Case 6.a found the expected warning line in the error log. |
| 212 |
--source include/assert_grep.inc |
| 213 |
|
| 214 |
--echo |
| 215 |
--echo # |
| 216 |
--echo # Case 6.b: QUERY(COMMIT or ROLLBACK) or XID_LOG_EVENT is not expected in an event stream outside a transaction. |
| 217 |
--echo # |
| 218 |
--let $stop_after= 9 |
| 219 |
--let $restart_at= 19 |
| 220 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 221 |
# Assert that there is the expected warning log line but just after the last restart |
| 222 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(COMMIT or ROLLBACK\) or XID_LOG_EVENT is not expected.* |
| 223 |
--let $assert_text= Case 6.b found the expected warning line in the error log. |
| 224 |
--source include/assert_grep.inc |
| 225 |
|
| 226 |
--echo |
| 227 |
--echo # |
| 228 |
--echo # Case 7.a: QUERY(COMMIT or ROLLBACK) or XID_LOG_EVENT is not expected in an event stream after a GTID_LOG_EVENT. |
| 229 |
--echo # |
| 230 |
--let $stop_after= 8 |
| 231 |
--let $restart_at= 13 |
| 232 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 233 |
# Assert that there is the expected warning log line but just after the last restart |
| 234 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(COMMIT or ROLLBACK\) or XID_LOG_EVENT is not expected.* |
| 235 |
--let $assert_text= Case 7.a found the expected warning line in the error log. |
| 236 |
--source include/assert_grep.inc |
| 237 |
|
| 238 |
--echo |
| 239 |
--echo # |
| 240 |
--echo # Case 7.b: QUERY(COMMIT or ROLLBACK) or XID_LOG_EVENT is not expected in an event stream after a GTID_LOG_EVENT. |
| 241 |
--echo # |
| 242 |
--let $stop_after= 8 |
| 243 |
--let $restart_at= 19 |
| 244 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 245 |
# Assert that there is the expected warning log line but just after the last restart |
| 246 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(COMMIT or ROLLBACK\) or XID_LOG_EVENT is not expected.* |
| 247 |
--let $assert_text= Case 7.b found the expected warning line in the error log. |
| 248 |
--source include/assert_grep.inc |
| 249 |
|
| 250 |
--echo |
| 251 |
--echo # |
| 252 |
--echo # Case 8.a: QUERY(COMMIT or ROLLBACK) or XID_LOG_EVENT is not expected in an event stream in the middle of a DDL. |
| 253 |
--echo # |
| 254 |
--let $stop_after= 6 |
| 255 |
--let $restart_at= 13 |
| 256 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 257 |
# Assert that there is the expected warning log line but just after the last restart |
| 258 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(COMMIT or ROLLBACK\) or XID_LOG_EVENT is not expected.* |
| 259 |
--let $assert_text= Case 8.a found the expected warning line in the error log. |
| 260 |
--source include/assert_grep.inc |
| 261 |
|
| 262 |
--echo |
| 263 |
--echo # |
| 264 |
--echo # Case 8.b: QUERY(COMMIT or ROLLBACK) or XID_LOG_EVENT is not expected in an event stream in the middle of a DDL. |
| 265 |
--echo # |
| 266 |
--let $stop_after= 6 |
| 267 |
--let $restart_at= 19 |
| 268 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 269 |
# Assert that there is the expected warning log line but just after the last restart |
| 270 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(COMMIT or ROLLBACK\) or XID_LOG_EVENT is not expected.* |
| 271 |
--let $assert_text= Case 8.b found the expected warning line in the error log. |
| 272 |
--source include/assert_grep.inc |
| 273 |
|
| 274 |
--echo |
| 275 |
--echo # |
| 276 |
--echo # Case 9.a: QUERY(XA ROLLBACK) is not expected in an event stream in the middle of a DDL. |
| 277 |
--echo # |
| 278 |
--let $stop_after= 6 |
| 279 |
--let $restart_at= 26 |
| 280 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 281 |
# Assert that there is the expected warning log line but just after the last restart |
| 282 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(XA ROLLBACK\) is not expected.* |
| 283 |
--let $assert_text= Case 9.a found the expected warning line in the error log. |
| 284 |
--source include/assert_grep.inc |
| 285 |
|
| 286 |
--echo |
| 287 |
--echo # |
| 288 |
--echo # Case 9.b: QUERY(XA ROLLBACK) is not expected in an event stream outside a transaction. |
| 289 |
--echo # |
| 290 |
--let $stop_after= 9 |
| 291 |
--let $restart_at= 26 |
| 292 |
--source extra/rpl_tests/rpl_trx_boundary_parser_warning.inc |
| 293 |
# Assert that there is the expected warning log line but just after the last restart |
| 294 |
--let $assert_select=.* \[Warning\] \[[^]]*\] \[[^]]*\] QUERY\(XA ROLLBACK\) is not expected.* |
| 295 |
--let $assert_text= Case 9.b found the expected warning line in the error log. |
| 296 |
--source include/assert_grep.inc |
| 297 |
|
| 298 |
--echo |
| 299 |
--echo # |
| 300 |
--echo # Prepare the slave to correctly replicate again after the test case |
| 301 |
--echo # |
| 302 |
# Restart the slave |
| 303 |
--let $rpl_server_number= 2 |
| 304 |
--let $rpl_force_stop=0 |
| 305 |
--source include/rpl_stop_server.inc |
| 306 |
--source include/rpl_start_server.inc |
| 307 |
|
| 308 |
# Reset the slave and enable GTID auto positioning if needed |
| 309 |
--source include/rpl_connection_slave.inc |
| 310 |
--source include/stop_slave.inc |
| 311 |
--disable_warnings |
| 312 |
DROP TABLE IF EXISTS t1, t2; |
| 313 |
--enable_warnings |
| 314 |
RESET MASTER; |
| 315 |
RESET SLAVE; |
| 316 |
if ($use_gtids) |
| 317 |
{ |
| 318 |
--disable_query_log |
| 319 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 1; |
| 320 |
--enable_query_log |
| 321 |
} |
| 322 |
--source include/start_slave.inc |
| 323 |
|
| 324 |
### |
| 325 |
### Cleanup |
| 326 |
### |
| 327 |
# Remove the master.info.backup files |
| 328 |
--let $event_counter= 2 |
| 329 |
while ($event_counter <= $expected_amount_of_events) |
| 330 |
{ |
| 331 |
--remove_file $MYSQLD_SLAVE_DATADIR/master.backup.$event_counter |
| 332 |
--inc $event_counter |
| 333 |
} |
| 334 |
# Drop the created tables |
| 335 |
--source include/rpl_connection_master.inc |
| 336 |
DROP TABLE t1, t2; |
| 337 |
DROP EVENT ev1; |
| 338 |
|
| 339 |
--source include/rpl_end.inc |