Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Check replication protocol packet size handling
4 #
5 # ==== Related bugs ====
6 # Bug#19402 SQL close to the size of the max_allowed_packet fails on slave
7 # BUG#23755: Replicated event larger that max_allowed_packet infinitely re-transmits
8 # BUG#42914: No LAST_IO_ERROR for max_allowed_packet errors
9 # BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET
10
11 --source include/force_myisam_default.inc
12 --source include/have_myisam.inc
13 # max-out size db name
14 --source include/not_group_replication_plugin.inc
15 source include/have_binlog_format_row.inc;
16
17 source include/master-slave.inc;
18
19 call mtr.add_suppression("Replica I/O for channel '': Got a packet bigger than 'replica_max_allowed_packet' bytes, Error_code: MY-013125");
20 call mtr.add_suppression("Log entry on source is longer than replica_max_allowed_packet");
21 let $db= DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
22 disable_warnings;
23 eval drop database if exists $db;
24 enable_warnings;
25 eval create database $db;
26
27 connection master;
28 let $old_max_allowed_packet= `SELECT @@global.max_allowed_packet`;
29 let $old_net_buffer_length= `SELECT @@global.net_buffer_length`;
30 let $old_replica_max_allowed_packet= `SELECT @@global.replica_max_allowed_packet`;
31 let $old_replica_max_allowed_packet_temp= `SELECT @@global.replica_max_allowed_packet`;
32 SET @@global.max_allowed_packet=10240;
33 SET @@global.net_buffer_length=1024;
34
35 --source include/sync_slave_sql_with_master.inc
36 # Restart slave for setting to take effect
37 call mtr.add_suppression(".*The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state.*");
38 source include/stop_slave.inc;
39 source include/start_slave.inc;
40
41 # Reconnect to master for new setting to take effect
42 disconnect master;
43
44 # alas, can't use eval here; if db name changed apply the change here
45 connect (master,localhost,root,,DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________);
46
47 connection master;
48 select @@net_buffer_length, @@max_allowed_packet;
49
50 create table `t1` (`f1` LONGTE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aaaaaaaaaaaaaaaaaaaaaaaaaa2048');
53 --source include/sync_slave_sql_with_master.inc
54
55 eval select count(*) from `$db`.`t1` /* must be 1 */;
56
57 --disable_warnings
58 select ras.SERVICE_STATE as Slave_SQL_Running, rcs.SERVICE_STATE as Slave_IO_Running
59 from performance_schema.replication_applier_status ras,
60 performance_schema.replication_connection_status rcs;
61 --enable_warnings
62 connection master;
63 eval drop database $db;
64 --source include/sync_slave_sql_with_master.inc
65
66 #
67 # Bug #23755: Replicated event larger that max_allowed_packet infinitely re-transmits
68 #
69 # Check that a situation when the size of event on the master is greater than
70 # max_allowed_packet on the slave does not lead to infinite re-transmits.
71
72 connection master;
73
74 # Change the max packet size on master
75
76 # Todo: improve over-max_allowed_packet size events block on the slave.
77 # The current size checking algorithm is not presize to allow large event
78 # to slip it. Reject happens according to the guard:
79 # if (data_len > max(max_allowed_packet,
80 # opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
81 # However, MAX_LOG_EVENT_HEADER is a conservative estimate so if the actual
82 # header size is less the extra data let in the slave.
83
84 # Adding the max size of the query log event status as
85 # MAX_DBS_IN_QUERY_MTS * (1 + NAME_LEN) to make the master not fail to read
86 # an event itself. The increased max_allowed_packet also takes care of the
87 # increase in the connect string processing introduced due to WL#5924.
88
89 SET @@global.max_allowed_packet=4096 + (floor(64 * 3 * 254 / 1024) + 1) * 1024;
90 SET @@global.net_buffer_length=@@global.max_allowed_packet;
91
92 # Restart slave for new setting to take effect
93 connection slave;
94 source include/stop_slave.inc;
95 source include/start_slave.inc;
96
97 # Reconnect to master for new setting to take effect
98 disconnect master;
99 connect (master, localhost, root);
100 connection master;
101
102 CREATE TABLE `t1` (`f1` LONGTEXT);
103
104 --source include/sync_slave_sql_with_master.inc
105 --source include/stop_slave_sql.inc
106
107 connection master;
108
109 INSERT INTO t1 VALUES (REPEAT('a', @@global.max_allowed_packet));
110
111
112 #
113 # Bug#42914: The slave I/O thread must stop after trying to read the above
114 # event, However there is no Last_IO_Error report.
115 #
116
117 # The slave I/O thread must stop after trying to read the above event
118 connection slave;
119 # 13125 = ER_SERVER_NET_PACKET_TOO_LARGE
120 --let $slave_io_errno= 13125
121 --let $show_slave_io_error= 1
122 --source include/wait_for_slave_io_error.inc
123
124 #
125 # Bug#42914: On the master, if a binary log event is larger than
126 # max_allowed_packet, the error message ER_SOURCE_FATAL_ERROR_READING_BINLOG
127 # is sent to a slave when it requests a dump from the master, thus leading the
128 # I/O thread to stop. However, there is no Last_IO_Error reported.
129 #
130
131 --let $rpl_only_running_threads= 1
132 --source include/rpl_reset.inc
133 --connection master
134 DROP TABLE t1;
135 --source include/sync_slave_sql_with_master.inc
136
137
138 connection master;
139 CREATE TABLE t1 (f1 int PRIMARY KEY, f2 LONGTEXT, f3 LONGTEXT) ENGINE=MyISAM;
140 --source include/sync_slave_sql_with_master.inc
141
142 connection master;
143 INSERT INTO t1(f1, f2, f3) VALUES(1, REPEAT('a', @@global.max_allowed_packet), REPEAT('b', @@global.max_allowed_packet));
144
145 connection slave;
146 # The slave I/O thread must stop after receiving
147 # 13125 = ER_SERVER_NET_PACKET_TOO_LARGE
148 --let $slave_io_errno= 13125
149 --let $show_slave_io_error= 1
150 --source include/wait_for_slave_io_error.inc
151
152 # Remove the bad binlog and clear error status on slave.
153 STOP SLAVE;
154 RESET SLAVE;
155 RESET MASTER;
156 --connection master
157 RESET MASTER;
158
159
160 #
161 # BUG#55322: SHOW BINLOG EVENTS increases @@SESSION.MAX_ALLOWED_PACKET
162 #
163 # In BUG#55322, @@session.max_allowed_packet increased each time SHOW
164 # BINLOG EVENTS was issued. To verify that this bug is fixed, we
165 # execute SHOW BINLOG EVENTS twice and check that max_allowed_packet
166 # never changes. We turn off the result log because we don't care
167 # about the contents of the binlog.
168
169 --disable_result_log
170 SET @max_allowed_packet_0= @@session.max_allowed_packet;
171 SHOW BINLOG EVENTS;
172 SET @max_allowed_packet_1= @@session.max_allowed_packet;
173 SHOW BINLOG EVENTS;
174 SET @max_allowed_packet_2= @@session.max_allowed_packet;
175 --enable_result_log
176 if (`SELECT NOT(@max_allowed_packet_0 = @max_allowed_packet_1 AND @max_allowed_packet_1 = @max_allowed_packet_2)`)
177 {
178 --echo ERROR: max_allowed_packet changed after executing SHOW BINLOG EVENTS
179 --source include/show_rpl_debug_info.inc
180 SELECT @max_allowed_packet_0, @max_allowed_packet_1, @max_allowed_packet_2;
181 --die @max_allowed_packet changed after executing SHOW BINLOG EVENTS
182 }
183
184 #
185 # BUG#55790
186 # This test verifies if the header of Table_map_log_event
187 # will be displayed by MYSQLBINLOG so long as it was written
188 # to the relay log, even if its rows events are discarded.
189 # And MYSQLBINLOG will print a warning for the missed
190 # rows event.
191 #
192
193 connection slave;
194
195 START SLAVE;
196 --source include/wait_for_slave_to_start.inc
197
198 connection master;
199 DROP TABLE t1;
200 select @@global.max_allowed_packet;
201 select @@global.net_buffer_length;
202 --source include/sync_slave_sql_with_master.inc
203 select @@global.max_allowed_packet;
204 select @@global.net_buffer_length;
205
206 --connection master
207 CREATE TABLE t1 (a TEXT) ENGINE=MyISAM;
208 --source include/sync_slave_sql_with_master.inc
209
210 # Create big row event.
211 --connection master
212 INSERT INTO t1 VALUES (REPEAT('a', @@global.max_allowed_packet));
213
214 # Slave IO thread should stop with error when trying to read the big event.
215 --connection slave
216 --echo # 13125 = ER_SERVER_NET_PACKET_TOO_LARGE
217 --let $slave_io_errno= 13125
218 --let $show_slave_io_error= 1
219 --source include/wait_for_slave_io_error.inc
220
221 --echo # Record Read_Master_Log_Pos for the Table_map_log_event
222 --let $table_map_log_pos= query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1)
223
224 --let $MYSQLD_DATADIR= `SELECT @@datadir`
225 --let $start_pos= query_get_value("SHOW SLAVE STATUS", Relay_Log_Pos, 1)
226 --let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
227 --let $outfile= $MYSQLTEST_VARDIR/tmp/b55790-mysqlbinlog
228 --let $i= 2
229
230 --let $old_replica_max_allowed_packet= `SELECT @@global.max_allowed_packet`
231 SET @@global.max_allowed_packet=1048576;
232 # Restart slave session for new settings to take effect.
233 --connect (slave2,127.0.0.1,root,,test,$SLAVE_MYPORT,)
234 --connection slave2
235
236 while($i)
237 {
238 --let $flags=--start-position=$start_pos
239
240 if($i==2)
241 {
242 --let $flags= $flags --base64-output=decode-rows -v
243 }
244
245 --exec $MYSQL_BINLOG $flags $MYSQLD_DATADIR/$relay_log_file 1> $outfile.1 2> $outfile.2
246 -- let POS=$table_map_log_pos
247 -- let FLGS=$flags
248 -- let OUTFILE_1=$outfile.1
249
250 -- perl
251 $found=0;
252 $file= $ENV{'OUTFILE_1'};
253 $table_map_log_pos= $ENV{'POS'};
254 $flags= $ENV{'FLGS'};
255
256 open(FILE, "$file") or die("Unable to open $file: $!\n");
257 while(<FILE>) {
258 if (/end_log_pos $table_map_log_pos .*Table_map/) {
259 $found=1;
260 break;
261 }
262 }
263
264 if (!$found)
265 {
266 print "**** ERROR **** Table map 'end_log_pos $table_map_log_pos Table_map' NOT FOUND in mysqlbinlog output ($flags $file).";
267 seek(FILE, 0, 0);
268 while($line= <FILE>) {
269 print $line;
270 }
271 }
272 close(FILE);
273 EOF
274
275 # Check the warning is caused
276 --cat_file $outfile.2
277
278 # Remove unecessary files
279 --remove_file $outfile.1
280 --remove_file $outfile.2
281
282 --dec $i
283 }
284
285 --echo ==== clean up ====
286 connection master;
287 DROP TABLE t1;
288 eval SET @@global.max_allowed_packet= $old_max_allowed_packet;
289 eval SET @@global.net_buffer_length= $old_net_buffer_length;
290 eval SET @@global.replica_max_allowed_packet= $old_replica_max_allowed_packet_temp;
291 # slave is stopped
292 connection slave;
293 eval SET @@global.max_allowed_packet= $old_replica_max_allowed_packet;
294 DROP TABLE t1;
295
296 # Clear Last_IO_Error
297
298 STOP REPLICA;
299 RESET SLAVE;
300
301 --let $rpl_only_running_threads=1
302 --source include/rpl_end.inc
303 # End of tests