Debian Codegraph @

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

raw
1 #
2 # BUG#42749: infinite loop writing to row based binlog - processlist shows
3 # "freeing items"
4 #
5 #
6 # WHY
7 # ===
8 #
9 # This bug would make table map event to report data_written one
10 # byte less than what would actually be written in its body. This
11 # would cause one byte shorter event end_log_pos. The ultimate
12 # impact was that it would make fixing the position in
13 # MYSQL_BIN_LOG::write_cache bogus or end up in an infinite loop.
14 #
15 # HOW
16 # ===
17 #
18 # Checking that the patch fixes the problem is done as follows:
19 #
20 # i) one table with m_field_metadata sized at 290
21 # ii) an insert is performed;
22 # iii) the logs are flushed;
23 # iv) mysqlbinlog is used to check if it succeeds.
24 #
25 # In step iv), before the bug was fixed, the test case would fail
26 # with mysqlbinlog reporting that it was unable to succeed in
27 # reading the event.
28 -- source include/not_group_replication_plugin.inc
29 -- source include/have_binlog_format_row.inc
30 -- source include/master-slave.inc
31
32
33 -- disable_warnings
34 DROP TABLE IF EXISTS `t1`;
35
36 # This CREATE TABLE statement issues the warning "Row size too large" when
37 # the InnoDB page size is 4K. No such warning will come for InnoDB page size
38 # 16K. Hence disabling the warning for this CREATE TABLE statement.
39 -- echo ### TABLE with field_metadata_size == 290
40 CREATE TABLE `t1` (
41 `c1` int(11) NOT NULL AUTO_INCREMENT,
42 `c2` varchar(30) NOT NULL,
43 `c3` varchar(30) DEFAULT NULL,
44 `c4` varchar(30) DEFAULT NULL,
45 `c5` varchar(30) DEFAULT NULL,
46 `c6` varchar(30) DEFAULT NULL,
47 `c7` varchar(30) DEFAULT NULL,
48 `c8` varchar(30) DEFAULT NULL,
49 `c9` varchar(30) DEFAULT NULL,
50 `c10` varchar(30) DEFAULT NULL,
51 `c11` varchar(30) DEFAULT NULL,
52 `c12` varchar(30) DEFAULT NULL,
53 `c13` varchar(30) DEFAULT NULL,
54 `c14` varchar(30) DEFAULT NULL,
55 `c15` varchar(30) DEFAULT NULL,
56 `c16` varchar(30) DEFAULT NULL,
57 `c17` varchar(30) DEFAULT NULL,
58 `c18` varchar(30) DEFAULT NULL,
59 `c19` varchar(30) DEFAULT NULL,
60 `c20` varchar(30) DEFAULT NULL,
61 `c21` varchar(30) DEFAULT NULL,
62 `c22` varchar(30) DEFAULT NULL,
63 `c23` varchar(30) DEFAULT NULL,
64 `c24` varchar(30) DEFAULT NULL,
65 `c25` varchar(30) DEFAULT NULL,
66 `c26` varchar(30) DEFAULT NULL,
67 `c27` varchar(30) DEFAULT NULL,
68 `c28` varchar(30) DEFAULT NULL,
69 `c29` varchar(30) DEFAULT NULL,
70 `c30` varchar(30) DEFAULT NULL,
71 `c31` varchar(30) DEFAULT NULL,
72 `c32` varchar(30) DEFAULT NULL,
73 `c33` varchar(30) DEFAULT NULL,
74 `c34` varchar(30) DEFAULT NULL,
75 `c35` varchar(30) DEFAULT NULL,
76 `c36` varchar(30) DEFAULT NULL,
77 `c37` varchar(30) DEFAULT NULL,
78 `c38` varchar(30) DEFAULT NULL,
79 `c39` varchar(30) DEFAULT NULL,
80 `c40` varchar(30) DEFAULT NULL,
81 `c41` varchar(30) DEFAULT NULL,
82 `c42` varchar(30) DEFAULT NULL,
83 `c43` varchar(30) DEFAULT NULL,
84 `c44` varchar(30) DEFAULT NULL,
85 `c45` varchar(30) DEFAULT NULL,
86 `c46` varchar(30) DEFAULT NULL,
87 `c47` varchar(30) DEFAULT NULL,
88 `c48` varchar(30) DEFAULT NULL,
89 `c49` varchar(30) DEFAULT NULL,
90 `c50` varchar(30) DEFAULT NULL,
91 `c51` varchar(30) DEFAULT NULL,
92 `c52` varchar(30) DEFAULT NULL,
93 `c53` varchar(30) DEFAULT NULL,
94 `c54` varchar(30) DEFAULT NULL,
95 `c55` varchar(30) DEFAULT NULL,
96 `c56` varchar(30) DEFAULT NULL,
97 `c57` varchar(30) DEFAULT NULL,
98 `c58` varchar(30) DEFAULT NULL,
99 `c59` varchar(30) DEFAULT NULL,
100 `c60` varchar(30) DEFAULT NULL,
101 `c61` varchar(30) DEFAULT NULL,
102 `c62` varchar(30) DEFAULT NULL,
103 `c63` varchar(30) DEFAULT NULL,
104 `c64` varchar(30) DEFAULT NULL,
105 `c65` varchar(30) DEFAULT NULL,
106 `c66` varchar(30) DEFAULT NULL,
107 `c67` varchar(30) DEFAULT NULL,
108 `c68` varchar(30) DEFAULT NULL,
109 `c69` varchar(30) DEFAULT NULL,
110 `c70` varchar(30) DEFAULT NULL,
111 `c71` varchar(30) DEFAULT NULL,
112 `c72` varchar(30) DEFAULT NULL,
113 `c73` varchar(30) DEFAULT NULL,
114 `c74` varchar(30) DEFAULT NULL,
115 `c75` varchar(30) DEFAULT NULL,
116 `c76` varchar(30) DEFAULT NULL,
117 `c77` varchar(30) DEFAULT NULL,
118 `c78` varchar(30) DEFAULT NULL,
119 `c79` varchar(30) DEFAULT NULL,
120 `c80` varchar(30) DEFAULT NULL,
121 `c81` varchar(30) DEFAULT NULL,
122 `c82` varchar(30) DEFAULT NULL,
123 `c83` varchar(30) DEFAULT NULL,
124 `c84` varchar(30) DEFAULT NULL,
125 `c85` varchar(30) DEFAULT NULL,
126 `c86` varchar(30) DEFAULT NULL,
127 `c87` varchar(30) DEFAULT NULL,
128 `c88` varchar(30) DEFAULT NULL,
129 `c89` varchar(30) DEFAULT NULL,
130 `c90` varchar(30) DEFAULT NULL,
131 `c91` varchar(30) DEFAULT NULL,
132 `c92` varchar(30) DEFAULT NULL,
133 `c93` varchar(30) DEFAULT NULL,
134 `c94` varchar(30) DEFAULT NULL,
135 `c95` varchar(30) DEFAULT NULL,
136 `c96` varchar(30) DEFAULT NULL,
137 `c97` varchar(30) DEFAULT NULL,
138 `c98` varchar(30) DEFAULT NULL,
139 `c99` varchar(30) DEFAULT NULL,
140 `c100` varchar(30) DEFAULT NULL,
141 `c101` varchar(30) DEFAULT NULL,
142 `c102` varchar(30) DEFAULT NULL,
143 `c103` varchar(30) DEFAULT NULL,
144 `c104` varchar(30) DEFAULT NULL,
145 `c105` varchar(30) DEFAULT NULL,
146 `c106` varchar(30) DEFAULT NULL,
147 `c107` varchar(30) DEFAULT NULL,
148 `c108` varchar(30) DEFAULT NULL,
149 `c109` varchar(30) DEFAULT NULL,
150 `c110` varchar(30) DEFAULT NULL,
151 `c111` varchar(30) DEFAULT NULL,
152 `c112` varchar(30) DEFAULT NULL,
153 `c113` varchar(30) DEFAULT NULL,
154 `c114` varchar(30) DEFAULT NULL,
155 `c115` varchar(30) DEFAULT NULL,
156 `c116` varchar(30) DEFAULT NULL,
157 `c117` varchar(30) DEFAULT NULL,
158 `c118` varchar(30) DEFAULT NULL,
159 `c119` varchar(30) DEFAULT NULL,
160 `c120` varchar(30) DEFAULT NULL,
161 `c121` varchar(30) DEFAULT NULL,
162 `c122` varchar(30) DEFAULT NULL,
163 `c123` varchar(30) DEFAULT NULL,
164 `c124` varchar(30) DEFAULT NULL,
165 `c125` varchar(30) DEFAULT NULL,
166 `c126` varchar(30) DEFAULT NULL,
167 `c127` varchar(30) DEFAULT NULL,
168 `c128` varchar(30) DEFAULT NULL,
169 `c129` varchar(30) DEFAULT NULL,
170 `c130` varchar(30) DEFAULT NULL,
171 `c131` varchar(30) DEFAULT NULL,
172 `c132` varchar(30) DEFAULT NULL,
173 `c133` varchar(30) DEFAULT NULL,
174 `c134` varchar(30) DEFAULT NULL,
175 `c135` varchar(30) DEFAULT NULL,
176 `c136` varchar(30) DEFAULT NULL,
177 `c137` varchar(30) DEFAULT NULL,
178 `c138` varchar(30) DEFAULT NULL,
179 `c139` varchar(30) DEFAULT NULL,
180 `c140` varchar(30) DEFAULT NULL,
181 `c141` varchar(30) DEFAULT NULL,
182 `c142` varchar(30) DEFAULT NULL,
183 `c143` varchar(30) DEFAULT NULL,
184 `c144` varchar(30) DEFAULT NULL,
185 `c145` varchar(30) DEFAULT NULL,
186 `c146` varchar(30) DEFAULT NULL,
187 PRIMARY KEY (`c1`)
188 ) ENGINE=InnoDB CHARACTER SET latin1;
189
190 -- enable_warnings
191
192 LOCK TABLES `t1` WRITE;
193 INSERT INTO `t1`(c2) VALUES ('1');
194 FLUSH LOGS;
195
196 --source include/sync_slave_sql_with_master.inc
197 -- connection master
198
199 -- echo ### assertion: the slave replicated event successfully and tables match
200 -- let $diff_tables= master:t1, slave:t1
201 -- source include/diff_tables.inc
202
203 -- connection master
204 DROP TABLE `t1`;
205 --source include/sync_slave_sql_with_master.inc
206 -- connection master
207
208 -- echo === Using mysqlbinlog to detect failure. Before the patch mysqlbinlog would find a corrupted event, thence would fail.
209
210 -- let $MYSQLD_DATADIR= `SELECT @@datadir`
211 -- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog
212 -- remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug42749.binlog
213
214 #############################################################
215 # BUG#50018: binlog corruption when table has many columns
216 #
217 # Same test from BUG#42749, but now we generate some SQL which
218 # creates and inserts into tables with metadata size from 249
219 # to 258.
220 #
221 # The test works as follows:
222 # 1. SQL for several CREATE TABLE and INSERTS are generated
223 # into a file.
224 # 2. This file is then "sourced"
225 # 3. The slave is synchronized with the master
226 # 4. FLUSH LOGS on master
227 # 5. Compare tables on master and slave.
228 # 6. run mysqlbinlog on master's binary log
229 #
230 # Steps #5 and #6 assert that binary log is not corrupted
231 # in both cases: when slave is replaying events and when
232 # mysqlbinlog is used to read the binary log
233
234 --source include/rpl_reset.inc
235 -- connection master
236
237 # Create several tables with field_metadata_size ranging
238 # from 249 to 258 (so that we cover 251 and 255 range).
239 # This should exercise the switch between using 1 or 3
240 # bytes to pack m_field_metadata_size.
241 #
242 # Each varchar field takes up to 2 metadata bytes, see:
243 #
244 # Field_varstring::do_save_field_metadata (field.cc)
245 #
246 # The float field takes 1 byte, see:
247 #
248 # Field_float::do_save_field_metadata (field.cc)
249 #
250
251 -- let $generated_sql= $MYSQLTEST_VARDIR/tmp/b50018.sql
252 -- let B50018_FILE= $generated_sql
253
254 -- echo ### action: generating several tables with different metadata
255 -- echo ### sizes (resorting to perl)
256 -- perl
257 my $file= $ENV{'B50018_FILE'};
258 open(FILE, ">", "$file") or die "Unable to open bug 50018 generated SQL file: $!" ;
259
260 my $tables= "";
261 my $ntables= 10;
262 my $base_ncols= 124;
263
264 for my $i (1..$ntables)
265 {
266 my $ncols= $base_ncols + $i;
267 my $metadata_size= $ncols_variable * 2 + 1;
268
269 print FILE "-- echo ### testing table with " . ($base_ncols*2 + $i) . " field metadata size.\n";
270 print FILE "CREATE TABLE t$i (\n";
271 for my $n (1..$base_ncols)
272 {
273 print FILE "c$n VARCHAR(30) NOT NULL DEFAULT 'BUG#50018',\n";
274 }
275
276 for my $n (1..$i)
277 {
278 print FILE "c" . ($base_ncols+$n) . " FLOAT NOT NULL DEFAULT 0";
279 if ($n < $i)
280 {
281 print FILE ",\n";
282 }
283 }
284
285 print FILE ") Engine=InnoDB CHARACTER SET latin1;\n";
286
287 $tables.= " t$i WRITE";
288 if ($i < $ntables)
289 {
290 $tables .=",";
291 }
292
293 print FILE "LOCK TABLES t$i WRITE;\n";
294 print FILE "INSERT INTO t$i(c". ($base_ncols+1) . ") VALUES (50018);\n";
295 print FILE "UNLOCK TABLES;";
296 }
297
298 close(FILE);
299
300 EOF
301
302 ## we don't need this in the result file
303 ## however, for debugging purposes you
304 ## may want to reactivate query logging
305
306 # The CREATE TABLE statements in 'generated_sql' issues the warning "Row size
307 # too large" when the InnoDB page size is 4K. No such warning will come for
308 # InnoDB page size 16K. Hence disabling the warning while executing these
309 # statement.
310
311 -- disable_warnings
312 -- disable_query_log
313 -- source $generated_sql
314 -- enable_query_log
315 -- enable_warnings
316
317 --source include/sync_slave_sql_with_master.inc
318 -- connection master
319
320 FLUSH LOGS;
321
322 -- let $ntables=10
323 while($ntables)
324 {
325 -- echo ### assertion: the slave replicated event successfully and tables match for t$ntables
326 -- let $diff_tables= master:t$ntables, slave:t$ntables
327 -- source include/diff_tables.inc
328
329 -- connection master
330 -- disable_query_log
331 -- eval DROP TABLE t$ntables
332 -- enable_query_log
333 --source include/sync_slave_sql_with_master.inc
334 -- connection master
335
336 -- dec $ntables
337 }
338
339 -- echo ### assertion: check that binlog is not corrupt. Using mysqlbinlog to
340 -- echo ### detect failure. Before the patch mysqlbinlog would find
341 -- echo ### a corrupted event, thence would fail.
342 -- let $MYSQLD_DATADIR= `SELECT @@datadir`
343 -- exec $MYSQL_BINLOG -v --hexdump $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug50018.binlog
344
345 ## clean up
346 ## For debugging purposes you might want not to remove these
347 -- remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug50018.binlog
348 -- remove_file $generated_sql
349 --source include/rpl_end.inc