Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_gtid_skip_with_parser_error.test

raw
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 --let $rpl_skip_start_slave = 1
51 --source include/set_privilege_checks_user_as_system_user.inc
52 --source include/not_rpl_gtid_only.inc
53 --source include/master-slave.inc
54
55 --let $MASTER_DATADIR= `select @@datadir`
56
57 # Restart the master to make it use the 5.6 binary log file as its own.
58 --let $rpl_server_number= 1
59 --source include/rpl_stop_server.inc
60 --remove_file $MASTER_DATADIR/master-bin.000001
61 --copy_file std_data/binlog_56_gtid_reserved_word.000001 $MASTER_DATADIR/master-bin.000001
62 --source include/rpl_start_server.inc
63
64 # Assert that all 6 transactions are assumed as already applied.
65 --let $assert_text= All transactions are assumed as applied on master
66 --let $assert_cond= "[SELECT @@GLOBAL.gtid_executed]" = "11111111-1111-1111-1111-111111111111:1-6"
67 --source include/assert.inc
68
69 # Start and sync slave's receiver thread
70 --source include/rpl_connection_slave.inc
71 --source include/start_slave_io.inc
72 --source include/rpl_connection_master.inc
73 --source include/sync_slave_io_with_master.inc
74
75 # Start slave's applier thread. It should stop with ER_PARSE_ERROR.
76 START SLAVE SQL_THREAD;
77 --let $slave_sql_errno= convert_error(ER_PARSE_ERROR)
78 --source include/wait_for_slave_sql_error.inc
79
80 # Assert that only 1st transaction is applied.
81 --let $assert_text= Only 1st transaction is applied on slave
82 --let $assert_cond= "[SELECT @@GLOBAL.gtid_executed]" = "11111111-1111-1111-1111-111111111111:1"
83 --source include/assert.inc
84
85 # Prepare GTID auto skip of offending transactions.
86 SET GTID_NEXT='11111111-1111-1111-1111-111111111111:2';
87 BEGIN;
88 COMMIT;
89
90 SET GTID_NEXT='11111111-1111-1111-1111-111111111111:3';
91 BEGIN;
92 COMMIT;
93
94 SET GTID_NEXT='11111111-1111-1111-1111-111111111111:4';
95 BEGIN;
96 COMMIT;
97
98 SET GTID_NEXT='11111111-1111-1111-1111-111111111111:6';
99 BEGIN;
100 COMMIT;
101
102 SET GTID_NEXT=AUTOMATIC;
103
104 # Restart applier thread that shall sync without issues.
105 --source include/start_slave_sql.inc
106 --source include/sync_slave_sql_with_io.inc
107 CALL mtr.add_suppression("The replica coordinator and worker threads are stopped");
108 --source include/rpl_end.inc