Merge lp:~laurynas-biveinis/percona-server/bmp-fixes-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis on 2013-05-29
Status: Merged
Approved by: Stewart Smith on 2013-05-31
Approved revision: 493
Merged at revision: 528
Proposed branch: lp:~laurynas-biveinis/percona-server/bmp-fixes-5.5
Merge into: lp:percona-server/5.5
Diff against target: 1312 lines (+537/-143) (has conflicts)
19 files modified
Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result (+7/-0)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result (+58/-33)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages_empty.result (+1/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test (+33/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test (+2/-2)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test (+99/-28)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages_empty.test (+4/-2)
Percona-Server/mysql-test/suite/sys_vars/r/all_vars.result (+0/-2)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_max_changed_pages_basic.result (+78/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_max_changed_pages_basic.test (+60/-0)
Percona-Server/storage/innobase/handler/i_s.cc (+8/-6)
Percona-Server/storage/innobase/include/log0log.h (+3/-1)
Percona-Server/storage/innobase/include/log0online.h (+2/-0)
Percona-Server/storage/innobase/include/os0file.h (+4/-2)
Percona-Server/storage/innobase/log/log0log.c (+13/-3)
Percona-Server/storage/innobase/log/log0online.c (+161/-53)
Percona-Server/storage/innobase/log/log0recv.c (+4/-3)
Percona-Server/storage/innobase/os/os0file.c (+0/-2)
Percona-Server/storage/innobase/srv/srv0start.c (+0/-6)
Text conflict in Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result
Text conflict in Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bmp-fixes-5.5
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2013-05-29 Approve on 2013-05-31
Review via email: mp+166280@code.launchpad.net

Description of the change

Merge bitmap fixes from 5.1, add 5.5+-specific fixes.

http://jenkins.percona.com/job/percona-server-5.5-param/749/

To post a comment you must log in.

The merge conflict is GCA vs trunk, does not hinder the review, and will be resolved at the trunk merge time.

Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result'
2--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result 2013-02-04 13:53:47 +0000
3+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result 2013-05-29 15:11:30 +0000
4@@ -47,13 +47,20 @@
5 ib_modified_log_1
6 ib_modified_log_2
7 ib_modified_log_3
8+DROP TABLE t1, t2;
9 8th restart
10 RESET CHANGED_PAGE_BITMAPS;
11 call mtr.add_suppression("InnoDB: Error: page [0-9]* log sequence number [0-9]*");
12 9th restart
13+<<<<<<< TREE
14 CREATE TABLE t3 (a MEDIUMBLOB) ENGINE=InnoDB;
15 call mtr.add_suppression("InnoDB: Error: the age of the oldest untracked record exceeds the log group capacity!");
16 call mtr.add_suppression("InnoDB: Error: stopping the log tracking thread at LSN");
17 INSERT INTO t3 VALUES (REPEAT('a', 12582912));
18 10th restart
19 DROP TABLE t1, t2, t3;
20+=======
21+ib_modified_log_1
22+10th restart
23+11th restart
24+>>>>>>> MERGE-SOURCE
25
26=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result'
27--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result 2013-01-29 15:14:23 +0000
28+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result 2013-05-29 15:11:30 +0000
29@@ -1,5 +1,5 @@
30 RESET CHANGED_PAGE_BITMAPS;
31-DROP TABLE IF EXISTS T1;
32+DROP TABLE IF EXISTS T1, ICP_COPY;
33 CREATE TABLE T1 (F1 CHAR(255)) ENGINE=INNODB;
34 1st interval end LSN greater than interval start LSN:
35 should_be_1
36@@ -54,35 +54,35 @@
37 ICP tests (all should be 1):
38 SELECT COUNT(*) = @cond_test_pages_count
39 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
40-WHERE END_LSN = @cond_test_max_end_lsn;
41-COUNT(*) = @cond_test_pages_count
42-1
43-SELECT COUNT(*) = @cond_test_pages_count
44-FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
45-WHERE
46-END_LSN > (@cond_test_max_end_lsn - 1) AND
47-END_LSN < (@cond_test_max_end_lsn + 1);
48-COUNT(*) = @cond_test_pages_count
49-1
50-SELECT COUNT(*) = @cond_test_pages_count
51-FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
52-WHERE
53-END_LSN >= @cond_test_max_end_lsn AND
54-END_LSN <= @cond_test_max_end_lsn;
55-COUNT(*) = @cond_test_pages_count
56-1
57-SELECT COUNT(*) = @cond_test_pages_count
58-FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
59-WHERE
60-(@cond_test_max_end_lsn - 1) < END_LSN AND
61-@cond_test_max_end_lsn >= END_LSN;
62-COUNT(*) = @cond_test_pages_count
63-1
64-SELECT COUNT(*) = @cond_test_pages_count
65-FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
66-WHERE
67-START_LSN <= @cond_test_max_end_lsn AND
68-END_LSN >= @cond_test_max_end_lsn;
69+WHERE END_LSN = @max_end_lsn;
70+COUNT(*) = @cond_test_pages_count
71+1
72+SELECT COUNT(*) = @cond_test_pages_count
73+FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
74+WHERE
75+END_LSN > (@max_end_lsn - 1) AND
76+END_LSN < (@max_end_lsn + 1);
77+COUNT(*) = @cond_test_pages_count
78+1
79+SELECT COUNT(*) = @cond_test_pages_count
80+FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
81+WHERE
82+END_LSN >= @max_end_lsn AND
83+END_LSN <= @max_end_lsn;
84+COUNT(*) = @cond_test_pages_count
85+1
86+SELECT COUNT(*) = @cond_test_pages_count
87+FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
88+WHERE
89+(@max_end_lsn - 1) < END_LSN AND
90+@max_end_lsn >= END_LSN;
91+COUNT(*) = @cond_test_pages_count
92+1
93+SELECT COUNT(*) = @cond_test_pages_count
94+FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
95+WHERE
96+START_LSN <= @max_end_lsn AND
97+END_LSN >= @max_end_lsn;
98 COUNT(*) = @cond_test_pages_count
99 1
100 SELECT COUNT(*) = @cond_test_pages_count
101@@ -101,7 +101,7 @@
102 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
103 WHERE
104 START_LSN >= @cond_test_max_start_lsn AND
105-END_LSN <= @cond_test_max_end_lsn;
106+END_LSN <= @max_end_lsn;
107 COUNT(*) = @cond_test_pages_count
108 1
109 SELECT COUNT(*) = @cond_test_pages_count
110@@ -115,7 +115,7 @@
111 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
112 WHERE
113 @cond_test_max_start_lsn <= START_LSN AND
114-@cond_test_max_end_lsn >= END_LSN;
115+@max_end_lsn >= END_LSN;
116 COUNT(*) = @cond_test_pages_count
117 1
118 SELECT COUNT(*)
119@@ -153,4 +153,29 @@
120 COUNT(*)
121 5
122 SET GLOBAL INNODB_MAX_CHANGED_PAGES = 1000000;
123-DROP TABLE T1;
124+CREATE TABLE ICP_COPY (
125+space_id INT(11) NOT NULL,
126+page_id INT(11) NOT NULL,
127+start_lsn BIGINT(21) NOT NULL,
128+end_lsn BIGINT(21) NOT NULL,
129+INDEX page_id(space_id, page_id)) ENGINE=InnoDB;
130+INSERT INTO ICP_COPY SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
131+WHERE END_LSN <= @max_end_lsn;
132+SELECT @@global.innodb_track_changed_pages;
133+@@global.innodb_track_changed_pages
134+0
135+SET @max_end_lsn= (SELECT MAX(end_lsn) FROM ICP_COPY);
136+TRUNCATE TABLE ICP_COPY;
137+INSERT INTO ICP_COPY SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
138+WHERE END_LSN <= @max_end_lsn;
139+Check that INNODB_CHANGED_PAGES copies checksum the same (should be 1):
140+should_be_1
141+1
142+SELECT @@global.innodb_track_changed_pages;
143+@@global.innodb_track_changed_pages
144+1
145+ib_modified_log_4
146+SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
147+WHERE START_LSN > 10000;
148+ERROR HY000: Can't read record in system table
149+DROP TABLE T1, ICP_COPY;
150
151=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages_empty.result'
152--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages_empty.result 2012-09-17 13:08:32 +0000
153+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages_empty.result 2013-05-29 15:11:30 +0000
154@@ -1,2 +1,3 @@
155+RESET CHANGED_PAGE_BITMAPS;
156 SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES;
157 space_id page_id start_lsn end_lsn
158
159=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test'
160--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test 2013-02-04 13:53:47 +0000
161+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test 2013-05-29 15:11:30 +0000
162@@ -205,6 +205,8 @@
163 --replace_regex /_[[:digit:]]+\.xdb$//
164 list_files $MYSQLD_DATADIR ib_modified_log*;
165
166+DROP TABLE t1, t2;
167+
168 #
169 # Test for log tracking compatibility with innodb_force_recovery (bug 1083596).
170 #
171@@ -221,7 +223,19 @@
172 RESET CHANGED_PAGE_BITMAPS;
173
174 call mtr.add_suppression("InnoDB: Error: page [0-9]* log sequence number [0-9]*");
175+
176+#
177+# Test that bitmap files are created correctly in innodb_data_home_dir without a trailing
178+# path separator (bug 1181887)
179+#
180+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
181+--shutdown_server 10
182+--source include/wait_until_disconnected.inc
183+--remove_files_wildcard $MYSQLD_DATADIR ib_logfile*
184+--mkdir $MYSQLTEST_VARDIR/tmpdatadir
185+--enable_reconnect
186 --echo 9th restart
187+<<<<<<< TREE
188 --source include/restart_mysqld.inc
189
190 #
191@@ -238,3 +252,22 @@
192 --source include/restart_mysqld.inc
193
194 DROP TABLE t1, t2, t3;
195+=======
196+--exec echo "restart:--innodb-data-home-dir=$MYSQLTEST_VARDIR/tmpdatadir" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
197+--source include/wait_until_connected_again.inc
198+
199+file_exists $MYSQLTEST_VARDIR/tmpdatadir/ib_modified_log_1_0.xdb;
200+--replace_regex /_[[:digit:]]+\.xdb$//
201+list_files $MYSQLTEST_VARDIR/tmpdatadir ib_modified_log*;
202+
203+--echo 10th restart
204+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
205+--shutdown_server 10
206+--source include/wait_until_disconnected.inc
207+--remove_files_wildcard $MYSQLD_DATADIR ib_logfile*
208+--remove_files_wildcard $MYSQLD_DATADIR ibdata*
209+--enable_reconnect
210+--echo 11th restart
211+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
212+--source include/wait_until_connected_again.inc
213+>>>>>>> MERGE-SOURCE
214
215=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test'
216--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test 2013-02-06 09:06:08 +0000
217+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test 2013-05-29 15:11:30 +0000
218@@ -61,7 +61,7 @@
219 INSERT INTO t1 VALUES (3, REPEAT("c", 20000));
220
221 #
222-# Test innodb_flush_method=O_DIRECT
223+# Test innodb_flush_method=ALL_O_DIRECT
224 # Check that the previous test produced bitmap data while the server is down.
225 #
226 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
227@@ -71,7 +71,7 @@
228 --replace_regex /_[[:digit:]]+\.xdb$//
229 list_files $MYSQLD_DATADIR ib_modified_log*;
230 --enable_reconnect
231---exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
232+--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=ALL_O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
233 --source include/wait_until_connected_again.inc
234
235 INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
236
237=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test'
238--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test 2013-01-29 15:14:23 +0000
239+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test 2013-05-29 15:11:30 +0000
240@@ -9,7 +9,7 @@
241 RESET CHANGED_PAGE_BITMAPS;
242
243 --disable_warnings
244-DROP TABLE IF EXISTS T1;
245+DROP TABLE IF EXISTS T1, ICP_COPY;
246 --enable_warnings
247
248 let $old_max_changed_pages= `SELECT @@GLOBAL.INNODB_MAX_CHANGED_PAGES`;
249@@ -105,9 +105,9 @@
250 # Gather data for condition pushdown testing not using conditions #
251 ###################################################################
252 --disable_result_log
253-SET @cond_test_max_end_lsn=
254- (SELECT MAX(end_lsn)
255- FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES);
256+SET @max_end_lsn=
257+ (SELECT MAX(end_lsn)
258+ FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES);
259
260 SET @cond_test_max_start_lsn=
261 (SELECT MAX(start_lsn)
262@@ -153,31 +153,31 @@
263 # Baseline as ICP currently does not support equality
264 SELECT COUNT(*) = @cond_test_pages_count
265 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
266- WHERE END_LSN = @cond_test_max_end_lsn;
267+ WHERE END_LSN = @max_end_lsn;
268
269 SELECT COUNT(*) = @cond_test_pages_count
270 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
271 WHERE
272- END_LSN > (@cond_test_max_end_lsn - 1) AND
273- END_LSN < (@cond_test_max_end_lsn + 1);
274-
275-SELECT COUNT(*) = @cond_test_pages_count
276- FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
277- WHERE
278- END_LSN >= @cond_test_max_end_lsn AND
279- END_LSN <= @cond_test_max_end_lsn;
280-
281-SELECT COUNT(*) = @cond_test_pages_count
282- FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
283- WHERE
284- (@cond_test_max_end_lsn - 1) < END_LSN AND
285- @cond_test_max_end_lsn >= END_LSN;
286-
287-SELECT COUNT(*) = @cond_test_pages_count
288- FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
289- WHERE
290- START_LSN <= @cond_test_max_end_lsn AND
291- END_LSN >= @cond_test_max_end_lsn;
292+ END_LSN > (@max_end_lsn - 1) AND
293+ END_LSN < (@max_end_lsn + 1);
294+
295+SELECT COUNT(*) = @cond_test_pages_count
296+ FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
297+ WHERE
298+ END_LSN >= @max_end_lsn AND
299+ END_LSN <= @max_end_lsn;
300+
301+SELECT COUNT(*) = @cond_test_pages_count
302+ FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
303+ WHERE
304+ (@max_end_lsn - 1) < END_LSN AND
305+ @max_end_lsn >= END_LSN;
306+
307+SELECT COUNT(*) = @cond_test_pages_count
308+ FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
309+ WHERE
310+ START_LSN <= @max_end_lsn AND
311+ END_LSN >= @max_end_lsn;
312
313 SELECT COUNT(*) = @cond_test_pages_count
314 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
315@@ -193,7 +193,7 @@
316 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
317 WHERE
318 START_LSN >= @cond_test_max_start_lsn AND
319- END_LSN <= @cond_test_max_end_lsn;
320+ END_LSN <= @max_end_lsn;
321
322 SELECT COUNT(*) = @cond_test_pages_count
323 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
324@@ -205,7 +205,7 @@
325 FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
326 WHERE
327 @cond_test_max_start_lsn <= START_LSN AND
328- @cond_test_max_end_lsn >= END_LSN;
329+ @max_end_lsn >= END_LSN;
330
331 # Empty range
332 SELECT COUNT(*)
333@@ -262,4 +262,75 @@
334
335 eval SET GLOBAL INNODB_MAX_CHANGED_PAGES = $old_max_changed_pages;
336
337-DROP TABLE T1;
338+#
339+# Test that I_S.INNODB_CHANGED_PAGES can be queried with the log tracking disabled
340+# (bug 1185304)
341+#
342+
343+# We have to skip ICP_COPY bitmap writes. Thus all the I_S queries from
344+# this point are limited to the max_end_lsn.
345+
346+# Save the copy of current table contents
347+CREATE TABLE ICP_COPY (
348+ space_id INT(11) NOT NULL,
349+ page_id INT(11) NOT NULL,
350+ start_lsn BIGINT(21) NOT NULL,
351+ end_lsn BIGINT(21) NOT NULL,
352+ INDEX page_id(space_id, page_id)) ENGINE=InnoDB;
353+
354+INSERT INTO ICP_COPY SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
355+ WHERE END_LSN <= @max_end_lsn;
356+
357+# Restart with log tracking disabled
358+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
359+--shutdown_server 10
360+--source include/wait_until_disconnected.inc
361+--enable_reconnect
362+--exec echo "restart:--innodb-track-changed-pages=FALSE" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
363+--source include/wait_until_connected_again.inc
364+
365+SELECT @@global.innodb_track_changed_pages;
366+
367+let $icp_1_checksum= `CHECKSUM TABLE ICP_COPY`;
368+
369+SET @max_end_lsn= (SELECT MAX(end_lsn) FROM ICP_COPY);
370+
371+# Read the table again
372+TRUNCATE TABLE ICP_COPY;
373+
374+INSERT INTO ICP_COPY SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
375+ WHERE END_LSN <= @max_end_lsn;
376+
377+# Compare the checksums of both reads
378+let $icp_2_checksum= `CHECKSUM TABLE ICP_COPY`;
379+--disable_query_log
380+--echo Check that INNODB_CHANGED_PAGES copies checksum the same (should be 1):
381+eval SELECT "$icp_1_checksum" LIKE "$icp_2_checksum" AS should_be_1;
382+--enable_query_log
383+
384+--source include/restart_mysqld.inc
385+
386+SELECT @@global.innodb_track_changed_pages;
387+
388+#
389+# Test for
390+# - bug 1179974 (INFORMATION_SCHEMA.INNODB_CHANGED_PAGES query fails server
391+# with an I/O error if a bitmap file in the middle of requested range is missing)
392+# - bug 1185040 (INFORMATION_SCHEMA.INNODB_CHANGED_PAGES_QUERY should return a
393+# warning if the result set is partial)
394+#
395+
396+let $MYSQLD_DATADIR= `select @@datadir`;
397+--replace_regex /_[[:digit:]]+\.xdb$//
398+list_files $MYSQLD_DATADIR ib_modified_log_4_*;
399+
400+remove_files_wildcard $MYSQLD_DATADIR ib_modified_log_4_*.xdb;
401+
402+--replace_regex /_[[:digit:]]+\.xdb$//
403+list_files $MYSQLD_DATADIR ib_modified_log_4_*;
404+
405+--error ER_CANT_FIND_SYSTEM_REC
406+SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES
407+ WHERE START_LSN > 10000;
408+
409+DROP TABLE T1, ICP_COPY;
410
411=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages_empty.test'
412--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages_empty.test 2012-09-17 13:08:32 +0000
413+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages_empty.test 2013-05-29 15:11:30 +0000
414@@ -1,8 +1,10 @@
415 ###############################################################################
416-# Test for empty I_S.INNODB_CHANGED_PAGES table. The table should be empty if#
417-# innodb_track_changed_pages is false. #
418+# Test for empty I_S.INNODB_CHANGED_PAGES table. The table should be empty if #
419+# no bitmap files exist #
420 ###############################################################################
421
422 --source include/have_innodb.inc
423
424+RESET CHANGED_PAGE_BITMAPS;
425+
426 SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES;
427
428=== modified file 'Percona-Server/mysql-test/suite/sys_vars/r/all_vars.result'
429--- Percona-Server/mysql-test/suite/sys_vars/r/all_vars.result 2013-01-29 15:14:23 +0000
430+++ Percona-Server/mysql-test/suite/sys_vars/r/all_vars.result 2013-05-29 15:11:30 +0000
431@@ -14,7 +14,5 @@
432 INNODB_FAKE_CHANGES
433 INNODB_KILL_IDLE_TRANSACTION
434 INNODB_KILL_IDLE_TRANSACTION
435-INNODB_MAX_CHANGED_PAGES
436-INNODB_MAX_CHANGED_PAGES
437 drop table t1;
438 drop table t2;
439
440=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_max_changed_pages_basic.result'
441--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_max_changed_pages_basic.result 1970-01-01 00:00:00 +0000
442+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_max_changed_pages_basic.result 2013-05-29 15:11:30 +0000
443@@ -0,0 +1,78 @@
444+SET @start_value = @@global.innodb_max_changed_pages;
445+SELECT @start_value;
446+@start_value
447+1000000
448+SET @@global.innodb_max_changed_pages = 5000;
449+SET @@global.innodb_max_changed_pages = DEFAULT;
450+SELECT @@global.innodb_max_changed_pages;
451+@@global.innodb_max_changed_pages
452+1000000
453+SET @@global.innodb_max_changed_pages = 0;
454+SELECT @@global.innodb_max_changed_pages;
455+@@global.innodb_max_changed_pages
456+0
457+SET @@global.innodb_max_changed_pages = 1;
458+SELECT @@global.innodb_max_changed_pages;
459+@@global.innodb_max_changed_pages
460+1
461+SET @@global.innodb_max_changed_pages = 18446744073709551614;
462+SELECT @@global.innodb_max_changed_pages;
463+@@global.innodb_max_changed_pages
464+18446744073709551614
465+SET @@global.innodb_max_changed_pages = 18446744073709551615;
466+SELECT @@global.innodb_max_changed_pages;
467+@@global.innodb_max_changed_pages
468+18446744073709551615
469+SET @@global.innodb_max_changed_pages = 18446744073709551616;
470+ERROR 42000: Incorrect argument type to variable 'innodb_max_changed_pages'
471+SELECT @@global.innodb_max_changed_pages;
472+@@global.innodb_max_changed_pages
473+18446744073709551615
474+SET @@global.innodb_max_changed_pages = 18446744073709551617;
475+ERROR 42000: Incorrect argument type to variable 'innodb_max_changed_pages'
476+SELECT @@global.innodb_max_changed_pages;
477+@@global.innodb_max_changed_pages
478+18446744073709551615
479+SET @@global.innodb_max_changed_pages = 105.54;
480+ERROR 42000: Incorrect argument type to variable 'innodb_max_changed_pages'
481+SELECT @@global.innodb_max_changed_pages;
482+@@global.innodb_max_changed_pages
483+18446744073709551615
484+SET @@global.innodb_max_changed_pages = -200;
485+Warnings:
486+Warning 1292 Truncated incorrect innodb_max_changed_pages value: '-200'
487+SELECT @@global.innodb_max_changed_pages;
488+@@global.innodb_max_changed_pages
489+0
490+SET @@global.innodb_max_changed_pages = ON;
491+ERROR 42000: Incorrect argument type to variable 'innodb_max_changed_pages'
492+SELECT @@global.innodb_max_changed_pages;
493+@@global.innodb_max_changed_pages
494+0
495+SET @@global.innodb_max_changed_pages = 'foo';
496+ERROR 42000: Incorrect argument type to variable 'innodb_max_changed_pages'
497+SELECT @@global.innodb_max_changed_pages;
498+@@global.innodb_max_changed_pages
499+0
500+SET @@session.innodb_max_changed_pages = 4096;
501+ERROR HY000: Variable 'innodb_max_changed_pages' is a GLOBAL variable and should be set with SET GLOBAL
502+SELECT @@session.innodb_max_changed_pages;
503+ERROR HY000: Variable 'innodb_max_changed_pages' is a GLOBAL variable
504+SELECT @@global.innodb_max_changed_pages = VARIABLE_VALUE
505+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
506+WHERE VARIABLE_NAME='innodb_max_changed_pages';
507+@@global.innodb_max_changed_pages = VARIABLE_VALUE
508+1
509+SELECT @@global.innodb_max_changed_pages = VARIABLE_VALUE
510+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
511+WHERE VARIABLE_NAME='innodb_max_changed_pages';
512+@@global.innodb_max_changed_pages = VARIABLE_VALUE
513+1
514+SET @@global.innodb_max_changed_pages=6789;
515+SELECT @@global.innodb_max_changed_pages=@@innodb_max_changed_pages;
516+@@global.innodb_max_changed_pages=@@innodb_max_changed_pages
517+1
518+SET @@global.innodb_max_changed_pages=@start_value;
519+SELECT @@global.innodb_max_changed_pages;
520+@@global.innodb_max_changed_pages
521+1000000
522
523=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_max_changed_pages_basic.test'
524--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_max_changed_pages_basic.test 1970-01-01 00:00:00 +0000
525+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_max_changed_pages_basic.test 2013-05-29 15:11:30 +0000
526@@ -0,0 +1,60 @@
527+# Tests for innodb_max_changed_pages variable
528+--source include/have_innodb.inc
529+
530+SET @start_value = @@global.innodb_max_changed_pages;
531+SELECT @start_value;
532+
533+SET @@global.innodb_max_changed_pages = 5000;
534+SET @@global.innodb_max_changed_pages = DEFAULT;
535+SELECT @@global.innodb_max_changed_pages;
536+
537+# Valid boundary values
538+SET @@global.innodb_max_changed_pages = 0;
539+SELECT @@global.innodb_max_changed_pages;
540+SET @@global.innodb_max_changed_pages = 1;
541+SELECT @@global.innodb_max_changed_pages;
542+SET @@global.innodb_max_changed_pages = 18446744073709551614;
543+SELECT @@global.innodb_max_changed_pages;
544+SET @@global.innodb_max_changed_pages = 18446744073709551615;
545+SELECT @@global.innodb_max_changed_pages;
546+
547+# Invalid values
548+--error ER_WRONG_TYPE_FOR_VAR
549+SET @@global.innodb_max_changed_pages = 18446744073709551616;
550+SELECT @@global.innodb_max_changed_pages;
551+--error ER_WRONG_TYPE_FOR_VAR
552+SET @@global.innodb_max_changed_pages = 18446744073709551617;
553+SELECT @@global.innodb_max_changed_pages;
554+--error ER_WRONG_TYPE_FOR_VAR
555+SET @@global.innodb_max_changed_pages = 105.54;
556+SELECT @@global.innodb_max_changed_pages;
557+SET @@global.innodb_max_changed_pages = -200;
558+SELECT @@global.innodb_max_changed_pages;
559+--error ER_WRONG_TYPE_FOR_VAR
560+SET @@global.innodb_max_changed_pages = ON;
561+SELECT @@global.innodb_max_changed_pages;
562+--error ER_WRONG_TYPE_FOR_VAR
563+SET @@global.innodb_max_changed_pages = 'foo';
564+SELECT @@global.innodb_max_changed_pages;
565+
566+# Accessing as session variable forbidden
567+--error ER_GLOBAL_VARIABLE
568+SET @@session.innodb_max_changed_pages = 4096;
569+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
570+SELECT @@session.innodb_max_changed_pages;
571+
572+# Verify INFORMATION_SCHEMA access
573+SELECT @@global.innodb_max_changed_pages = VARIABLE_VALUE
574+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
575+WHERE VARIABLE_NAME='innodb_max_changed_pages';
576+
577+SELECT @@global.innodb_max_changed_pages = VARIABLE_VALUE
578+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
579+WHERE VARIABLE_NAME='innodb_max_changed_pages';
580+
581+# Check default scope
582+SET @@global.innodb_max_changed_pages=6789;
583+SELECT @@global.innodb_max_changed_pages=@@innodb_max_changed_pages;
584+
585+SET @@global.innodb_max_changed_pages=@start_value;
586+SELECT @@global.innodb_max_changed_pages;
587
588=== modified file 'Percona-Server/storage/innobase/handler/i_s.cc'
589--- Percona-Server/storage/innobase/handler/i_s.cc 2013-05-15 05:05:18 +0000
590+++ Percona-Server/storage/innobase/handler/i_s.cc 2013-05-29 15:11:30 +0000
591@@ -52,7 +52,7 @@
592 #include "dict0mem.h"
593 #include "dict0types.h"
594 #include "ha_prototypes.h" /* for innobase_convert_name() */
595-#include "srv0srv.h" /* for srv_track_changed_pages */
596+#include "srv0srv.h" /* for srv_max_changed_pages */
597 #include "srv0start.h" /* for srv_was_started */
598 #include "trx0i_s.h"
599 #include "trx0trx.h" /* for TRX_QUE_STATE_STR_MAX_LEN */
600@@ -7473,6 +7473,7 @@
601 ib_uint64_t output_rows_num = 0UL;
602 ib_uint64_t max_lsn = IB_ULONGLONG_MAX;
603 ib_uint64_t min_lsn = 0ULL;
604+ int ret = 0;
605
606 DBUG_ENTER("i_s_innodb_changed_pages_fill");
607
608@@ -7484,10 +7485,6 @@
609
610 RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
611
612- if (!srv_track_changed_pages) {
613- DBUG_RETURN(0);
614- }
615-
616 if (cond) {
617 limit_lsn_range_from_condition(table, cond, &min_lsn,
618 &max_lsn);
619@@ -7563,8 +7560,13 @@
620 ++output_rows_num;
621 }
622
623+ if (i.failed) {
624+ my_error(ER_CANT_FIND_SYSTEM_REC, MYF(0));
625+ ret = 1;
626+ }
627+
628 log_online_bitmap_iterator_release(&i);
629- DBUG_RETURN(0);
630+ DBUG_RETURN(ret);
631 }
632
633 static
634
635=== modified file 'Percona-Server/storage/innobase/include/log0log.h'
636--- Percona-Server/storage/innobase/include/log0log.h 2013-04-02 18:49:46 +0000
637+++ Percona-Server/storage/innobase/include/log0log.h 2013-05-29 15:11:30 +0000
638@@ -400,7 +400,9 @@
639 byte* buf, /*!< in: buffer where to read */
640 log_group_t* group, /*!< in: log group */
641 ib_uint64_t start_lsn, /*!< in: read area start */
642- ib_uint64_t end_lsn); /*!< in: read area end */
643+ ib_uint64_t end_lsn, /*!< in: read area end */
644+ ibool release_mutex); /*!< in: whether the log_sys->mutex
645+ should be released before the read */
646 /******************************************************//**
647 Writes a buffer to a log file group. */
648 UNIV_INTERN
649
650=== modified file 'Percona-Server/storage/innobase/include/log0online.h'
651--- Percona-Server/storage/innobase/include/log0online.h 2013-01-30 13:42:52 +0000
652+++ Percona-Server/storage/innobase/include/log0online.h 2013-05-29 15:11:30 +0000
653@@ -159,6 +159,8 @@
654 /** Struct for an iterator through all bits of changed pages bitmap blocks */
655 struct log_bitmap_iterator_struct
656 {
657+ ibool failed; /*!< Has the iteration
658+ stopped prematurely */
659 log_online_bitmap_file_range_t in_files; /*!< The bitmap files
660 for this iterator */
661 size_t in_i; /*!< Currently read
662
663=== modified file 'Percona-Server/storage/innobase/include/os0file.h'
664--- Percona-Server/storage/innobase/include/os0file.h 2013-02-06 09:26:12 +0000
665+++ Percona-Server/storage/innobase/include/os0file.h 2013-05-29 15:11:30 +0000
666@@ -76,15 +76,19 @@
667 #endif
668
669 #ifdef __WIN__
670+#define SRV_PATH_SEPARATOR '\\'
671 /** File handle */
672 # define os_file_t HANDLE
673+# define os_file_invalid INVALID_HANDLE_VALUE
674 /** Convert a C file descriptor to a native file handle
675 @param fd file descriptor
676 @return native file handle */
677 # define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
678 #else
679+#define SRV_PATH_SEPARATOR '/'
680 /** File handle */
681 typedef int os_file_t;
682+# define os_file_invalid (-1)
683 /** Convert a C file descriptor to a native file handle
684 @param fd file descriptor
685 @return native file handle */
686@@ -819,7 +823,6 @@
687 ulint src_line);/*!< in: line where the func invoked */
688 #endif /* UNIV_PFS_IO */
689
690-#ifdef UNIV_HOTBACKUP
691 /***********************************************************************//**
692 Closes a file handle.
693 @return TRUE if success */
694@@ -828,7 +831,6 @@
695 os_file_close_no_error_handling(
696 /*============================*/
697 os_file_t file); /*!< in, own: handle to a file */
698-#endif /* UNIV_HOTBACKUP */
699 /***********************************************************************//**
700 Gets a file size.
701 @return TRUE if success */
702
703=== modified file 'Percona-Server/storage/innobase/log/log0log.c'
704--- Percona-Server/storage/innobase/log/log0log.c 2013-04-03 06:56:50 +0000
705+++ Percona-Server/storage/innobase/log/log0log.c 2013-05-29 15:11:30 +0000
706@@ -2307,7 +2307,8 @@
707 }
708
709 /******************************************************//**
710-Reads a specified log segment to a buffer. */
711+Reads a specified log segment to a buffer. Optionally releases the log mutex
712+before the I/O. */
713 UNIV_INTERN
714 void
715 log_group_read_log_seg(
716@@ -2316,7 +2317,9 @@
717 byte* buf, /*!< in: buffer where to read */
718 log_group_t* group, /*!< in: log group */
719 ib_uint64_t start_lsn, /*!< in: read area start */
720- ib_uint64_t end_lsn) /*!< in: read area end */
721+ ib_uint64_t end_lsn, /*!< in: read area end */
722+ ibool release_mutex) /*!< in: whether the log_sys->mutex
723+ should be released before the read */
724 {
725 ulint len;
726 ulint source_offset;
727@@ -2346,6 +2349,10 @@
728
729 log_sys->n_log_ios++;
730
731+ if (release_mutex) {
732+ mutex_exit(&(log_sys->mutex));
733+ }
734+
735 fil_io(OS_FILE_READ | OS_FILE_LOG, sync, group->space_id, 0,
736 source_offset / UNIV_PAGE_SIZE, source_offset % UNIV_PAGE_SIZE,
737 len, buf, NULL);
738@@ -2355,6 +2362,9 @@
739
740 if (start_lsn != end_lsn) {
741
742+ if (release_mutex) {
743+ mutex_enter(&(log_sys->mutex));
744+ }
745 goto loop;
746 }
747 }
748@@ -2846,7 +2856,7 @@
749
750 log_group_read_log_seg(LOG_ARCHIVE, log_sys->archive_buf,
751 UT_LIST_GET_FIRST(log_sys->log_groups),
752- start_lsn, limit_lsn);
753+ start_lsn, limit_lsn, FALSE);
754
755 mutex_exit(&(log_sys->mutex));
756
757
758=== modified file 'Percona-Server/storage/innobase/log/log0online.c'
759--- Percona-Server/storage/innobase/log/log0online.c 2013-04-04 03:54:12 +0000
760+++ Percona-Server/storage/innobase/log/log0online.c 2013-05-29 15:11:30 +0000
761@@ -43,8 +43,8 @@
762
763 /** Log parsing and bitmap output data structure */
764 struct log_bitmap_struct {
765- byte read_buf[FOLLOW_SCAN_SIZE];
766- /*!< log read buffer */
767+ byte* read_buf_ptr; /*!< Unaligned log read buffer */
768+ byte* read_buf; /*!< log read buffer */
769 byte parse_buf[RECV_PARSING_BUF_SIZE];
770 /*!< log parse buffer */
771 byte* parse_buf_end; /*!< parse buffer position where the
772@@ -53,6 +53,8 @@
773 parsed, it points to the start,
774 otherwise points immediatelly past the
775 end of the incomplete log record. */
776+ char bmp_file_home[FN_REFLEN];
777+ /*!< directory for bitmap files */
778 log_online_bitmap_file_t out; /*!< The current bitmap file */
779 ulint out_seq_num; /*!< the bitmap file sequence number */
780 ib_uint64_t start_lsn; /*!< the LSN of the next unparsed
781@@ -490,9 +492,8 @@
782 ib_uint64_t start_lsn) /*!< in: the start LSN name part */
783 {
784 ut_snprintf(log_bmp_sys->out.name, FN_REFLEN, bmp_file_name_template,
785- srv_data_home, bmp_file_name_stem,
786+ log_bmp_sys->bmp_file_home, bmp_file_name_stem,
787 log_bmp_sys->out_seq_num, start_lsn);
788-
789 }
790
791 /*********************************************************************//**
792@@ -509,7 +510,8 @@
793
794 /* Currently, it's OK to overwrite 0-sized files only */
795 success = os_file_get_status(path, &file_info);
796- return success && file_info.size == 0LL;
797+ return success && file_info.type == OS_FILE_TYPE_FILE
798+ && file_info.size == 0LL;
799 }
800
801 /*********************************************************************//**
802@@ -525,7 +527,7 @@
803
804 /* Check for an old file that should be deleted first */
805 if (log_online_should_overwrite(log_bmp_sys->out.name)) {
806- success = os_file_delete(log_bmp_sys->out.name);
807+ success = os_file_delete_if_exists(log_bmp_sys->out.name);
808 }
809
810 if (UNIV_LIKELY(success)) {
811@@ -544,7 +546,6 @@
812 fprintf(stderr,
813 "InnoDB: Error: Cannot create \'%s\'\n",
814 log_bmp_sys->out.name);
815- log_bmp_sys->out.file = -1;
816 return FALSE;
817 }
818
819@@ -563,9 +564,9 @@
820 ib_uint64_t next_file_start_lsn) /*!<in: the start LSN name
821 part */
822 {
823- if (log_bmp_sys->out.file != -1) {
824+ if (log_bmp_sys->out.file != os_file_invalid) {
825 os_file_close(log_bmp_sys->out.file);
826- log_bmp_sys->out.file = -1;
827+ log_bmp_sys->out.file = os_file_invalid;
828 }
829 log_bmp_sys->out_seq_num++;
830 log_online_make_bitmap_name(next_file_start_lsn);
831@@ -613,6 +614,7 @@
832 os_file_dir_t bitmap_dir;
833 os_file_stat_t bitmap_dir_file_info;
834 ib_uint64_t last_file_start_lsn = MIN_TRACKED_LSN;
835+ size_t srv_data_home_len;
836
837 /* Bitmap data start and end in a bitmap block must be 8-byte
838 aligned. */
839@@ -620,20 +622,39 @@
840 compile_time_assert(MODIFIED_PAGE_BLOCK_BITMAP_LEN % 8 == 0);
841
842 log_bmp_sys = ut_malloc(sizeof(*log_bmp_sys));
843+ log_bmp_sys->read_buf_ptr = ut_malloc(FOLLOW_SCAN_SIZE
844+ + OS_FILE_LOG_BLOCK_SIZE);
845+ log_bmp_sys->read_buf = ut_align(log_bmp_sys->read_buf_ptr,
846+ OS_FILE_LOG_BLOCK_SIZE);
847
848 mutex_create(log_bmp_sys_mutex_key, &log_bmp_sys->mutex,
849 SYNC_LOG_ONLINE);
850
851+ /* Initialize bitmap file directory from srv_data_home and add a path
852+ separator if needed. */
853+ srv_data_home_len = strlen(srv_data_home);
854+ ut_a (srv_data_home_len < FN_REFLEN);
855+ strcpy(log_bmp_sys->bmp_file_home, srv_data_home);
856+ if (srv_data_home_len
857+ && log_bmp_sys->bmp_file_home[srv_data_home_len - 1]
858+ != SRV_PATH_SEPARATOR) {
859+
860+ ut_a (srv_data_home_len < FN_REFLEN - 1);
861+ log_bmp_sys->bmp_file_home[srv_data_home_len]
862+ = SRV_PATH_SEPARATOR;
863+ log_bmp_sys->bmp_file_home[srv_data_home_len + 1] = '\0';
864+ }
865+
866 /* Enumerate existing bitmap files to either open the last one to get
867 the last tracked LSN either to find that there are none and start
868 tracking from scratch. */
869 log_bmp_sys->out.name[0] = '\0';
870 log_bmp_sys->out_seq_num = 0;
871
872- bitmap_dir = os_file_opendir(srv_data_home, TRUE);
873+ bitmap_dir = os_file_opendir(log_bmp_sys->bmp_file_home, TRUE);
874 ut_a(bitmap_dir);
875- while (!os_file_readdir_next_file(srv_data_home, bitmap_dir,
876- &bitmap_dir_file_info)) {
877+ while (!os_file_readdir_next_file(log_bmp_sys->bmp_file_home,
878+ bitmap_dir, &bitmap_dir_file_info)) {
879
880 ulong file_seq_num;
881 ib_uint64_t file_start_lsn;
882@@ -648,8 +669,8 @@
883 && bitmap_dir_file_info.size > 0) {
884 log_bmp_sys->out_seq_num = file_seq_num;
885 last_file_start_lsn = file_start_lsn;
886- /* No dir component (srv_data_home) here, because
887- that's the cwd */
888+ /* No dir component (log_bmp_sys->bmp_file_home) here,
889+ because that's the cwd */
890 strncpy(log_bmp_sys->out.name,
891 bitmap_dir_file_info.name, FN_REFLEN - 1);
892 log_bmp_sys->out.name[FN_REFLEN - 1] = '\0';
893@@ -659,7 +680,7 @@
894 if (os_file_closedir(bitmap_dir)) {
895 os_file_get_last_error(TRUE);
896 fprintf(stderr, "InnoDB: Error: cannot close \'%s\'\n",
897- srv_data_home);
898+ log_bmp_sys->bmp_file_home);
899 exit(1);
900 }
901
902@@ -762,9 +783,9 @@
903 {
904 ib_rbt_node_t *free_list_node = log_bmp_sys->page_free_list;
905
906- if (log_bmp_sys->out.file != -1) {
907+ if (log_bmp_sys->out.file != os_file_invalid) {
908 os_file_close(log_bmp_sys->out.file);
909- log_bmp_sys->out.file = -1;
910+ log_bmp_sys->out.file = os_file_invalid;
911 }
912
913 rbt_free(log_bmp_sys->modified_pages);
914@@ -777,6 +798,7 @@
915
916 mutex_free(&log_bmp_sys->mutex);
917
918+ ut_free(log_bmp_sys->read_buf_ptr);
919 ut_free(log_bmp_sys);
920 }
921
922@@ -978,8 +1000,8 @@
923
924 mutex_enter(&log_sys->mutex);
925 log_group_read_log_seg(LOG_RECOVER, log_bmp_sys->read_buf,
926- group, block_start_lsn, block_end_lsn);
927- mutex_exit(&log_sys->mutex);
928+ group, block_start_lsn, block_end_lsn, TRUE);
929+ /* log_group_read_log_seg will release the log_sys->mutex for us */
930
931 while (log_block < log_block_end
932 && log_bmp_sys->next_parse_lsn < log_bmp_sys->end_lsn) {
933@@ -1256,15 +1278,18 @@
934 os_file_dir_t bitmap_dir;
935 os_file_stat_t bitmap_dir_file_info;
936 ulong first_file_seq_num = ULONG_MAX;
937+ ulong last_file_seq_num = 0;
938 ib_uint64_t first_file_start_lsn = IB_ULONGLONG_MAX;
939
940+ ut_ad(range_end >= range_start);
941+
942 bitmap_files->count = 0;
943 bitmap_files->files = NULL;
944
945 /* 1st pass: size the info array */
946
947 bitmap_dir = os_file_opendir(srv_data_home, FALSE);
948- if (!bitmap_dir) {
949+ if (UNIV_UNLIKELY(!bitmap_dir)) {
950 fprintf(stderr,
951 "InnoDB: Error: "
952 "failed to open bitmap directory \'%s\'\n",
953@@ -1286,12 +1311,17 @@
954 continue;
955 }
956
957+ if (file_seq_num > last_file_seq_num) {
958+
959+ last_file_seq_num = file_seq_num;
960+ }
961+
962 if (file_start_lsn >= range_start
963 || file_start_lsn == first_file_start_lsn
964 || first_file_start_lsn > range_start) {
965
966 /* A file that falls into the range */
967- bitmap_files->count++;
968+
969 if (file_start_lsn < first_file_start_lsn) {
970
971 first_file_start_lsn = file_start_lsn;
972@@ -1309,23 +1339,27 @@
973 }
974 }
975
976- ut_a(first_file_seq_num != ULONG_MAX || bitmap_files->count == 0);
977+ if (UNIV_UNLIKELY(os_file_closedir(bitmap_dir))) {
978
979- if (os_file_closedir(bitmap_dir)) {
980 os_file_get_last_error(TRUE);
981 fprintf(stderr, "InnoDB: Error: cannot close \'%s\'\n",
982 srv_data_home);
983 return FALSE;
984 }
985
986- if (!bitmap_files->count) {
987+ if (first_file_seq_num == ULONG_MAX && last_file_seq_num == 0) {
988+
989+ bitmap_files->count = 0;
990 return TRUE;
991 }
992
993+ bitmap_files->count = last_file_seq_num - first_file_seq_num + 1;
994+
995 /* 2nd pass: get the file names in the file_seq_num order */
996
997 bitmap_dir = os_file_opendir(srv_data_home, FALSE);
998- if (!bitmap_dir) {
999+ if (UNIV_UNLIKELY(!bitmap_dir)) {
1000+
1001 fprintf(stderr, "InnoDB: Error: "
1002 "failed to open bitmap directory \'%s\'\n",
1003 srv_data_home);
1004@@ -1349,11 +1383,25 @@
1005 &file_start_lsn)
1006 || file_start_lsn >= range_end
1007 || file_start_lsn < first_file_start_lsn) {
1008+
1009 continue;
1010 }
1011
1012 array_pos = file_seq_num - first_file_seq_num;
1013+ if (UNIV_UNLIKELY(array_pos >= bitmap_files->count)) {
1014+
1015+ fprintf(stderr,
1016+ "InnoDB: Error: inconsistent bitmap file "
1017+ "directory for a "
1018+ "INFORMATION_SCHEMA.INNODB_CHANGED_PAGES query"
1019+ "\n");
1020+ free(bitmap_files->files);
1021+ return FALSE;
1022+ }
1023+
1024+
1025 if (file_seq_num > bitmap_files->files[array_pos].seq_num) {
1026+
1027 bitmap_files->files[array_pos].seq_num = file_seq_num;
1028 strncpy(bitmap_files->files[array_pos].name,
1029 bitmap_dir_file_info.name, FN_REFLEN);
1030@@ -1364,7 +1412,8 @@
1031 }
1032 }
1033
1034- if (os_file_closedir(bitmap_dir)) {
1035+ if (UNIV_UNLIKELY(os_file_closedir(bitmap_dir))) {
1036+
1037 os_file_get_last_error(TRUE);
1038 fprintf(stderr, "InnoDB: Error: cannot close \'%s\'\n",
1039 srv_data_home);
1040@@ -1411,6 +1460,8 @@
1041 ulint size_low;
1042 ulint size_high;
1043
1044+ ut_ad(name[0] != '\0');
1045+
1046 ut_snprintf(bitmap_file->name, FN_REFLEN, "%s%s", srv_data_home, name);
1047 bitmap_file->file
1048 = os_file_create_simple_no_error_handling(innodb_file_bmp_key,
1049@@ -1418,7 +1469,8 @@
1050 OS_FILE_OPEN,
1051 OS_FILE_READ_ONLY,
1052 &success);
1053- if (!success) {
1054+ if (UNIV_UNLIKELY(!success)) {
1055+
1056 /* Here and below assume that bitmap file names do not
1057 contain apostrophes, thus no need for ut_print_filename(). */
1058 fprintf(stderr,
1059@@ -1461,7 +1513,8 @@
1060 || (bitmap_file->offset
1061 > bitmap_file->size - MODIFIED_PAGE_BLOCK_SIZE)) {
1062
1063- if (bitmap_file->offset != bitmap_file->size) {
1064+ if (UNIV_UNLIKELY(bitmap_file->offset != bitmap_file->size)) {
1065+
1066 /* If we are not at EOF and we have less than one page
1067 to read, it's junk. This error is not fatal in
1068 itself. */
1069@@ -1472,7 +1525,8 @@
1070 bitmap_file->name);
1071 }
1072
1073- if (!last_page_in_run) {
1074+ if (UNIV_UNLIKELY(!last_page_in_run)) {
1075+
1076 /* We are at EOF but the last read page did not finish
1077 a run */
1078 /* It's a "Warning" here because it's not a fatal error
1079@@ -1512,18 +1566,29 @@
1080 if (!log_online_setup_bitmap_file_range(&i->in_files, min_lsn,
1081 max_lsn)) {
1082
1083+ i->failed = TRUE;
1084 return FALSE;
1085 }
1086
1087- ut_a(i->in_files.count > 0);
1088+ i->in_i = 0;
1089+
1090+ if (i->in_files.count == 0) {
1091+
1092+ /* Empty range */
1093+ i->in.file = os_file_invalid;
1094+ i->page = NULL;
1095+ i->failed = FALSE;
1096+ return TRUE;
1097+ }
1098
1099 /* Open the 1st bitmap file */
1100- i->in_i = 0;
1101- if (!log_online_open_bitmap_file_read_only(i->in_files.files[i->in_i].
1102- name,
1103- &i->in)) {
1104+ if (UNIV_UNLIKELY(!log_online_open_bitmap_file_read_only(
1105+ i->in_files.files[i->in_i].name,
1106+ &i->in))) {
1107+
1108 i->in_i = i->in_files.count;
1109 free(i->in_files.files);
1110+ i->failed = TRUE;
1111 return FALSE;
1112 }
1113
1114@@ -1534,6 +1599,7 @@
1115 i->first_page_id = 0;
1116 i->last_page_in_run = TRUE;
1117 i->changed = FALSE;
1118+ i->failed = FALSE;
1119
1120 return TRUE;
1121 }
1122@@ -1548,11 +1614,20 @@
1123 {
1124 ut_a(i);
1125
1126- if (i->in_i < i->in_files.count) {
1127+ if (i->in.file != os_file_invalid) {
1128+
1129 os_file_close(i->in.file);
1130- }
1131- ut_free(i->in_files.files);
1132- ut_free(i->page);
1133+ i->in.file = os_file_invalid;
1134+ }
1135+ if (i->in_files.files) {
1136+
1137+ ut_free(i->in_files.files);
1138+ }
1139+ if (i->page) {
1140+
1141+ ut_free(i->page);
1142+ }
1143+ i->failed = TRUE;
1144 }
1145
1146 /*********************************************************************//**
1147@@ -1567,10 +1642,16 @@
1148 log_bitmap_iterator_t *i) /*!<in/out: iterator */
1149 {
1150 ibool checksum_ok = FALSE;
1151+ ibool success;
1152
1153 ut_a(i);
1154
1155- if (i->bit_offset < MODIFIED_PAGE_BLOCK_BITMAP_LEN)
1156+ if (UNIV_UNLIKELY(i->in_files.count == 0)) {
1157+
1158+ return FALSE;
1159+ }
1160+
1161+ if (UNIV_LIKELY(i->bit_offset < MODIFIED_PAGE_BLOCK_BITMAP_LEN))
1162 {
1163 ++i->bit_offset;
1164 i->changed =
1165@@ -1587,29 +1668,56 @@
1166
1167 /* Advance file */
1168 i->in_i++;
1169- os_file_close(i->in.file);
1170- log_online_diagnose_bitmap_eof(&i->in,
1171- i->last_page_in_run);
1172- if (i->in_i == i->in_files.count
1173- || i->in_files.files[i->in_i].seq_num == 0) {
1174-
1175- return FALSE;
1176- }
1177-
1178- if (!log_online_open_bitmap_file_read_only(
1179+ success = os_file_close_no_error_handling(i->in.file);
1180+ i->in.file = os_file_invalid;
1181+ if (UNIV_UNLIKELY(!success)) {
1182+
1183+ os_file_get_last_error(TRUE);
1184+ i->failed = TRUE;
1185+ return FALSE;
1186+ }
1187+
1188+ success = log_online_diagnose_bitmap_eof(
1189+ &i->in, i->last_page_in_run);
1190+ if (UNIV_UNLIKELY(!success)) {
1191+
1192+ i->failed = TRUE;
1193+ return FALSE;
1194+
1195+ }
1196+
1197+ if (i->in_i == i->in_files.count) {
1198+
1199+ return FALSE;
1200+ }
1201+
1202+ if (UNIV_UNLIKELY(i->in_files.files[i->in_i].seq_num
1203+ == 0)) {
1204+
1205+ i->failed = TRUE;
1206+ return FALSE;
1207+ }
1208+
1209+ success = log_online_open_bitmap_file_read_only(
1210 i->in_files.files[i->in_i].name,
1211- &i->in)) {
1212+ &i->in);
1213+ if (UNIV_UNLIKELY(!success)) {
1214+
1215+ i->failed = TRUE;
1216 return FALSE;
1217 }
1218 }
1219
1220- if (!log_online_read_bitmap_page(&i->in, i->page,
1221- &checksum_ok)) {
1222+ success = log_online_read_bitmap_page(&i->in, i->page,
1223+ &checksum_ok);
1224+ if (UNIV_UNLIKELY(!success)) {
1225+
1226 os_file_get_last_error(TRUE);
1227 fprintf(stderr,
1228 "InnoDB: Warning: failed reading "
1229 "changed page bitmap file \'%s\'\n",
1230 i->in_files.files[i->in_i].name);
1231+ i->failed = TRUE;
1232 return FALSE;
1233 }
1234 }
1235@@ -1666,7 +1774,7 @@
1236 /* If we have to delete the current output file, close it
1237 first. */
1238 os_file_close(log_bmp_sys->out.file);
1239- log_bmp_sys->out.file = -1;
1240+ log_bmp_sys->out.file = os_file_invalid;
1241 }
1242
1243 for (i = 0; i < bitmap_files.count; i++) {
1244
1245=== modified file 'Percona-Server/storage/innobase/log/log0recv.c'
1246--- Percona-Server/storage/innobase/log/log0recv.c 2013-05-23 08:39:28 +0000
1247+++ Percona-Server/storage/innobase/log/log0recv.c 2013-05-29 15:11:30 +0000
1248@@ -546,7 +546,8 @@
1249 }
1250
1251 log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
1252- up_to_date_group, start_lsn, end_lsn);
1253+ up_to_date_group, start_lsn, end_lsn,
1254+ FALSE);
1255
1256 len = (ulint) (end_lsn - start_lsn);
1257
1258@@ -590,7 +591,7 @@
1259 ut_a(start_lsn != end_lsn);
1260
1261 log_group_read_log_seg(LOG_RECOVER, recv_sys->last_block,
1262- up_to_date_group, start_lsn, end_lsn);
1263+ up_to_date_group, start_lsn, end_lsn, FALSE);
1264
1265 group = UT_LIST_GET_FIRST(log_sys->log_groups);
1266
1267@@ -2887,7 +2888,7 @@
1268 end_lsn = start_lsn + RECV_SCAN_SIZE;
1269
1270 log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
1271- group, start_lsn, end_lsn);
1272+ group, start_lsn, end_lsn, FALSE);
1273
1274 finished = recv_scan_log_recs(
1275 (buf_pool_get_n_pages()
1276
1277=== modified file 'Percona-Server/storage/innobase/os/os0file.c'
1278--- Percona-Server/storage/innobase/os/os0file.c 2013-05-23 08:39:28 +0000
1279+++ Percona-Server/storage/innobase/os/os0file.c 2013-05-29 15:11:30 +0000
1280@@ -1890,7 +1890,6 @@
1281 #endif
1282 }
1283
1284-#ifdef UNIV_HOTBACKUP
1285 /***********************************************************************//**
1286 Closes a file handle.
1287 @return TRUE if success */
1288@@ -1925,7 +1924,6 @@
1289 return(TRUE);
1290 #endif
1291 }
1292-#endif /* UNIV_HOTBACKUP */
1293
1294 /***********************************************************************//**
1295 Gets a file size.
1296
1297=== modified file 'Percona-Server/storage/innobase/srv/srv0start.c'
1298--- Percona-Server/storage/innobase/srv/srv0start.c 2013-02-04 11:28:50 +0000
1299+++ Percona-Server/storage/innobase/srv/srv0start.c 2013-05-29 15:11:30 +0000
1300@@ -496,12 +496,6 @@
1301 }
1302 #endif /* !UNIV_HOTBACKUP */
1303
1304-#ifdef __WIN__
1305-#define SRV_PATH_SEPARATOR '\\'
1306-#else
1307-#define SRV_PATH_SEPARATOR '/'
1308-#endif
1309-
1310 /*********************************************************************//**
1311 Normalizes a directory path for Windows: converts slashes to backslashes. */
1312 UNIV_INTERN

Subscribers

People subscribed via source and target branches