Debian Codegraph @

mysql-test/suite/rpl/t/rpl_gtid_header_valid.test

raw
1 #
2 # This test ensures that, when a GTID event is constructed by reading its
3 # content from a binlog file, the reader (e.g. replica, in this test) cannot
4 # read beyond the length of the GTID event. That is, we ensure that the
5 # structure indicated by its flags and extra_flags are consistent with the
6 # actual content of the event.
7 #
8 # To spoof a broken GTID log event, we use the DEBUG_DBUG mechanism to inject
9 # the master to write invalid GTID events for each flag. The transaction is
10 # given a commit id to ensure the event is not shorter than GTID_HEADER_LEN,
11 # which would result in zero padding up to GTID_HEADER_LEN.
12 #
13 #
14 # References:
15 # MDEV-33672: Gtid_log_event Construction from File Should Ensure Event
16 # Length When Using Extra Flags
17 #
18
19 --source include/have_debug.inc
20
21 # GTID event extra_flags are format independent
22 --source include/have_binlog_format_row.inc
23 --source include/have_innodb.inc
24 --source include/master-slave.inc
25
26 --echo #
27 --echo # Initialize test data
28 --connection master
29 create table t1 (a int) engine=innodb;
30 --source include/save_master_gtid.inc
31 set @@SESSION.debug_dbug= "+d,binlog_force_commit_id";
32
33 --connection slave
34 set SQL_LOG_BIN= 0;
35 call mtr.add_suppression('Found invalid event in binary log');
36 call mtr.add_suppression('Slave SQL.*Relay log read failure: Could not parse relay log event entry.* 1594');
37 set SQL_LOG_BIN= 1;
38 --source include/sync_with_master_gtid.inc
39 --source include/stop_slave.inc
40 --source include/start_slave.inc
41 --let $cid_ctr= 100
42
43
44 --echo #
45 --echo # Test FL_PREPARED_XA
46 --connection master
47 set @@SESSION.debug_dbug= "+d,negate_xid_from_gtid";
48 --eval set @commit_id= $cid_ctr
49
50 XA START 'x1';
51 insert into t1 values (1);
52 XA END 'x1';
53 XA PREPARE 'x1';
54 set @@SESSION.debug_dbug= "-d,negate_xid_from_gtid";
55 XA COMMIT 'x1';
56 --source include/save_master_gtid.inc
57
58 --echo # Waiting for slave to find invalid event..
59 --connection slave
60 let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE
61 source include/wait_for_slave_sql_error.inc;
62 STOP SLAVE IO_THREAD;
63
64 --echo # Reset master binlogs (as there is an invalid event) and slave state
65 --connection master
66 RESET MASTER;
67 --connection slave
68 RESET MASTER;
69 RESET SLAVE;
70 set @@global.gtid_slave_pos="";
71 --source include/start_slave.inc
72
73
74 --echo #
75 --echo # Test FL_COMPLETED_XA
76 --connection master
77 --inc $cid_ctr
78 --eval set @commit_id= $cid_ctr
79 XA START 'x1';
80 --let $next_val = `SELECT max(a)+1 FROM t1`
81 --eval insert into t1 values ($next_val)
82 XA END 'x1';
83 XA PREPARE 'x1';
84 set @@SESSION.debug_dbug= "+d,negate_xid_from_gtid";
85 XA COMMIT 'x1';
86 set @@SESSION.debug_dbug= "-d,negate_xid_from_gtid";
87 --source include/save_master_gtid.inc
88
89 --echo # Waiting for slave to find invalid event..
90 --connection slave
91 let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE
92 source include/wait_for_slave_sql_error.inc;
93 STOP SLAVE IO_THREAD;
94
95 --echo # Cleanup hanging XA PREPARE on slave
96 set statement SQL_LOG_BIN=0 for XA COMMIT 'x1';
97
98 --echo # Reset master binlogs (as there is an invalid event) and slave state
99 --connection master
100 RESET MASTER;
101 --connection slave
102 RESET MASTER;
103 RESET SLAVE;
104 set @@global.gtid_slave_pos="";
105 --source include/start_slave.inc
106
107
108 --echo #
109 --echo # Test Missing xid.data (but has format id and length description parts)
110
111 --connection master
112 --eval set @commit_id= $cid_ctr
113
114 XA START 'x1';
115 insert into t1 values (1);
116 XA END 'x1';
117 XA PREPARE 'x1';
118 set @@SESSION.debug_dbug= "+d,negate_xid_data_from_gtid";
119 XA COMMIT 'x1';
120 set @@SESSION.debug_dbug= "-d,negate_xid_data_from_gtid";
121 --source include/save_master_gtid.inc
122
123 --echo # Waiting for slave to find invalid event..
124 --connection slave
125 let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE
126 source include/wait_for_slave_sql_error.inc;
127 STOP SLAVE IO_THREAD;
128
129 --echo # Cleanup hanging XA PREPARE on slave
130 set statement SQL_LOG_BIN=0 for XA COMMIT 'x1';
131
132 --echo # Reset master binlogs (as there is an invalid event) and slave state
133 --connection master
134 RESET MASTER;
135 --connection slave
136 RESET MASTER;
137 RESET SLAVE;
138 set @@global.gtid_slave_pos="";
139 --source include/start_slave.inc
140
141
142 --echo #
143 --echo # Test FL_EXTRA_MULTI_ENGINE
144 --connection master
145 set @old_dbug= @@SESSION.debug_dbug;
146 set @@SESSION.debug_dbug= "+d,inject_fl_extra_multi_engine_into_gtid";
147 --inc $cid_ctr
148 --eval set @commit_id= $cid_ctr
149 --let $next_val = `SELECT max(a)+1 FROM t1`
150 --eval insert into t1 values ($next_val)
151 --source include/save_master_gtid.inc
152 set @@SESSION.debug_dbug=@old_dbug;
153
154 --connection slave
155 --echo # Waiting for slave to find invalid event..
156 let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE
157 source include/wait_for_slave_sql_error.inc;
158 STOP SLAVE IO_THREAD;
159
160 --echo # Reset master binlogs (as there is an invalid event) and slave state
161 --connection master
162 RESET MASTER;
163
164 --connection slave
165 RESET SLAVE;
166 RESET MASTER;
167 set @@global.gtid_slave_pos="";
168 --source include/start_slave.inc
169
170
171 --echo #
172 --echo # Test FL_COMMIT_ALTER
173 --connection master
174 set @old_dbug= @@SESSION.debug_dbug;
175 set @@SESSION.debug_dbug= "+d,negate_alter_fl_from_gtid";
176 set @old_alter_tp= @@SESSION.binlog_alter_two_phase;
177 set @@SESSION.binlog_alter_two_phase= 1;
178 alter table t1 add column (nc int);
179 --source include/save_master_gtid.inc
180 set @@SESSION.debug_dbug=@old_dbug;
181 set @@SESSION.binlog_alter_two_phase=@old_alter_tp;
182
183 --connection slave
184 --echo # Waiting for slave to find invalid event..
185 let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE
186 source include/wait_for_slave_sql_error.inc;
187 STOP SLAVE IO_THREAD;
188
189 --echo # Reset master binlogs (as there is an invalid event) and slave state
190 --connection master
191 RESET MASTER;
192
193 --connection slave
194 # Just to keep tables consistent between master/slave
195 SET STATEMENT sql_log_bin=0 FOR alter table t1 add column (nc int);
196 RESET SLAVE;
197 RESET MASTER;
198 set @@global.gtid_slave_pos="";
199 --source include/start_slave.inc
200
201
202 --echo #
203 --echo # Cleanup
204
205 --connection master
206 drop table t1;
207 --source include/save_master_gtid.inc
208
209 --connection slave
210 --source include/sync_with_master_gtid.inc
211
212 --source include/rpl_end.inc
213 --echo # End of rpl_gtid_header_valid.test