Merge lp:~laurynas-biveinis/percona-server/BT-16724-xtradb-bmp-requests-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis on 2013-01-22
Status: Merged
Approved by: Alexey Kopytov on 2013-01-25
Approved revision: 410
Merged at revision: 410
Proposed branch: lp:~laurynas-biveinis/percona-server/BT-16724-xtradb-bmp-requests-5.5
Merge into: lp:percona-server/5.5
Diff against target: 1132 lines (+632/-44)
24 files modified
Percona-Server/include/mysql_com.h (+4/-0)
Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc (+0/-11)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result (+1/-0)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result (+1/-0)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result (+76/-0)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result (+3/-0)
Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result (+1/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test (+3/-1)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test (+3/-1)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt (+1/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test (+200/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt (+1/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test (+7/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test (+3/-1)
Percona-Server/sql/handler.cc (+36/-0)
Percona-Server/sql/handler.h (+5/-0)
Percona-Server/sql/lex.h (+1/-0)
Percona-Server/sql/sql_parse.cc (+37/-4)
Percona-Server/sql/sql_reload.cc (+16/-0)
Percona-Server/sql/sql_yacc.yy (+13/-0)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+55/-0)
Percona-Server/storage/innobase/include/log0online.h (+32/-6)
Percona-Server/storage/innobase/include/sync0sync.h (+2/-0)
Percona-Server/storage/innobase/log/log0online.c (+131/-20)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/BT-16724-xtradb-bmp-requests-5.5
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) 2013-01-22 Approve on 2013-01-25
Stewart Smith 2013-01-22 Pending
Vlad Lesin 2013-01-22 Pending
Review via email: mp+144364@code.launchpad.net

This proposal supersedes a proposal from 2012-11-29.

To post a comment you must log in.
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Typo in the id - it's 16274.

Vlad Lesin (vlad-lesin) wrote : Posted in a previous version of this proposal

See comments in 5.1 branch.

review: Needs Fixing
Vlad Lesin (vlad-lesin) : Posted in a previous version of this proposal
review: Approve
Stewart Smith (stewart) wrote : Posted in a previous version of this proposal

This reserves BITMAPS so that "create table bitmaps (a int)" no longer works. This probably isn't the intent (it would be better ,and keep better compatibility if we didn't do this)

review: Needs Fixing
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal

Same comments/questions as in the 5.1 MP.

review: Needs Fixing
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/include/mysql_com.h'
2--- Percona-Server/include/mysql_com.h 2012-05-10 07:49:14 +0000
3+++ Percona-Server/include/mysql_com.h 2013-01-22 18:26:30 +0000
4@@ -152,6 +152,10 @@
5 #define REFRESH_USER_STATS 0x800000L /* Refresh user stats my_hash table */
6 #define REFRESH_CLIENT_STATS 0x1000000L /* Refresh client stats my_hash table */
7 #define REFRESH_THREAD_STATS 0x2000000L /* Refresh thread stats my_hash table */
8+#define REFRESH_FLUSH_PAGE_BITMAPS 0x400000L
9+#define REFRESH_RESET_PAGE_BITMAPS 0x800000L
10+
11+#define PURGE_BITMAPS_TO_LSN 1
12
13 #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
14 #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
15
16=== removed file 'Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc'
17--- Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc 2012-11-25 09:30:58 +0000
18+++ Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc 1970-01-01 00:00:00 +0000
19@@ -1,11 +0,0 @@
20-# Remove all the InnoDB bitmap files. A temporary measure until RESET user request is implemented
21-
22-let $MYSQLD_DATADIR= `select @@datadir`;
23-
24---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
25---shutdown_server 10
26---source include/wait_until_disconnected.inc
27-remove_files_wildcard $MYSQLD_DATADIR ib_modified_log*;
28---enable_reconnect
29---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
30---source include/wait_until_connected_again.inc
31
32=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result'
33--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result 2012-11-25 09:30:58 +0000
34+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result 2013-01-22 18:26:30 +0000
35@@ -1,3 +1,4 @@
36+RESET CHANGED_PAGE_BITMAPS;
37 DROP TABLE IF EXISTS t1, t2;
38 CREATE TABLE t1 (x INT) ENGINE=InnoDB;
39 INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
40
41=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result'
42--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result 2012-11-25 09:30:58 +0000
43+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result 2013-01-22 18:26:30 +0000
44@@ -1,3 +1,4 @@
45+RESET CHANGED_PAGE_BITMAPS;
46 DROP TABLE IF EXISTS t1, t2;
47 CREATE TABLE t1 (x INT) ENGINE=InnoDB;
48 INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
49
50=== added file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result'
51--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result 1970-01-01 00:00:00 +0000
52+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result 2013-01-22 18:26:30 +0000
53@@ -0,0 +1,76 @@
54+RESET CHANGED_PAGE_BITMAPS;
55+DROP TABLE IF EXISTS t1;
56+DELETE FROM mysql.user WHERE USER='mysqltest_1';
57+FLUSH PRIVILEGES;
58+CREATE TABLE t1 (x INT) ENGINE=InnoDB;
59+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
60+FLUSH CHANGED_PAGE_BITMAPS;
61+Before RESET:
62+ib_modified_log_1
63+ib_modified_log_2
64+RESET CHANGED_PAGE_BITMAPS;
65+After RESET:
66+ib_modified_log_1
67+RESET CHANGED_PAGE_BITMAPS;
68+After 2nd RESET
69+ib_modified_log_1
70+After RESETs and restart:
71+ib_modified_log_1
72+ib_modified_log_2
73+PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
74+After PURGE ... BEFORE 1:
75+ib_modified_log_2
76+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
77+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
78+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
79+After PURGE ... BEFORE 100000000 and restart:
80+ib_modified_log_4
81+ib_modified_log_5
82+PURGE CHANGED_PAGE_BITMAPS BEFORE 5+5;
83+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+5' at line 1
84+PURGE CHANGED_PAGE_BITMAPS BEFORE -12;
85+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-12' at line 1
86+PURGE CHANGED_PAGE_BITMAPS BEFORE 1.2e-2;
87+ERROR 42000: Only integers allowed as number here near '1.2e-2' at line 1
88+PURGE CHANGED_PAGE_BITMAPS BEFORE t1;
89+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1' at line 1
90+PURGE CHANGED_PAGE_BITMAPS BEFORE "t1";
91+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"t1"' at line 1
92+PURGE CHANGED_PAGE_BITMAPS BEFORE TRUE;
93+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRUE' at line 1
94+PURGE CHANGED_PAGE_BITMAPS BEFORE NULL;
95+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
96+CREATE USER mysqltest_1@localhost;
97+GRANT ALL ON *.* TO mysqltest_1@localhost;
98+REVOKE SUPER ON *.* FROM mysqltest_1@localhost;
99+FLUSH CHANGED_PAGE_BITMAPS;
100+ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
101+RESET CHANGED_PAGE_BITMAPS;
102+ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
103+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
104+ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
105+DROP USER mysqltest_1@localhost;
106+SELECT @@GLOBAL.innodb_track_changed_pages;
107+@@GLOBAL.innodb_track_changed_pages
108+0
109+FLUSH CHANGED_PAGE_BITMAPS;
110+Before the PURGE with tracking disabled
111+ib_modified_log_4
112+ib_modified_log_5
113+PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
114+After the PURGE that deletes nothing:
115+ib_modified_log_4
116+ib_modified_log_5
117+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
118+After the PURGE that deletes everything:
119+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
120+After the repeated PURGE:
121+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
122+Before the RESET while tracking disabled:
123+ib_modified_log_1
124+ib_modified_log_2
125+RESET CHANGED_PAGE_BITMAPS;
126+After the RESET with tracking disabled:
127+DROP TABLE t1;
128+CREATE TABLE CHANGED_PAGE_BITMAPS (a INT);
129+DROP TABLE CHANGED_PAGE_BITMAPS;
130
131=== added file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result'
132--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result 1970-01-01 00:00:00 +0000
133+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result 2013-01-22 18:26:30 +0000
134@@ -0,0 +1,3 @@
135+FLUSH CHANGED_PAGE_BITMAPS;
136+RESET CHANGED_PAGE_BITMAPS;
137+PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
138
139=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result'
140--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result 2012-11-25 09:30:58 +0000
141+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result 2013-01-22 18:26:30 +0000
142@@ -1,3 +1,4 @@
143+RESET CHANGED_PAGE_BITMAPS;
144 DROP TABLE IF EXISTS T1;
145 CREATE TABLE T1 (F1 CHAR(255)) ENGINE=INNODB;
146 1st interval end LSN greater than interval start LSN:
147
148=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test'
149--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test 2012-11-25 09:30:58 +0000
150+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test 2013-01-22 18:26:30 +0000
151@@ -13,7 +13,9 @@
152 # Valgrind reports useless errors on very fast server shutdowns
153 --source include/not_valgrind.inc
154
155---source include/delete_innodb_bitmaps.inc
156+# Delete any existing bitmaps
157+--source include/restart_mysqld.inc
158+RESET CHANGED_PAGE_BITMAPS;
159
160 --disable_warnings
161 DROP TABLE IF EXISTS t1, t2;
162
163=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test'
164--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test 2012-11-25 09:30:58 +0000
165+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test 2013-01-22 18:26:30 +0000
166@@ -2,7 +2,9 @@
167 # percona_changed_page_bmp test, which contains the full functional tests.
168 --source include/have_innodb.inc
169
170---source include/delete_innodb_bitmaps.inc
171+# Delete any existing bitmaps
172+--source include/restart_mysqld.inc
173+RESET CHANGED_PAGE_BITMAPS;
174
175 --disable_warnings
176 DROP TABLE IF EXISTS t1, t2;
177
178=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt'
179--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt 1970-01-01 00:00:00 +0000
180+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt 2013-01-22 18:26:30 +0000
181@@ -0,0 +1,1 @@
182+--innodb_track_changed_pages=TRUE
183
184=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test'
185--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test 1970-01-01 00:00:00 +0000
186+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test 2013-01-22 18:26:30 +0000
187@@ -0,0 +1,200 @@
188+#
189+# Tests for changed page tracking bitmaps: user requests.
190+#
191+--source include/have_innodb.inc
192+
193+# Delete any existing bitmaps
194+--source include/restart_mysqld.inc
195+RESET CHANGED_PAGE_BITMAPS;
196+
197+--source include/count_sessions.inc
198+
199+let $MYSQLD_DATADIR= `select @@datadir`;
200+
201+--disable_warnings
202+DROP TABLE IF EXISTS t1;
203+DELETE FROM mysql.user WHERE USER='mysqltest_1';
204+FLUSH PRIVILEGES;
205+--enable_warnings
206+
207+CREATE TABLE t1 (x INT) ENGINE=InnoDB;
208+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
209+
210+#
211+# Test FLUSH CHANGED_PAGE_BITMAPS. Not much to test due to checkpointing non-determinism,
212+# just see that it does not crash or return an error
213+#
214+FLUSH CHANGED_PAGE_BITMAPS;
215+
216+#
217+# Test that RESET CHANGED_PAGE_BITMAPS works
218+#
219+
220+# Have at least two bitmap files
221+--source include/restart_mysqld.inc
222+
223+--echo Before RESET:
224+--replace_regex /_[[:digit:]]+\.xdb$//
225+list_files $MYSQLD_DATADIR ib_modified_log*;
226+
227+RESET CHANGED_PAGE_BITMAPS;
228+
229+--echo After RESET:
230+--replace_regex /_[[:digit:]]+\.xdb$//
231+list_files $MYSQLD_DATADIR ib_modified_log*;
232+
233+# Test consecutive RESET
234+RESET CHANGED_PAGE_BITMAPS;
235+--echo After 2nd RESET
236+--replace_regex /_[[:digit:]]+\.xdb$//
237+list_files $MYSQLD_DATADIR ib_modified_log*;
238+
239+# Check that the file sequence after RESET starts with 1 again
240+--source include/restart_mysqld.inc
241+
242+--echo After RESETs and restart:
243+--replace_regex /_[[:digit:]]+\.xdb$//
244+list_files $MYSQLD_DATADIR ib_modified_log*;
245+
246+#
247+# Test that PURGE CHANGED_PAGE_BITMAPS BEFORE works. We don't test partial PURGE
248+# because it's hard to extract good LSN value for that.
249+#
250+
251+# PURGE that deletes nothing
252+PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
253+--echo After PURGE ... BEFORE 1:
254+--replace_regex /_[[:digit:]]+\.xdb$//
255+list_files $MYSQLD_DATADIR ib_modified_log*;
256+
257+# PURGE that deletes everything
258+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
259+# Test consecutive PURGE
260+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
261+
262+# Check that file sequence continues
263+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
264+--source include/restart_mysqld.inc
265+--echo After PURGE ... BEFORE 100000000 and restart:
266+--replace_regex /_[[:digit:]]+\.xdb$//
267+list_files $MYSQLD_DATADIR ib_modified_log*;
268+
269+#
270+# Test malformed PURGE ... BEFORE
271+#
272+--error ER_PARSE_ERROR
273+PURGE CHANGED_PAGE_BITMAPS BEFORE 5+5;
274+
275+--error ER_PARSE_ERROR
276+PURGE CHANGED_PAGE_BITMAPS BEFORE -12;
277+
278+--error ER_PARSE_ERROR
279+PURGE CHANGED_PAGE_BITMAPS BEFORE 1.2e-2;
280+
281+--error ER_PARSE_ERROR
282+PURGE CHANGED_PAGE_BITMAPS BEFORE t1;
283+
284+--error ER_PARSE_ERROR
285+PURGE CHANGED_PAGE_BITMAPS BEFORE "t1";
286+
287+--error ER_PARSE_ERROR
288+PURGE CHANGED_PAGE_BITMAPS BEFORE TRUE;
289+
290+--error ER_PARSE_ERROR
291+PURGE CHANGED_PAGE_BITMAPS BEFORE NULL;
292+
293+#
294+# Test that non-privileged users cannot issue user requests
295+#
296+CREATE USER mysqltest_1@localhost;
297+GRANT ALL ON *.* TO mysqltest_1@localhost;
298+REVOKE SUPER ON *.* FROM mysqltest_1@localhost;
299+
300+connect (conn1,localhost,mysqltest_1,,);
301+
302+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
303+FLUSH CHANGED_PAGE_BITMAPS;
304+
305+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
306+RESET CHANGED_PAGE_BITMAPS;
307+
308+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
309+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
310+
311+connection default;
312+disconnect conn1;
313+
314+--source include/wait_until_count_sessions.inc
315+
316+DROP USER mysqltest_1@localhost;
317+
318+#
319+# Test FLUSH and PURGE requests with log tracking disabled
320+#
321+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
322+--shutdown_server 10
323+--source include/wait_until_disconnected.inc
324+--enable_reconnect
325+--exec echo "restart:--innodb_track_changed_pages=FALSE" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
326+--source include/wait_until_connected_again.inc
327+
328+SELECT @@GLOBAL.innodb_track_changed_pages;
329+
330+FLUSH CHANGED_PAGE_BITMAPS;
331+
332+# The previous bitmap files should be present
333+--echo Before the PURGE with tracking disabled
334+--replace_regex /_[[:digit:]]+\.xdb$//
335+list_files $MYSQLD_DATADIR ib_modified_log*;
336+
337+PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
338+
339+--echo After the PURGE that deletes nothing:
340+--replace_regex /_[[:digit:]]+\.xdb$//
341+list_files $MYSQLD_DATADIR ib_modified_log*;
342+
343+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
344+
345+--echo After the PURGE that deletes everything:
346+--replace_regex /_[[:digit:]]+\.xdb$//
347+list_files $MYSQLD_DATADIR ib_modified_log*;
348+
349+PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
350+
351+--echo After the repeated PURGE:
352+--replace_regex /_[[:digit:]]+\.xdb$//
353+list_files $MYSQLD_DATADIR ib_modified_log*;
354+
355+#
356+# Test RESET request with log tracking disabled
357+#
358+
359+# Generate some bitmap data again
360+--source include/restart_mysqld.inc
361+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
362+--source include/restart_mysqld.inc
363+
364+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
365+--shutdown_server 10
366+--source include/wait_until_disconnected.inc
367+--enable_reconnect
368+--exec echo "restart:--innodb_track_changed_pages=FALSE" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
369+--source include/wait_until_connected_again.inc
370+
371+--echo Before the RESET while tracking disabled:
372+--replace_regex /_[[:digit:]]+\.xdb$//
373+list_files $MYSQLD_DATADIR ib_modified_log*;
374+
375+RESET CHANGED_PAGE_BITMAPS;
376+
377+--echo After the RESET with tracking disabled:
378+--replace_regex /_[[:digit:]]+\.xdb$//
379+list_files $MYSQLD_DATADIR ib_modified_log*;
380+
381+DROP TABLE t1;
382+
383+#
384+# Test that the new keyword does not preclude its use as identifier
385+#
386+CREATE TABLE CHANGED_PAGE_BITMAPS (a INT);
387+DROP TABLE CHANGED_PAGE_BITMAPS;
388
389=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt'
390--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt 1970-01-01 00:00:00 +0000
391+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt 2013-01-22 18:26:30 +0000
392@@ -0,0 +1,1 @@
393+--skip-innodb
394
395=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test'
396--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test 1970-01-01 00:00:00 +0000
397+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test 2013-01-22 18:26:30 +0000
398@@ -0,0 +1,7 @@
399+#
400+# Test that changed page tracking user requests are parsed without InnoDB
401+#
402+FLUSH CHANGED_PAGE_BITMAPS;
403+RESET CHANGED_PAGE_BITMAPS;
404+PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
405+
406
407=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test'
408--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test 2012-11-25 09:30:58 +0000
409+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test 2013-01-22 18:26:30 +0000
410@@ -4,7 +4,9 @@
411
412 --source include/have_innodb.inc
413
414---source include/delete_innodb_bitmaps.inc
415+# Delete any existing bitmaps
416+--source include/restart_mysqld.inc
417+RESET CHANGED_PAGE_BITMAPS;
418
419 --disable_warnings
420 DROP TABLE IF EXISTS T1;
421
422=== modified file 'Percona-Server/sql/handler.cc'
423--- Percona-Server/sql/handler.cc 2013-01-17 22:50:22 +0000
424+++ Percona-Server/sql/handler.cc 2013-01-22 18:26:30 +0000
425@@ -5125,6 +5125,42 @@
426 return result;
427 }
428
429+static my_bool flush_changed_page_bitmaps_handlerton(THD *unused1,
430+ plugin_ref plugin,
431+ void *unused2)
432+{
433+ handlerton *hton= plugin_data(plugin, handlerton *);
434+
435+ if (hton->flush_changed_page_bitmaps == NULL)
436+ return FALSE;
437+
438+ return hton->flush_changed_page_bitmaps();
439+}
440+
441+bool ha_flush_changed_page_bitmaps()
442+{
443+ return plugin_foreach(NULL, flush_changed_page_bitmaps_handlerton,
444+ MYSQL_STORAGE_ENGINE_PLUGIN, NULL);
445+}
446+
447+static my_bool purge_changed_page_bitmaps_handlerton(THD *unused1,
448+ plugin_ref plugin,
449+ void *lsn)
450+{
451+ handlerton *hton= plugin_data(plugin, handlerton *);
452+
453+ if (hton->purge_changed_page_bitmaps == NULL)
454+ return FALSE;
455+
456+ return hton->purge_changed_page_bitmaps(*(ulonglong *)lsn);
457+}
458+
459+bool ha_purge_changed_page_bitmaps(ulonglong lsn)
460+{
461+ return plugin_foreach(NULL, purge_changed_page_bitmaps_handlerton,
462+ MYSQL_STORAGE_ENGINE_PLUGIN, &lsn);
463+}
464+
465 /*
466 Function to check if the conditions for row-based binlogging is
467 correct for the table.
468
469=== modified file 'Percona-Server/sql/handler.h'
470--- Percona-Server/sql/handler.h 2013-01-09 23:45:25 +0000
471+++ Percona-Server/sql/handler.h 2013-01-22 18:26:30 +0000
472@@ -842,6 +842,8 @@
473 int (*fill_is_table)(handlerton *hton, THD *thd, TABLE_LIST *tables,
474 class Item *cond,
475 enum enum_schema_tables);
476+ my_bool (*flush_changed_page_bitmaps)(void);
477+ my_bool (*purge_changed_page_bitmaps)(ulonglong lsn);
478 uint32 flags; /* global handler flags */
479 /*
480 Those handlerton functions below are properly initialized at handler
481@@ -2390,6 +2392,9 @@
482 int ha_prepare(THD *thd);
483 int ha_recover(HASH *commit_list);
484
485+bool ha_flush_changed_page_bitmaps();
486+bool ha_purge_changed_page_bitmaps(ulonglong lsn);
487+
488 /* transactions: these functions never call handlerton functions directly */
489 int ha_enable_transaction(THD *thd, bool on);
490
491
492=== modified file 'Percona-Server/sql/lex.h'
493--- Percona-Server/sql/lex.h 2012-05-10 07:49:14 +0000
494+++ Percona-Server/sql/lex.h 2013-01-22 18:26:30 +0000
495@@ -103,6 +103,7 @@
496 { "CHAIN", SYM(CHAIN_SYM)},
497 { "CHANGE", SYM(CHANGE)},
498 { "CHANGED", SYM(CHANGED)},
499+ { "CHANGED_PAGE_BITMAPS", SYM(CHANGED_PAGE_BITMAPS_SYM)},
500 { "CHAR", SYM(CHAR_SYM)},
501 { "CHARACTER", SYM(CHAR_SYM)},
502 { "CHARSET", SYM(CHARSET)},
503
504=== modified file 'Percona-Server/sql/sql_parse.cc'
505--- Percona-Server/sql/sql_parse.cc 2013-01-09 23:45:25 +0000
506+++ Percona-Server/sql/sql_parse.cc 2013-01-22 18:26:30 +0000
507@@ -2320,9 +2320,35 @@
508 {
509 if (check_global_access(thd, SUPER_ACL))
510 goto error;
511- /* PURGE MASTER LOGS TO 'file' */
512- res = purge_master_logs(thd, lex->to_log);
513- break;
514+ if (lex->type == 0)
515+ {
516+ /* PURGE MASTER LOGS TO 'file' */
517+ res = purge_master_logs(thd, lex->to_log);
518+ break;
519+ }
520+ if (lex->type == PURGE_BITMAPS_TO_LSN)
521+ {
522+ /* PURGE CHANGED_PAGE_BITMAPS BEFORE lsn */
523+ ulonglong lsn= 0;
524+ Item *it= (Item *)lex->value_list.head();
525+ if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1)
526+ || it->null_value)
527+ {
528+ my_error(ER_WRONG_ARGUMENTS, MYF(0),
529+ "PURGE CHANGED_PAGE_BITMAPS BEFORE");
530+ goto error;
531+ }
532+ lsn= it->val_uint();
533+ res= ha_purge_changed_page_bitmaps(lsn);
534+ if (res)
535+ {
536+ my_error(ER_LOG_PURGE_UNKNOWN_ERR, MYF(0),
537+ "PURGE CHANGED_PAGE_BITMAPS BEFORE");
538+ goto error;
539+ }
540+ my_ok(thd);
541+ break;
542+ }
543 }
544 case SQLCOM_PURGE_BEFORE:
545 {
546@@ -3782,7 +3808,14 @@
547 case SQLCOM_FLUSH:
548 {
549 int write_to_binlog;
550- if (check_global_access(thd,RELOAD_ACL))
551+
552+ if (lex->type & REFRESH_FLUSH_PAGE_BITMAPS
553+ || lex->type & REFRESH_RESET_PAGE_BITMAPS)
554+ {
555+ if (check_global_access(thd, SUPER_ACL))
556+ goto error;
557+ }
558+ else if (check_global_access(thd, RELOAD_ACL))
559 goto error;
560
561 if (first_table && lex->type & REFRESH_READ_LOCK)
562
563=== modified file 'Percona-Server/sql/sql_reload.cc'
564--- Percona-Server/sql/sql_reload.cc 2012-04-18 23:26:01 +0000
565+++ Percona-Server/sql/sql_reload.cc 2013-01-22 18:26:30 +0000
566@@ -362,6 +362,22 @@
567 }
568 mysql_mutex_unlock(&LOCK_global_user_client_stats);
569 }
570+ if (options & REFRESH_FLUSH_PAGE_BITMAPS)
571+ {
572+ result= ha_flush_changed_page_bitmaps();
573+ if (result)
574+ {
575+ my_error(ER_UNKNOWN_ERROR, MYF(0), "FLUSH CHANGED_PAGE_BITMAPS");
576+ }
577+ }
578+ if (options & REFRESH_RESET_PAGE_BITMAPS)
579+ {
580+ result= ha_purge_changed_page_bitmaps(0);
581+ if (result)
582+ {
583+ my_error(ER_UNKNOWN_ERROR, MYF(0), "RESET CHANGED_PAGE_BITMAPS");
584+ }
585+ }
586 if (*write_to_binlog != -1)
587 *write_to_binlog= tmp_write_to_binlog;
588 /*
589
590=== modified file 'Percona-Server/sql/sql_yacc.yy'
591--- Percona-Server/sql/sql_yacc.yy 2013-01-09 23:45:25 +0000
592+++ Percona-Server/sql/sql_yacc.yy 2013-01-22 18:26:30 +0000
593@@ -858,6 +858,7 @@
594 %token CHAIN_SYM /* SQL-2003-N */
595 %token CHANGE
596 %token CHANGED
597+%token CHANGED_PAGE_BITMAPS_SYM /* MYSQL */
598 %token CHARSET
599 %token CHAR_SYM /* SQL-2003-R */
600 %token CHECKSUM_SYM
601@@ -11457,6 +11458,8 @@
602 { Lex->type|= REFRESH_DES_KEY_FILE; }
603 | RESOURCES
604 { Lex->type|= REFRESH_USER_RESOURCES; }
605+ | CHANGED_PAGE_BITMAPS_SYM
606+ { Lex->type|= REFRESH_FLUSH_PAGE_BITMAPS; }
607 ;
608
609 opt_table_list:
610@@ -11484,6 +11487,8 @@
611 slave_reset_options { }
612 | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
613 | QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}
614+ | CHANGED_PAGE_BITMAPS_SYM
615+ { Lex->type |= REFRESH_RESET_PAGE_BITMAPS; }
616 ;
617
618 slave_reset_options:
619@@ -11504,6 +11509,13 @@
620
621 purge_options:
622 master_or_binary LOGS_SYM purge_option
623+ | CHANGED_PAGE_BITMAPS_SYM BEFORE_SYM real_ulonglong_num
624+ {
625+ LEX *lex= Lex;
626+ lex->value_list.empty();
627+ lex->value_list.push_front(new Item_uint($3));
628+ lex->type= PURGE_BITMAPS_TO_LSN;
629+ }
630 ;
631
632 purge_option:
633@@ -12594,6 +12606,7 @@
634 | CATALOG_NAME_SYM {}
635 | CHAIN_SYM {}
636 | CHANGED {}
637+ | CHANGED_PAGE_BITMAPS_SYM {}
638 | CIPHER_SYM {}
639 | CLIENT_STATS_SYM {}
640 | CLIENT_SYM {}
641
642=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
643--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-01-18 03:34:53 +0000
644+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-01-22 18:26:30 +0000
645@@ -85,6 +85,7 @@
646 #include "row0sel.h"
647 #include "row0upd.h"
648 #include "log0log.h"
649+#include "log0online.h"
650 #include "lock0lock.h"
651 #include "dict0crea.h"
652 #include "btr0cur.h"
653@@ -297,6 +298,7 @@
654 {&ibuf_pessimistic_insert_mutex_key,
655 "ibuf_pessimistic_insert_mutex", 0},
656 {&kernel_mutex_key, "kernel_mutex", 0},
657+ {&log_bmp_sys_mutex_key, "log_bmp_sys_mutex", 0},
658 {&log_sys_mutex_key, "log_sys_mutex", 0},
659 # ifdef UNIV_MEM_DEBUG
660 {&mem_hash_mutex_key, "mem_hash_mutex", 0},
661@@ -438,6 +440,25 @@
662 innobase_alter_table_flags(
663 /*=======================*/
664 uint flags);
665+/************************************************************//**
666+Synchronously read and parse the redo log up to the last
667+checkpoint to write the changed page bitmap.
668+@return 0 to indicate success. Current implementation cannot fail. */
669+static
670+my_bool
671+innobase_flush_changed_page_bitmaps();
672+/*==================================*/
673+/************************************************************//**
674+Delete all the bitmap files for data less than the specified LSN.
675+If called with lsn == 0 (i.e. set by RESET request) or
676+IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
677+continue it.
678+@return 0 to indicate success, 1 for failure. */
679+static
680+my_bool
681+innobase_purge_changed_page_bitmaps(
682+/*================================*/
683+ ulonglong lsn); /*!< in: LSN to purge files up to */
684
685 static const char innobase_hton_name[]= "InnoDB";
686
687@@ -2663,6 +2684,10 @@
688 innobase_hton->flags=HTON_NO_FLAGS;
689 innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
690 innobase_hton->alter_table_flags = innobase_alter_table_flags;
691+ innobase_hton->flush_changed_page_bitmaps
692+ = innobase_flush_changed_page_bitmaps;
693+ innobase_hton->purge_changed_page_bitmaps
694+ = innobase_purge_changed_page_bitmaps;
695
696 ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
697
698@@ -3282,6 +3307,36 @@
699 | HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE);
700 }
701
702+/************************************************************//**
703+Synchronously read and parse the redo log up to the last
704+checkpoint to write the changed page bitmap.
705+@return 0 to indicate success. Current implementation cannot fail. */
706+static
707+my_bool
708+innobase_flush_changed_page_bitmaps()
709+/*=================================*/
710+{
711+ if (srv_track_changed_pages) {
712+ os_event_reset(srv_checkpoint_completed_event);
713+ log_online_follow_redo_log();
714+ }
715+ return FALSE;
716+}
717+
718+/************************************************************//**
719+Delete all the bitmap files for data less than the specified LSN.
720+If called with lsn == IB_ULONGLONG_MAX (i.e. set by RESET request),
721+restart the bitmap file sequence, otherwise continue it.
722+@return 0 to indicate success, 1 for failure. */
723+static
724+my_bool
725+innobase_purge_changed_page_bitmaps(
726+/*================================*/
727+ ulonglong lsn) /*!< in: LSN to purge files up to */
728+{
729+ return (my_bool)log_online_purge_changed_page_bitmaps(lsn);
730+}
731+
732 /****************************************************************//**
733 Copy the current replication position from MySQL to a transaction. */
734 static
735
736=== modified file 'Percona-Server/storage/innobase/include/log0online.h'
737--- Percona-Server/storage/innobase/include/log0online.h 2012-11-25 09:29:43 +0000
738+++ Percona-Server/storage/innobase/include/log0online.h 2013-01-22 18:26:30 +0000
739@@ -41,23 +41,49 @@
740 Initializes the online log following subsytem. */
741 UNIV_INTERN
742 void
743-log_online_read_init();
744-/*===================*/
745+log_online_read_init(void);
746+/*=======================*/
747
748 /*********************************************************************//**
749 Shuts down the online log following subsystem. */
750 UNIV_INTERN
751 void
752-log_online_read_shutdown();
753-/*=======================*/
754+log_online_read_shutdown(void);
755+/*===========================*/
756
757 /*********************************************************************//**
758 Reads and parses the redo log up to last checkpoint LSN to build the changed
759 page bitmap which is then written to disk. */
760 UNIV_INTERN
761 void
762-log_online_follow_redo_log();
763-/*=========================*/
764+log_online_follow_redo_log(void);
765+/*=============================*/
766+
767+/************************************************************//**
768+Delete all the bitmap files for data less than the specified LSN.
769+If called with lsn == 0 (i.e. set by RESET request) or
770+IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
771+continue it.
772+
773+@return FALSE to indicate success, TRUE for failure. */
774+UNIV_INTERN
775+ibool
776+log_online_purge_changed_page_bitmaps(
777+/*==================================*/
778+ ib_uint64_t lsn); /*!<in: LSN to purge files up to */
779+
780+/************************************************************//**
781+Delete all the bitmap files for data less than the specified LSN.
782+If called with lsn == 0 (i.e. set by RESET request) or
783+IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
784+continue it.
785+
786+@return FALSE to indicate success, TRUE for failure. */
787+UNIV_INTERN
788+ibool
789+log_online_purge_changed_page_bitmaps(
790+/*==================================*/
791+ ib_uint64_t lsn); /*!<in: LSN to purge files up to */
792
793 #define LOG_BITMAP_ITERATOR_START_LSN(i) \
794 ((i).start_lsn)
795
796=== modified file 'Percona-Server/storage/innobase/include/sync0sync.h'
797--- Percona-Server/storage/innobase/include/sync0sync.h 2012-05-10 07:49:14 +0000
798+++ Percona-Server/storage/innobase/include/sync0sync.h 2013-01-22 18:26:30 +0000
799@@ -89,6 +89,7 @@
800 extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
801 extern mysql_pfs_key_t ibuf_mutex_key;
802 extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
803+extern mysql_pfs_key_t log_bmp_sys_mutex_key;
804 extern mysql_pfs_key_t log_sys_mutex_key;
805 extern mysql_pfs_key_t log_flush_order_mutex_key;
806 extern mysql_pfs_key_t kernel_mutex_key;
807@@ -672,6 +673,7 @@
808 #define SYNC_TRX_LOCK_HEAP 298
809 #define SYNC_TRX_SYS_HEADER 290
810 #define SYNC_PURGE_QUEUE 200
811+#define SYNC_LOG_ONLINE 175
812 #define SYNC_LOG 170
813 #define SYNC_LOG_FLUSH_ORDER 156
814 #define SYNC_RECV 168
815
816=== modified file 'Percona-Server/storage/innobase/log/log0online.c'
817--- Percona-Server/storage/innobase/log/log0online.c 2013-01-04 15:24:45 +0000
818+++ Percona-Server/storage/innobase/log/log0online.c 2013-01-22 18:26:30 +0000
819@@ -36,6 +36,11 @@
820
821 enum { FOLLOW_SCAN_SIZE = 4 * (UNIV_PAGE_SIZE_MAX) };
822
823+#ifdef UNIV_PFS_MUTEX
824+/* Key to register log_bmp_sys->mutex with PFS */
825+UNIV_INTERN mysql_pfs_key_t log_bmp_sys_mutex_key;
826+#endif /* UNIV_PFS_MUTEX */
827+
828 /** Log parsing and bitmap output data structure */
829 struct log_bitmap_struct {
830 byte read_buf[FOLLOW_SCAN_SIZE];
831@@ -69,6 +74,7 @@
832 both the correct type and the tree does
833 not mind its overwrite during
834 rbt_next() tree traversal. */
835+ mutex_t mutex; /*!< mutex protecting all the fields.*/
836 };
837
838 /* The log parsing and bitmap output struct instance */
839@@ -172,6 +178,8 @@
840 byte search_page[MODIFIED_PAGE_BLOCK_SIZE];
841 byte *page_ptr;
842
843+ ut_ad(mutex_own(&log_bmp_sys->mutex));
844+
845 ut_a(space != ULINT_UNDEFINED);
846 ut_a(page_no != ULINT_UNDEFINED);
847
848@@ -312,8 +320,8 @@
849 @return the last fully tracked LSN */
850 static
851 ib_uint64_t
852-log_online_read_last_tracked_lsn()
853-/*==============================*/
854+log_online_read_last_tracked_lsn(void)
855+/*==================================*/
856 {
857 byte page[MODIFIED_PAGE_BLOCK_SIZE];
858 ibool is_last_page = FALSE;
859@@ -487,8 +495,8 @@
860 Create a new empty bitmap output file. */
861 static
862 void
863-log_online_start_bitmap_file()
864-/*==========================*/
865+log_online_start_bitmap_file(void)
866+/*==============================*/
867 {
868 ibool success;
869
870@@ -518,7 +526,10 @@
871 ib_uint64_t next_file_start_lsn) /*!<in: the start LSN name
872 part */
873 {
874- os_file_close(log_bmp_sys->out.file);
875+ if (log_bmp_sys->out.file != -1) {
876+ os_file_close(log_bmp_sys->out.file);
877+ log_bmp_sys->out.file = -1;
878+ }
879 log_bmp_sys->out_seq_num++;
880 log_online_make_bitmap_name(next_file_start_lsn);
881 log_online_start_bitmap_file();
882@@ -556,8 +567,8 @@
883 Initialize the online log following subsytem. */
884 UNIV_INTERN
885 void
886-log_online_read_init()
887-/*==================*/
888+log_online_read_init(void)
889+/*======================*/
890 {
891 ibool success;
892 ib_uint64_t tracking_start_lsn
893@@ -566,13 +577,16 @@
894 os_file_stat_t bitmap_dir_file_info;
895 ib_uint64_t last_file_start_lsn = MIN_TRACKED_LSN;
896
897- /* Assert (could be compile-time assert) that bitmap data start and end
898- in a bitmap block is 8-byte aligned */
899- ut_a(MODIFIED_PAGE_BLOCK_BITMAP % 8 == 0);
900- ut_a(MODIFIED_PAGE_BLOCK_BITMAP_LEN % 8 == 0);
901+ /* Bitmap data start and end in a bitmap block must be 8-byte
902+ aligned. */
903+ compile_time_assert(MODIFIED_PAGE_BLOCK_BITMAP % 8 == 0);
904+ compile_time_assert(MODIFIED_PAGE_BLOCK_BITMAP_LEN % 8 == 0);
905
906 log_bmp_sys = ut_malloc(sizeof(*log_bmp_sys));
907
908+ mutex_create(log_bmp_sys_mutex_key, &log_bmp_sys->mutex,
909+ SYNC_LOG_ONLINE);
910+
911 /* Enumerate existing bitmap files to either open the last one to get
912 the last tracked LSN either to find that there are none and start
913 tracking from scratch. */
914@@ -701,12 +715,15 @@
915 Shut down the online log following subsystem. */
916 UNIV_INTERN
917 void
918-log_online_read_shutdown()
919-/*======================*/
920+log_online_read_shutdown(void)
921+/*==========================*/
922 {
923 ib_rbt_node_t *free_list_node = log_bmp_sys->page_free_list;
924
925- os_file_close(log_bmp_sys->out.file);
926+ if (log_bmp_sys->out.file != -1) {
927+ os_file_close(log_bmp_sys->out.file);
928+ log_bmp_sys->out.file = -1;
929+ }
930
931 rbt_free(log_bmp_sys->modified_pages);
932
933@@ -716,6 +733,8 @@
934 free_list_node = next;
935 }
936
937+ mutex_free(&log_bmp_sys->mutex);
938+
939 ut_free(log_bmp_sys);
940 }
941
942@@ -759,14 +778,16 @@
943 buffer. */
944 static
945 void
946-log_online_parse_redo_log()
947-/*=======================*/
948+log_online_parse_redo_log(void)
949+/*===========================*/
950 {
951 byte *ptr = log_bmp_sys->parse_buf;
952 byte *end = log_bmp_sys->parse_buf_end;
953
954 ulint len = 0;
955
956+ ut_ad(mutex_own(&log_bmp_sys->mutex));
957+
958 while (ptr != end
959 && log_bmp_sys->next_parse_lsn < log_bmp_sys->end_lsn) {
960
961@@ -857,6 +878,8 @@
962 ulint actual_data_len = (end_offset >= start_offset)
963 ? end_offset - start_offset : 0;
964
965+ ut_ad(mutex_own(&log_bmp_sys->mutex));
966+
967 ut_memcpy(log_bmp_sys->parse_buf_end, log_block + start_offset,
968 actual_data_len);
969
970@@ -881,6 +904,8 @@
971 {
972 ulint block_data_len;
973
974+ ut_ad(mutex_own(&log_bmp_sys->mutex));
975+
976 block_data_len = log_block_get_data_len(log_block);
977
978 ut_ad(block_data_len % OS_FILE_LOG_BLOCK_SIZE == 0
979@@ -907,6 +932,8 @@
980 byte* log_block_end = log_bmp_sys->read_buf
981 + (block_end_lsn - block_start_lsn);
982
983+ ut_ad(mutex_own(&log_bmp_sys->mutex));
984+
985 mutex_enter(&log_sys->mutex);
986 log_group_read_log_seg(LOG_RECOVER, log_bmp_sys->read_buf,
987 group, block_start_lsn, block_end_lsn);
988@@ -969,6 +996,8 @@
989 ib_uint64_t block_start_lsn = contiguous_lsn;
990 ib_uint64_t block_end_lsn;
991
992+ ut_ad(mutex_own(&log_bmp_sys->mutex));
993+
994 log_bmp_sys->next_parse_lsn = log_bmp_sys->start_lsn;
995 log_bmp_sys->parse_buf_end = log_bmp_sys->parse_buf;
996
997@@ -1005,6 +1034,8 @@
998 {
999 ibool success;
1000
1001+ ut_ad(mutex_own(&log_bmp_sys->mutex));
1002+
1003 success = os_file_write(log_bmp_sys->out.name, log_bmp_sys->out.file,
1004 block,
1005 (ulint)(log_bmp_sys->out.offset & 0xFFFFFFFF),
1006@@ -1038,12 +1069,14 @@
1007 bitmap tree and recycles its nodes to the free list. */
1008 static
1009 void
1010-log_online_write_bitmap()
1011-/*=====================*/
1012+log_online_write_bitmap(void)
1013+/*=========================*/
1014 {
1015 ib_rbt_node_t *bmp_tree_node;
1016 const ib_rbt_node_t *last_bmp_tree_node;
1017
1018+ ut_ad(mutex_own(&log_bmp_sys->mutex));
1019+
1020 if (log_bmp_sys->out.offset >= srv_max_bitmap_file_size) {
1021 log_online_rotate_bitmap_file(log_bmp_sys->start_lsn);
1022 }
1023@@ -1084,18 +1117,21 @@
1024 page bitmap which is then written to disk. */
1025 UNIV_INTERN
1026 void
1027-log_online_follow_redo_log()
1028-/*========================*/
1029+log_online_follow_redo_log(void)
1030+/*============================*/
1031 {
1032 ib_uint64_t contiguous_start_lsn;
1033 log_group_t* group;
1034
1035+ mutex_enter(&log_bmp_sys->mutex);
1036+
1037 /* Grab the LSN of the last checkpoint, we will parse up to it */
1038 mutex_enter(&(log_sys->mutex));
1039 log_bmp_sys->end_lsn = log_sys->last_checkpoint_lsn;
1040 mutex_exit(&(log_sys->mutex));
1041
1042 if (log_bmp_sys->end_lsn == log_bmp_sys->start_lsn) {
1043+ mutex_exit(&log_bmp_sys->mutex);
1044 return;
1045 }
1046
1047@@ -1117,6 +1153,8 @@
1048 log_online_write_bitmap();
1049 log_bmp_sys->start_lsn = log_bmp_sys->end_lsn;
1050 log_set_tracked_lsn(log_bmp_sys->start_lsn);
1051+
1052+ mutex_exit(&log_bmp_sys->mutex);
1053 }
1054
1055 /*********************************************************************//**
1056@@ -1514,3 +1552,76 @@
1057
1058 return TRUE;
1059 }
1060+
1061+/************************************************************//**
1062+Delete all the bitmap files for data less than the specified LSN.
1063+If called with lsn == 0 (i.e. set by RESET request) or
1064+IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
1065+continue it.
1066+
1067+@return FALSE to indicate success, TRUE for failure. */
1068+UNIV_INTERN
1069+ibool
1070+log_online_purge_changed_page_bitmaps(
1071+/*==================================*/
1072+ ib_uint64_t lsn) /*!< in: LSN to purge files up to */
1073+{
1074+ log_online_bitmap_file_range_t bitmap_files;
1075+ size_t i;
1076+ ibool result = FALSE;
1077+
1078+ if (lsn == 0) {
1079+ lsn = IB_ULONGLONG_MAX;
1080+ }
1081+
1082+ if (srv_track_changed_pages) {
1083+ /* User requests might happen with both enabled and disabled
1084+ tracking */
1085+ mutex_enter(&log_bmp_sys->mutex);
1086+ }
1087+
1088+ if (!log_online_setup_bitmap_file_range(&bitmap_files, 0, lsn)) {
1089+ if (srv_track_changed_pages) {
1090+ mutex_exit(&log_bmp_sys->mutex);
1091+ }
1092+ return TRUE;
1093+ }
1094+
1095+ if (srv_track_changed_pages && lsn >= log_bmp_sys->end_lsn) {
1096+ /* If we have to delete the current output file, close it
1097+ first. */
1098+ os_file_close(log_bmp_sys->out.file);
1099+ log_bmp_sys->out.file = -1;
1100+ }
1101+
1102+ for (i = 0; i < bitmap_files.count; i++) {
1103+ if (bitmap_files.files[i].seq_num == 0
1104+ || bitmap_files.files[i].start_lsn >= lsn) {
1105+ break;
1106+ }
1107+ if (!os_file_delete_if_exists(bitmap_files.files[i].name)) {
1108+ os_file_get_last_error(TRUE);
1109+ result = TRUE;
1110+ break;
1111+ }
1112+ }
1113+
1114+ if (srv_track_changed_pages) {
1115+ if (lsn > log_bmp_sys->end_lsn) {
1116+ if (lsn == IB_ULONGLONG_MAX) {
1117+ /* RESET restarts the sequence */
1118+ log_bmp_sys->out_seq_num = 0;
1119+ log_online_rotate_bitmap_file(0);
1120+ } else {
1121+ /* PURGE continues the sequence */
1122+ log_online_rotate_bitmap_file
1123+ (log_bmp_sys->end_lsn);
1124+ }
1125+ }
1126+
1127+ mutex_exit(&log_bmp_sys->mutex);
1128+ }
1129+
1130+ free(bitmap_files.files);
1131+ return result;
1132+}

Subscribers

People subscribed via source and target branches