|
| 1 | +# ==== Purpose ==== |
| 2 | +# |
| 3 | +# Test that GTID auto skip works even when replication applier is applying |
| 4 | +# events that would lead to ER_PARSE_ERROR. |
| 5 | +# |
| 6 | +# For this test case a binary log file was generated in MySQL 5.6 creating |
| 7 | +# a table with a name that is a reserved word in MySQL 5.7+. |
| 8 | +# |
| 9 | +# Replicating the binary log to a 5.7+ slave shall make the applier thread |
| 10 | +# to stop once reaching the offending transaction. |
| 11 | +# |
| 12 | +# Supposing a DBA/operator fixed the issue manually and the GTID of the |
| 13 | +# offending transaction was committed so the replicated one shall be skipped |
| 14 | +# by GTID auto skip functionality, restarting the slave applier thread shall |
| 15 | +# not hit errors for this transaction anymore. |
| 16 | +# |
| 17 | +# The binary log file generated in MySQL 5.6 has the following content: |
| 18 | +# |
| 19 | +#+-------------------+------+----------------+-----------+-------------+-------------------------------------------------------------------+ |
| 20 | +#| Log_name | Pos | Event_type | Server_id | End_log_pos | Info | |
| 21 | +#+-------------------+------+----------------+-----------+-------------+-------------------------------------------------------------------+ |
| 22 | +#| master-bin.000001 | 4 | Format_desc | 1 | 120 | Server ver: 5.6.41-debug-log, Binlog ver: 4 | |
| 23 | +#| master-bin.000001 | 120 | Previous_gtids | 1 | 151 | | |
| 24 | +#| master-bin.000001 | 151 | Gtid | 1 | 199 | SET @@SESSION.GTID_NEXT= '11111111-1111-1111-1111-111111111111:1' | |
| 25 | +#| master-bin.000001 | 199 | Query | 1 | 308 | use `test`; CREATE TABLE t1 (a int PRIMARY KEY) | |
| 26 | +#| master-bin.000001 | 308 | Gtid | 1 | 356 | SET @@SESSION.GTID_NEXT= '11111111-1111-1111-1111-111111111111:2' | |
| 27 | +#| master-bin.000001 | 356 | Query | 1 | 458 | use `test`; CREATE TABLE GENERATED LIKE test.t1 | |
| 28 | +#| master-bin.000001 | 458 | Gtid | 1 | 506 | SET @@SESSION.GTID_NEXT= '11111111-1111-1111-1111-111111111111:3' | |
| 29 | +#| master-bin.000001 | 506 | Query | 1 | 585 | BEGIN | |
| 30 | +#| master-bin.000001 | 585 | Query | 1 | 701 | use `test`; INSERT INTO GENERATED VALUES (1), (2), (3) | |
| 31 | +#| master-bin.000001 | 701 | Query | 1 | 781 | COMMIT | |
| 32 | +#| master-bin.000001 | 781 | Gtid | 1 | 829 | SET @@SESSION.GTID_NEXT= '11111111-1111-1111-1111-111111111111:4' | |
| 33 | +#| master-bin.000001 | 829 | Query | 1 | 901 | BEGIN | |
| 34 | +#| master-bin.000001 | 901 | Table_map | 1 | 953 | table_id: 75 (test.GENERATED) | |
| 35 | +#| master-bin.000001 | 953 | Write_rows | 1 | 993 | table_id: 75 flags: STMT_END_F | |
| 36 | +#| master-bin.000001 | 993 | Query | 1 | 1066 | COMMIT | |
| 37 | +#| master-bin.000001 | 1066 | Gtid | 1 | 1114 | SET @@SESSION.GTID_NEXT= '11111111-1111-1111-1111-111111111111:5' | |
| 38 | +#| master-bin.000001 | 1114 | Query | 1 | 1229 | use `test`; DROP TABLE `t1` /* generated by server */ | |
| 39 | +#| master-bin.000001 | 1229 | Gtid | 1 | 1277 | SET @@SESSION.GTID_NEXT= '11111111-1111-1111-1111-111111111111:6' | |
| 40 | +#| master-bin.000001 | 1277 | Query | 1 | 1399 | use `test`; DROP TABLE `GENERATED` /* generated by server */ | |
| 41 | +#+-------------------+------+----------------+-----------+-------------+-------------------------------------------------------------------+ |
| 42 | +# |
| 43 | +# ==== Related Bugs and Worklogs ==== |
| 44 | +# |
| 45 | +# BUG#27638268 GTID AUTO SKIP DOES NOT WORK FOR QUERIES WITH PARSER ERRORS |
| 46 | +# |
| 47 | + |
| 48 | +# This test case is not compatible with SBR. |
| 49 | +--source include/have_binlog_format_mixed_or_row.inc |
| 50 | +--source include/have_gtid.inc |
| 51 | +--let $rpl_skip_start_slave = 1 |
| 52 | +--source include/master-slave.inc |
| 53 | + |
| 54 | +--let $MASTER_DATADIR= `select @@datadir` |
| 55 | + |
| 56 | +# Restart the master to make it use the 5.6 binary log file as its own. |
| 57 | +--let $rpl_server_number= 1 |
| 58 | +--source include/rpl_stop_server.inc |
| 59 | +--remove_file $MASTER_DATADIR/master-bin.000001 |
| 60 | +--copy_file std_data/binlog_56_gtid_reserved_word.000001 $MASTER_DATADIR/master-bin.000001 |
| 61 | +--source include/rpl_start_server.inc |
| 62 | + |
| 63 | +# Assert that all 6 transactions are assumed as already applied. |
| 64 | +--let $assert_text= All transactions are assumed as applied on master |
| 65 | +--let $assert_cond= "[SELECT @@GLOBAL.gtid_executed]" = "11111111-1111-1111-1111-111111111111:1-6" |
| 66 | +--source include/assert.inc |
| 67 | + |
| 68 | +# Start and sync slave's receiver thread |
| 69 | +--source include/rpl_connection_slave.inc |
| 70 | +--source include/start_slave_io.inc |
| 71 | +--source include/rpl_connection_master.inc |
| 72 | +--source include/sync_slave_io_with_master.inc |
| 73 | + |
| 74 | +# Start slave's applier thread. It should stop with ER_PARSE_ERROR. |
| 75 | +START SLAVE SQL_THREAD; |
| 76 | +--let $slave_sql_errno= convert_error(ER_PARSE_ERROR) |
| 77 | +--source include/wait_for_slave_sql_error.inc |
| 78 | + |
| 79 | +# Assert that only 1st transaction is applied. |
| 80 | +--let $assert_text= Only 1st transaction is applied on slave |
| 81 | +--let $assert_cond= "[SELECT @@GLOBAL.gtid_executed]" = "11111111-1111-1111-1111-111111111111:1" |
| 82 | +--source include/assert.inc |
| 83 | + |
| 84 | +# Prepare GTID auto skip of offending transactions. |
| 85 | +SET GTID_NEXT='11111111-1111-1111-1111-111111111111:2'; |
| 86 | +BEGIN; |
| 87 | +COMMIT; |
| 88 | + |
| 89 | +SET GTID_NEXT='11111111-1111-1111-1111-111111111111:3'; |
| 90 | +BEGIN; |
| 91 | +COMMIT; |
| 92 | + |
| 93 | +SET GTID_NEXT='11111111-1111-1111-1111-111111111111:4'; |
| 94 | +BEGIN; |
| 95 | +COMMIT; |
| 96 | + |
| 97 | +SET GTID_NEXT='11111111-1111-1111-1111-111111111111:6'; |
| 98 | +BEGIN; |
| 99 | +COMMIT; |
| 100 | + |
| 101 | +SET GTID_NEXT=AUTOMATIC; |
| 102 | + |
| 103 | +# Restart applier thread that shall sync without issues. |
| 104 | +--source include/start_slave_sql.inc |
| 105 | +--source include/sync_slave_sql_with_io.inc |
| 106 | +CALL mtr.add_suppression("The slave coordinator and worker threads are stopped"); |
| 107 | +--source include/rpl_end.inc |
0 commit comments