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

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
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) Approve
Vlad Lesin Pending
Stewart Smith 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.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Typo in the id - it's 16274.

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

See comments in 5.1 branch.

review: Needs Fixing
Revision history for this message
Vlad Lesin (vlad-lesin) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
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
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal

Same comments/questions as in the 5.1 MP.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Percona-Server/include/mysql_com.h'
--- Percona-Server/include/mysql_com.h 2012-05-10 07:49:14 +0000
+++ Percona-Server/include/mysql_com.h 2013-01-22 18:26:30 +0000
@@ -152,6 +152,10 @@
152#define REFRESH_USER_STATS 0x800000L /* Refresh user stats my_hash table */152#define REFRESH_USER_STATS 0x800000L /* Refresh user stats my_hash table */
153#define REFRESH_CLIENT_STATS 0x1000000L /* Refresh client stats my_hash table */153#define REFRESH_CLIENT_STATS 0x1000000L /* Refresh client stats my_hash table */
154#define REFRESH_THREAD_STATS 0x2000000L /* Refresh thread stats my_hash table */154#define REFRESH_THREAD_STATS 0x2000000L /* Refresh thread stats my_hash table */
155#define REFRESH_FLUSH_PAGE_BITMAPS 0x400000L
156#define REFRESH_RESET_PAGE_BITMAPS 0x800000L
157
158#define PURGE_BITMAPS_TO_LSN 1
155159
156#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */160#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
157#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */161#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
158162
=== removed file 'Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc'
--- Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/include/delete_innodb_bitmaps.inc 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1# Remove all the InnoDB bitmap files. A temporary measure until RESET user request is implemented
2
3let $MYSQLD_DATADIR= `select @@datadir`;
4
5--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
6--shutdown_server 10
7--source include/wait_until_disconnected.inc
8remove_files_wildcard $MYSQLD_DATADIR ib_modified_log*;
9--enable_reconnect
10--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
11--source include/wait_until_connected_again.inc
120
=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result'
--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp.result 2013-01-22 18:26:30 +0000
@@ -1,3 +1,4 @@
1RESET CHANGED_PAGE_BITMAPS;
1DROP TABLE IF EXISTS t1, t2;2DROP TABLE IF EXISTS t1, t2;
2CREATE TABLE t1 (x INT) ENGINE=InnoDB;3CREATE TABLE t1 (x INT) ENGINE=InnoDB;
3INSERT INTO t1 VALUES (1),(2),(3),(4),(5);4INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
45
=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result'
--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_no_restart.result 2013-01-22 18:26:30 +0000
@@ -1,3 +1,4 @@
1RESET CHANGED_PAGE_BITMAPS;
1DROP TABLE IF EXISTS t1, t2;2DROP TABLE IF EXISTS t1, t2;
2CREATE TABLE t1 (x INT) ENGINE=InnoDB;3CREATE TABLE t1 (x INT) ENGINE=InnoDB;
3INSERT INTO t1 VALUES (1),(2),(3),(4),(5);4INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
45
=== added file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result'
--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests.result 2013-01-22 18:26:30 +0000
@@ -0,0 +1,76 @@
1RESET CHANGED_PAGE_BITMAPS;
2DROP TABLE IF EXISTS t1;
3DELETE FROM mysql.user WHERE USER='mysqltest_1';
4FLUSH PRIVILEGES;
5CREATE TABLE t1 (x INT) ENGINE=InnoDB;
6INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
7FLUSH CHANGED_PAGE_BITMAPS;
8Before RESET:
9ib_modified_log_1
10ib_modified_log_2
11RESET CHANGED_PAGE_BITMAPS;
12After RESET:
13ib_modified_log_1
14RESET CHANGED_PAGE_BITMAPS;
15After 2nd RESET
16ib_modified_log_1
17After RESETs and restart:
18ib_modified_log_1
19ib_modified_log_2
20PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
21After PURGE ... BEFORE 1:
22ib_modified_log_2
23PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
24PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
25INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
26After PURGE ... BEFORE 100000000 and restart:
27ib_modified_log_4
28ib_modified_log_5
29PURGE CHANGED_PAGE_BITMAPS BEFORE 5+5;
30ERROR 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
31PURGE CHANGED_PAGE_BITMAPS BEFORE -12;
32ERROR 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
33PURGE CHANGED_PAGE_BITMAPS BEFORE 1.2e-2;
34ERROR 42000: Only integers allowed as number here near '1.2e-2' at line 1
35PURGE CHANGED_PAGE_BITMAPS BEFORE t1;
36ERROR 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
37PURGE CHANGED_PAGE_BITMAPS BEFORE "t1";
38ERROR 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
39PURGE CHANGED_PAGE_BITMAPS BEFORE TRUE;
40ERROR 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
41PURGE CHANGED_PAGE_BITMAPS BEFORE NULL;
42ERROR 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
43CREATE USER mysqltest_1@localhost;
44GRANT ALL ON *.* TO mysqltest_1@localhost;
45REVOKE SUPER ON *.* FROM mysqltest_1@localhost;
46FLUSH CHANGED_PAGE_BITMAPS;
47ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
48RESET CHANGED_PAGE_BITMAPS;
49ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
50PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
51ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
52DROP USER mysqltest_1@localhost;
53SELECT @@GLOBAL.innodb_track_changed_pages;
54@@GLOBAL.innodb_track_changed_pages
550
56FLUSH CHANGED_PAGE_BITMAPS;
57Before the PURGE with tracking disabled
58ib_modified_log_4
59ib_modified_log_5
60PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
61After the PURGE that deletes nothing:
62ib_modified_log_4
63ib_modified_log_5
64PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
65After the PURGE that deletes everything:
66PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
67After the repeated PURGE:
68INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
69Before the RESET while tracking disabled:
70ib_modified_log_1
71ib_modified_log_2
72RESET CHANGED_PAGE_BITMAPS;
73After the RESET with tracking disabled:
74DROP TABLE t1;
75CREATE TABLE CHANGED_PAGE_BITMAPS (a INT);
76DROP TABLE CHANGED_PAGE_BITMAPS;
077
=== added file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result'
--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_requests_no_innodb.result 2013-01-22 18:26:30 +0000
@@ -0,0 +1,3 @@
1FLUSH CHANGED_PAGE_BITMAPS;
2RESET CHANGED_PAGE_BITMAPS;
3PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
04
=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result'
--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_pages.result 2013-01-22 18:26:30 +0000
@@ -1,3 +1,4 @@
1RESET CHANGED_PAGE_BITMAPS;
1DROP TABLE IF EXISTS T1;2DROP TABLE IF EXISTS T1;
2CREATE TABLE T1 (F1 CHAR(255)) ENGINE=INNODB;3CREATE TABLE T1 (F1 CHAR(255)) ENGINE=INNODB;
31st interval end LSN greater than interval start LSN:41st interval end LSN greater than interval start LSN:
45
=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp.test 2013-01-22 18:26:30 +0000
@@ -13,7 +13,9 @@
13# Valgrind reports useless errors on very fast server shutdowns13# Valgrind reports useless errors on very fast server shutdowns
14--source include/not_valgrind.inc14--source include/not_valgrind.inc
1515
16--source include/delete_innodb_bitmaps.inc16# Delete any existing bitmaps
17--source include/restart_mysqld.inc
18RESET CHANGED_PAGE_BITMAPS;
1719
18--disable_warnings20--disable_warnings
19DROP TABLE IF EXISTS t1, t2;21DROP TABLE IF EXISTS t1, t2;
2022
=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_no_restart.test 2013-01-22 18:26:30 +0000
@@ -2,7 +2,9 @@
2# percona_changed_page_bmp test, which contains the full functional tests.2# percona_changed_page_bmp test, which contains the full functional tests.
3--source include/have_innodb.inc3--source include/have_innodb.inc
44
5--source include/delete_innodb_bitmaps.inc5# Delete any existing bitmaps
6--source include/restart_mysqld.inc
7RESET CHANGED_PAGE_BITMAPS;
68
7--disable_warnings9--disable_warnings
8DROP TABLE IF EXISTS t1, t2;10DROP TABLE IF EXISTS t1, t2;
911
=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests-master.opt 2013-01-22 18:26:30 +0000
@@ -0,0 +1,1 @@
1--innodb_track_changed_pages=TRUE
02
=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests.test 2013-01-22 18:26:30 +0000
@@ -0,0 +1,200 @@
1#
2# Tests for changed page tracking bitmaps: user requests.
3#
4--source include/have_innodb.inc
5
6# Delete any existing bitmaps
7--source include/restart_mysqld.inc
8RESET CHANGED_PAGE_BITMAPS;
9
10--source include/count_sessions.inc
11
12let $MYSQLD_DATADIR= `select @@datadir`;
13
14--disable_warnings
15DROP TABLE IF EXISTS t1;
16DELETE FROM mysql.user WHERE USER='mysqltest_1';
17FLUSH PRIVILEGES;
18--enable_warnings
19
20CREATE TABLE t1 (x INT) ENGINE=InnoDB;
21INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
22
23#
24# Test FLUSH CHANGED_PAGE_BITMAPS. Not much to test due to checkpointing non-determinism,
25# just see that it does not crash or return an error
26#
27FLUSH CHANGED_PAGE_BITMAPS;
28
29#
30# Test that RESET CHANGED_PAGE_BITMAPS works
31#
32
33# Have at least two bitmap files
34--source include/restart_mysqld.inc
35
36--echo Before RESET:
37--replace_regex /_[[:digit:]]+\.xdb$//
38list_files $MYSQLD_DATADIR ib_modified_log*;
39
40RESET CHANGED_PAGE_BITMAPS;
41
42--echo After RESET:
43--replace_regex /_[[:digit:]]+\.xdb$//
44list_files $MYSQLD_DATADIR ib_modified_log*;
45
46# Test consecutive RESET
47RESET CHANGED_PAGE_BITMAPS;
48--echo After 2nd RESET
49--replace_regex /_[[:digit:]]+\.xdb$//
50list_files $MYSQLD_DATADIR ib_modified_log*;
51
52# Check that the file sequence after RESET starts with 1 again
53--source include/restart_mysqld.inc
54
55--echo After RESETs and restart:
56--replace_regex /_[[:digit:]]+\.xdb$//
57list_files $MYSQLD_DATADIR ib_modified_log*;
58
59#
60# Test that PURGE CHANGED_PAGE_BITMAPS BEFORE works. We don't test partial PURGE
61# because it's hard to extract good LSN value for that.
62#
63
64# PURGE that deletes nothing
65PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
66--echo After PURGE ... BEFORE 1:
67--replace_regex /_[[:digit:]]+\.xdb$//
68list_files $MYSQLD_DATADIR ib_modified_log*;
69
70# PURGE that deletes everything
71PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
72# Test consecutive PURGE
73PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
74
75# Check that file sequence continues
76INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
77--source include/restart_mysqld.inc
78--echo After PURGE ... BEFORE 100000000 and restart:
79--replace_regex /_[[:digit:]]+\.xdb$//
80list_files $MYSQLD_DATADIR ib_modified_log*;
81
82#
83# Test malformed PURGE ... BEFORE
84#
85--error ER_PARSE_ERROR
86PURGE CHANGED_PAGE_BITMAPS BEFORE 5+5;
87
88--error ER_PARSE_ERROR
89PURGE CHANGED_PAGE_BITMAPS BEFORE -12;
90
91--error ER_PARSE_ERROR
92PURGE CHANGED_PAGE_BITMAPS BEFORE 1.2e-2;
93
94--error ER_PARSE_ERROR
95PURGE CHANGED_PAGE_BITMAPS BEFORE t1;
96
97--error ER_PARSE_ERROR
98PURGE CHANGED_PAGE_BITMAPS BEFORE "t1";
99
100--error ER_PARSE_ERROR
101PURGE CHANGED_PAGE_BITMAPS BEFORE TRUE;
102
103--error ER_PARSE_ERROR
104PURGE CHANGED_PAGE_BITMAPS BEFORE NULL;
105
106#
107# Test that non-privileged users cannot issue user requests
108#
109CREATE USER mysqltest_1@localhost;
110GRANT ALL ON *.* TO mysqltest_1@localhost;
111REVOKE SUPER ON *.* FROM mysqltest_1@localhost;
112
113connect (conn1,localhost,mysqltest_1,,);
114
115--error ER_SPECIFIC_ACCESS_DENIED_ERROR
116FLUSH CHANGED_PAGE_BITMAPS;
117
118--error ER_SPECIFIC_ACCESS_DENIED_ERROR
119RESET CHANGED_PAGE_BITMAPS;
120
121--error ER_SPECIFIC_ACCESS_DENIED_ERROR
122PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
123
124connection default;
125disconnect conn1;
126
127--source include/wait_until_count_sessions.inc
128
129DROP USER mysqltest_1@localhost;
130
131#
132# Test FLUSH and PURGE requests with log tracking disabled
133#
134--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
135--shutdown_server 10
136--source include/wait_until_disconnected.inc
137--enable_reconnect
138--exec echo "restart:--innodb_track_changed_pages=FALSE" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
139--source include/wait_until_connected_again.inc
140
141SELECT @@GLOBAL.innodb_track_changed_pages;
142
143FLUSH CHANGED_PAGE_BITMAPS;
144
145# The previous bitmap files should be present
146--echo Before the PURGE with tracking disabled
147--replace_regex /_[[:digit:]]+\.xdb$//
148list_files $MYSQLD_DATADIR ib_modified_log*;
149
150PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
151
152--echo After the PURGE that deletes nothing:
153--replace_regex /_[[:digit:]]+\.xdb$//
154list_files $MYSQLD_DATADIR ib_modified_log*;
155
156PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
157
158--echo After the PURGE that deletes everything:
159--replace_regex /_[[:digit:]]+\.xdb$//
160list_files $MYSQLD_DATADIR ib_modified_log*;
161
162PURGE CHANGED_PAGE_BITMAPS BEFORE 100000000;
163
164--echo After the repeated PURGE:
165--replace_regex /_[[:digit:]]+\.xdb$//
166list_files $MYSQLD_DATADIR ib_modified_log*;
167
168#
169# Test RESET request with log tracking disabled
170#
171
172# Generate some bitmap data again
173--source include/restart_mysqld.inc
174INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
175--source include/restart_mysqld.inc
176
177--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
178--shutdown_server 10
179--source include/wait_until_disconnected.inc
180--enable_reconnect
181--exec echo "restart:--innodb_track_changed_pages=FALSE" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
182--source include/wait_until_connected_again.inc
183
184--echo Before the RESET while tracking disabled:
185--replace_regex /_[[:digit:]]+\.xdb$//
186list_files $MYSQLD_DATADIR ib_modified_log*;
187
188RESET CHANGED_PAGE_BITMAPS;
189
190--echo After the RESET with tracking disabled:
191--replace_regex /_[[:digit:]]+\.xdb$//
192list_files $MYSQLD_DATADIR ib_modified_log*;
193
194DROP TABLE t1;
195
196#
197# Test that the new keyword does not preclude its use as identifier
198#
199CREATE TABLE CHANGED_PAGE_BITMAPS (a INT);
200DROP TABLE CHANGED_PAGE_BITMAPS;
0201
=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb-master.opt 2013-01-22 18:26:30 +0000
@@ -0,0 +1,1 @@
1--skip-innodb
02
=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_requests_no_innodb.test 2013-01-22 18:26:30 +0000
@@ -0,0 +1,7 @@
1#
2# Test that changed page tracking user requests are parsed without InnoDB
3#
4FLUSH CHANGED_PAGE_BITMAPS;
5RESET CHANGED_PAGE_BITMAPS;
6PURGE CHANGED_PAGE_BITMAPS BEFORE 1;
7
08
=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test'
--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test 2012-11-25 09:30:58 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_pages.test 2013-01-22 18:26:30 +0000
@@ -4,7 +4,9 @@
44
5--source include/have_innodb.inc5--source include/have_innodb.inc
66
7--source include/delete_innodb_bitmaps.inc7# Delete any existing bitmaps
8--source include/restart_mysqld.inc
9RESET CHANGED_PAGE_BITMAPS;
810
9--disable_warnings11--disable_warnings
10DROP TABLE IF EXISTS T1;12DROP TABLE IF EXISTS T1;
1113
=== modified file 'Percona-Server/sql/handler.cc'
--- Percona-Server/sql/handler.cc 2013-01-17 22:50:22 +0000
+++ Percona-Server/sql/handler.cc 2013-01-22 18:26:30 +0000
@@ -5125,6 +5125,42 @@
5125 return result;5125 return result;
5126}5126}
51275127
5128static my_bool flush_changed_page_bitmaps_handlerton(THD *unused1,
5129 plugin_ref plugin,
5130 void *unused2)
5131{
5132 handlerton *hton= plugin_data(plugin, handlerton *);
5133
5134 if (hton->flush_changed_page_bitmaps == NULL)
5135 return FALSE;
5136
5137 return hton->flush_changed_page_bitmaps();
5138}
5139
5140bool ha_flush_changed_page_bitmaps()
5141{
5142 return plugin_foreach(NULL, flush_changed_page_bitmaps_handlerton,
5143 MYSQL_STORAGE_ENGINE_PLUGIN, NULL);
5144}
5145
5146static my_bool purge_changed_page_bitmaps_handlerton(THD *unused1,
5147 plugin_ref plugin,
5148 void *lsn)
5149{
5150 handlerton *hton= plugin_data(plugin, handlerton *);
5151
5152 if (hton->purge_changed_page_bitmaps == NULL)
5153 return FALSE;
5154
5155 return hton->purge_changed_page_bitmaps(*(ulonglong *)lsn);
5156}
5157
5158bool ha_purge_changed_page_bitmaps(ulonglong lsn)
5159{
5160 return plugin_foreach(NULL, purge_changed_page_bitmaps_handlerton,
5161 MYSQL_STORAGE_ENGINE_PLUGIN, &lsn);
5162}
5163
5128/*5164/*
5129 Function to check if the conditions for row-based binlogging is5165 Function to check if the conditions for row-based binlogging is
5130 correct for the table.5166 correct for the table.
51315167
=== modified file 'Percona-Server/sql/handler.h'
--- Percona-Server/sql/handler.h 2013-01-09 23:45:25 +0000
+++ Percona-Server/sql/handler.h 2013-01-22 18:26:30 +0000
@@ -842,6 +842,8 @@
842 int (*fill_is_table)(handlerton *hton, THD *thd, TABLE_LIST *tables, 842 int (*fill_is_table)(handlerton *hton, THD *thd, TABLE_LIST *tables,
843 class Item *cond, 843 class Item *cond,
844 enum enum_schema_tables);844 enum enum_schema_tables);
845 my_bool (*flush_changed_page_bitmaps)(void);
846 my_bool (*purge_changed_page_bitmaps)(ulonglong lsn);
845 uint32 flags; /* global handler flags */847 uint32 flags; /* global handler flags */
846 /*848 /*
847 Those handlerton functions below are properly initialized at handler849 Those handlerton functions below are properly initialized at handler
@@ -2390,6 +2392,9 @@
2390int ha_prepare(THD *thd);2392int ha_prepare(THD *thd);
2391int ha_recover(HASH *commit_list);2393int ha_recover(HASH *commit_list);
23922394
2395bool ha_flush_changed_page_bitmaps();
2396bool ha_purge_changed_page_bitmaps(ulonglong lsn);
2397
2393/* transactions: these functions never call handlerton functions directly */2398/* transactions: these functions never call handlerton functions directly */
2394int ha_enable_transaction(THD *thd, bool on);2399int ha_enable_transaction(THD *thd, bool on);
23952400
23962401
=== modified file 'Percona-Server/sql/lex.h'
--- Percona-Server/sql/lex.h 2012-05-10 07:49:14 +0000
+++ Percona-Server/sql/lex.h 2013-01-22 18:26:30 +0000
@@ -103,6 +103,7 @@
103 { "CHAIN", SYM(CHAIN_SYM)},103 { "CHAIN", SYM(CHAIN_SYM)},
104 { "CHANGE", SYM(CHANGE)},104 { "CHANGE", SYM(CHANGE)},
105 { "CHANGED", SYM(CHANGED)},105 { "CHANGED", SYM(CHANGED)},
106 { "CHANGED_PAGE_BITMAPS", SYM(CHANGED_PAGE_BITMAPS_SYM)},
106 { "CHAR", SYM(CHAR_SYM)},107 { "CHAR", SYM(CHAR_SYM)},
107 { "CHARACTER", SYM(CHAR_SYM)},108 { "CHARACTER", SYM(CHAR_SYM)},
108 { "CHARSET", SYM(CHARSET)},109 { "CHARSET", SYM(CHARSET)},
109110
=== modified file 'Percona-Server/sql/sql_parse.cc'
--- Percona-Server/sql/sql_parse.cc 2013-01-09 23:45:25 +0000
+++ Percona-Server/sql/sql_parse.cc 2013-01-22 18:26:30 +0000
@@ -2320,9 +2320,35 @@
2320 {2320 {
2321 if (check_global_access(thd, SUPER_ACL))2321 if (check_global_access(thd, SUPER_ACL))
2322 goto error;2322 goto error;
2323 /* PURGE MASTER LOGS TO 'file' */2323 if (lex->type == 0)
2324 res = purge_master_logs(thd, lex->to_log);2324 {
2325 break;2325 /* PURGE MASTER LOGS TO 'file' */
2326 res = purge_master_logs(thd, lex->to_log);
2327 break;
2328 }
2329 if (lex->type == PURGE_BITMAPS_TO_LSN)
2330 {
2331 /* PURGE CHANGED_PAGE_BITMAPS BEFORE lsn */
2332 ulonglong lsn= 0;
2333 Item *it= (Item *)lex->value_list.head();
2334 if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1)
2335 || it->null_value)
2336 {
2337 my_error(ER_WRONG_ARGUMENTS, MYF(0),
2338 "PURGE CHANGED_PAGE_BITMAPS BEFORE");
2339 goto error;
2340 }
2341 lsn= it->val_uint();
2342 res= ha_purge_changed_page_bitmaps(lsn);
2343 if (res)
2344 {
2345 my_error(ER_LOG_PURGE_UNKNOWN_ERR, MYF(0),
2346 "PURGE CHANGED_PAGE_BITMAPS BEFORE");
2347 goto error;
2348 }
2349 my_ok(thd);
2350 break;
2351 }
2326 }2352 }
2327 case SQLCOM_PURGE_BEFORE:2353 case SQLCOM_PURGE_BEFORE:
2328 {2354 {
@@ -3782,7 +3808,14 @@
3782 case SQLCOM_FLUSH:3808 case SQLCOM_FLUSH:
3783 {3809 {
3784 int write_to_binlog;3810 int write_to_binlog;
3785 if (check_global_access(thd,RELOAD_ACL))3811
3812 if (lex->type & REFRESH_FLUSH_PAGE_BITMAPS
3813 || lex->type & REFRESH_RESET_PAGE_BITMAPS)
3814 {
3815 if (check_global_access(thd, SUPER_ACL))
3816 goto error;
3817 }
3818 else if (check_global_access(thd, RELOAD_ACL))
3786 goto error;3819 goto error;
37873820
3788 if (first_table && lex->type & REFRESH_READ_LOCK)3821 if (first_table && lex->type & REFRESH_READ_LOCK)
37893822
=== modified file 'Percona-Server/sql/sql_reload.cc'
--- Percona-Server/sql/sql_reload.cc 2012-04-18 23:26:01 +0000
+++ Percona-Server/sql/sql_reload.cc 2013-01-22 18:26:30 +0000
@@ -362,6 +362,22 @@
362 }362 }
363 mysql_mutex_unlock(&LOCK_global_user_client_stats);363 mysql_mutex_unlock(&LOCK_global_user_client_stats);
364 }364 }
365 if (options & REFRESH_FLUSH_PAGE_BITMAPS)
366 {
367 result= ha_flush_changed_page_bitmaps();
368 if (result)
369 {
370 my_error(ER_UNKNOWN_ERROR, MYF(0), "FLUSH CHANGED_PAGE_BITMAPS");
371 }
372 }
373 if (options & REFRESH_RESET_PAGE_BITMAPS)
374 {
375 result= ha_purge_changed_page_bitmaps(0);
376 if (result)
377 {
378 my_error(ER_UNKNOWN_ERROR, MYF(0), "RESET CHANGED_PAGE_BITMAPS");
379 }
380 }
365 if (*write_to_binlog != -1)381 if (*write_to_binlog != -1)
366 *write_to_binlog= tmp_write_to_binlog;382 *write_to_binlog= tmp_write_to_binlog;
367 /*383 /*
368384
=== modified file 'Percona-Server/sql/sql_yacc.yy'
--- Percona-Server/sql/sql_yacc.yy 2013-01-09 23:45:25 +0000
+++ Percona-Server/sql/sql_yacc.yy 2013-01-22 18:26:30 +0000
@@ -858,6 +858,7 @@
858%token CHAIN_SYM /* SQL-2003-N */858%token CHAIN_SYM /* SQL-2003-N */
859%token CHANGE859%token CHANGE
860%token CHANGED860%token CHANGED
861%token CHANGED_PAGE_BITMAPS_SYM /* MYSQL */
861%token CHARSET862%token CHARSET
862%token CHAR_SYM /* SQL-2003-R */863%token CHAR_SYM /* SQL-2003-R */
863%token CHECKSUM_SYM864%token CHECKSUM_SYM
@@ -11457,6 +11458,8 @@
11457 { Lex->type|= REFRESH_DES_KEY_FILE; }11458 { Lex->type|= REFRESH_DES_KEY_FILE; }
11458 | RESOURCES11459 | RESOURCES
11459 { Lex->type|= REFRESH_USER_RESOURCES; }11460 { Lex->type|= REFRESH_USER_RESOURCES; }
11461 | CHANGED_PAGE_BITMAPS_SYM
11462 { Lex->type|= REFRESH_FLUSH_PAGE_BITMAPS; }
11460 ;11463 ;
1146111464
11462opt_table_list:11465opt_table_list:
@@ -11484,6 +11487,8 @@
11484 slave_reset_options { }11487 slave_reset_options { }
11485 | MASTER_SYM { Lex->type|= REFRESH_MASTER; }11488 | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
11486 | QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}11489 | QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}
11490 | CHANGED_PAGE_BITMAPS_SYM
11491 { Lex->type |= REFRESH_RESET_PAGE_BITMAPS; }
11487 ;11492 ;
1148811493
11489slave_reset_options:11494slave_reset_options:
@@ -11504,6 +11509,13 @@
1150411509
11505purge_options:11510purge_options:
11506 master_or_binary LOGS_SYM purge_option11511 master_or_binary LOGS_SYM purge_option
11512 | CHANGED_PAGE_BITMAPS_SYM BEFORE_SYM real_ulonglong_num
11513 {
11514 LEX *lex= Lex;
11515 lex->value_list.empty();
11516 lex->value_list.push_front(new Item_uint($3));
11517 lex->type= PURGE_BITMAPS_TO_LSN;
11518 }
11507 ;11519 ;
1150811520
11509purge_option:11521purge_option:
@@ -12594,6 +12606,7 @@
12594 | CATALOG_NAME_SYM {}12606 | CATALOG_NAME_SYM {}
12595 | CHAIN_SYM {}12607 | CHAIN_SYM {}
12596 | CHANGED {}12608 | CHANGED {}
12609 | CHANGED_PAGE_BITMAPS_SYM {}
12597 | CIPHER_SYM {}12610 | CIPHER_SYM {}
12598 | CLIENT_STATS_SYM {}12611 | CLIENT_STATS_SYM {}
12599 | CLIENT_SYM {}12612 | CLIENT_SYM {}
1260012613
=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-01-18 03:34:53 +0000
+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-01-22 18:26:30 +0000
@@ -85,6 +85,7 @@
85#include "row0sel.h"85#include "row0sel.h"
86#include "row0upd.h"86#include "row0upd.h"
87#include "log0log.h"87#include "log0log.h"
88#include "log0online.h"
88#include "lock0lock.h"89#include "lock0lock.h"
89#include "dict0crea.h"90#include "dict0crea.h"
90#include "btr0cur.h"91#include "btr0cur.h"
@@ -297,6 +298,7 @@
297 {&ibuf_pessimistic_insert_mutex_key,298 {&ibuf_pessimistic_insert_mutex_key,
298 "ibuf_pessimistic_insert_mutex", 0},299 "ibuf_pessimistic_insert_mutex", 0},
299 {&kernel_mutex_key, "kernel_mutex", 0},300 {&kernel_mutex_key, "kernel_mutex", 0},
301 {&log_bmp_sys_mutex_key, "log_bmp_sys_mutex", 0},
300 {&log_sys_mutex_key, "log_sys_mutex", 0},302 {&log_sys_mutex_key, "log_sys_mutex", 0},
301# ifdef UNIV_MEM_DEBUG303# ifdef UNIV_MEM_DEBUG
302 {&mem_hash_mutex_key, "mem_hash_mutex", 0},304 {&mem_hash_mutex_key, "mem_hash_mutex", 0},
@@ -438,6 +440,25 @@
438innobase_alter_table_flags(440innobase_alter_table_flags(
439/*=======================*/441/*=======================*/
440 uint flags);442 uint flags);
443/************************************************************//**
444Synchronously read and parse the redo log up to the last
445checkpoint to write the changed page bitmap.
446@return 0 to indicate success. Current implementation cannot fail. */
447static
448my_bool
449innobase_flush_changed_page_bitmaps();
450/*==================================*/
451/************************************************************//**
452Delete all the bitmap files for data less than the specified LSN.
453If called with lsn == 0 (i.e. set by RESET request) or
454IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
455continue it.
456@return 0 to indicate success, 1 for failure. */
457static
458my_bool
459innobase_purge_changed_page_bitmaps(
460/*================================*/
461 ulonglong lsn); /*!< in: LSN to purge files up to */
441462
442static const char innobase_hton_name[]= "InnoDB";463static const char innobase_hton_name[]= "InnoDB";
443464
@@ -2663,6 +2684,10 @@
2663 innobase_hton->flags=HTON_NO_FLAGS;2684 innobase_hton->flags=HTON_NO_FLAGS;
2664 innobase_hton->release_temporary_latches=innobase_release_temporary_latches;2685 innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
2665 innobase_hton->alter_table_flags = innobase_alter_table_flags;2686 innobase_hton->alter_table_flags = innobase_alter_table_flags;
2687 innobase_hton->flush_changed_page_bitmaps
2688 = innobase_flush_changed_page_bitmaps;
2689 innobase_hton->purge_changed_page_bitmaps
2690 = innobase_purge_changed_page_bitmaps;
26662691
2667 ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);2692 ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
26682693
@@ -3282,6 +3307,36 @@
3282 | HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE);3307 | HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE);
3283}3308}
32843309
3310/************************************************************//**
3311Synchronously read and parse the redo log up to the last
3312checkpoint to write the changed page bitmap.
3313@return 0 to indicate success. Current implementation cannot fail. */
3314static
3315my_bool
3316innobase_flush_changed_page_bitmaps()
3317/*=================================*/
3318{
3319 if (srv_track_changed_pages) {
3320 os_event_reset(srv_checkpoint_completed_event);
3321 log_online_follow_redo_log();
3322 }
3323 return FALSE;
3324}
3325
3326/************************************************************//**
3327Delete all the bitmap files for data less than the specified LSN.
3328If called with lsn == IB_ULONGLONG_MAX (i.e. set by RESET request),
3329restart the bitmap file sequence, otherwise continue it.
3330@return 0 to indicate success, 1 for failure. */
3331static
3332my_bool
3333innobase_purge_changed_page_bitmaps(
3334/*================================*/
3335 ulonglong lsn) /*!< in: LSN to purge files up to */
3336{
3337 return (my_bool)log_online_purge_changed_page_bitmaps(lsn);
3338}
3339
3285/****************************************************************//**3340/****************************************************************//**
3286Copy the current replication position from MySQL to a transaction. */3341Copy the current replication position from MySQL to a transaction. */
3287static3342static
32883343
=== modified file 'Percona-Server/storage/innobase/include/log0online.h'
--- Percona-Server/storage/innobase/include/log0online.h 2012-11-25 09:29:43 +0000
+++ Percona-Server/storage/innobase/include/log0online.h 2013-01-22 18:26:30 +0000
@@ -41,23 +41,49 @@
41Initializes the online log following subsytem. */41Initializes the online log following subsytem. */
42UNIV_INTERN42UNIV_INTERN
43void43void
44log_online_read_init();44log_online_read_init(void);
45/*===================*/45/*=======================*/
4646
47/*********************************************************************//**47/*********************************************************************//**
48Shuts down the online log following subsystem. */48Shuts down the online log following subsystem. */
49UNIV_INTERN49UNIV_INTERN
50void50void
51log_online_read_shutdown();51log_online_read_shutdown(void);
52/*=======================*/52/*===========================*/
5353
54/*********************************************************************//**54/*********************************************************************//**
55Reads and parses the redo log up to last checkpoint LSN to build the changed55Reads and parses the redo log up to last checkpoint LSN to build the changed
56page bitmap which is then written to disk. */56page bitmap which is then written to disk. */
57UNIV_INTERN57UNIV_INTERN
58void58void
59log_online_follow_redo_log();59log_online_follow_redo_log(void);
60/*=========================*/60/*=============================*/
61
62/************************************************************//**
63Delete all the bitmap files for data less than the specified LSN.
64If called with lsn == 0 (i.e. set by RESET request) or
65IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
66continue it.
67
68@return FALSE to indicate success, TRUE for failure. */
69UNIV_INTERN
70ibool
71log_online_purge_changed_page_bitmaps(
72/*==================================*/
73 ib_uint64_t lsn); /*!<in: LSN to purge files up to */
74
75/************************************************************//**
76Delete all the bitmap files for data less than the specified LSN.
77If called with lsn == 0 (i.e. set by RESET request) or
78IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
79continue it.
80
81@return FALSE to indicate success, TRUE for failure. */
82UNIV_INTERN
83ibool
84log_online_purge_changed_page_bitmaps(
85/*==================================*/
86 ib_uint64_t lsn); /*!<in: LSN to purge files up to */
6187
62#define LOG_BITMAP_ITERATOR_START_LSN(i) \88#define LOG_BITMAP_ITERATOR_START_LSN(i) \
63 ((i).start_lsn)89 ((i).start_lsn)
6490
=== modified file 'Percona-Server/storage/innobase/include/sync0sync.h'
--- Percona-Server/storage/innobase/include/sync0sync.h 2012-05-10 07:49:14 +0000
+++ Percona-Server/storage/innobase/include/sync0sync.h 2013-01-22 18:26:30 +0000
@@ -89,6 +89,7 @@
89extern mysql_pfs_key_t ibuf_bitmap_mutex_key;89extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
90extern mysql_pfs_key_t ibuf_mutex_key;90extern mysql_pfs_key_t ibuf_mutex_key;
91extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;91extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
92extern mysql_pfs_key_t log_bmp_sys_mutex_key;
92extern mysql_pfs_key_t log_sys_mutex_key;93extern mysql_pfs_key_t log_sys_mutex_key;
93extern mysql_pfs_key_t log_flush_order_mutex_key;94extern mysql_pfs_key_t log_flush_order_mutex_key;
94extern mysql_pfs_key_t kernel_mutex_key;95extern mysql_pfs_key_t kernel_mutex_key;
@@ -672,6 +673,7 @@
672#define SYNC_TRX_LOCK_HEAP 298673#define SYNC_TRX_LOCK_HEAP 298
673#define SYNC_TRX_SYS_HEADER 290674#define SYNC_TRX_SYS_HEADER 290
674#define SYNC_PURGE_QUEUE 200675#define SYNC_PURGE_QUEUE 200
676#define SYNC_LOG_ONLINE 175
675#define SYNC_LOG 170677#define SYNC_LOG 170
676#define SYNC_LOG_FLUSH_ORDER 156678#define SYNC_LOG_FLUSH_ORDER 156
677#define SYNC_RECV 168679#define SYNC_RECV 168
678680
=== modified file 'Percona-Server/storage/innobase/log/log0online.c'
--- Percona-Server/storage/innobase/log/log0online.c 2013-01-04 15:24:45 +0000
+++ Percona-Server/storage/innobase/log/log0online.c 2013-01-22 18:26:30 +0000
@@ -36,6 +36,11 @@
3636
37enum { FOLLOW_SCAN_SIZE = 4 * (UNIV_PAGE_SIZE_MAX) };37enum { FOLLOW_SCAN_SIZE = 4 * (UNIV_PAGE_SIZE_MAX) };
3838
39#ifdef UNIV_PFS_MUTEX
40/* Key to register log_bmp_sys->mutex with PFS */
41UNIV_INTERN mysql_pfs_key_t log_bmp_sys_mutex_key;
42#endif /* UNIV_PFS_MUTEX */
43
39/** Log parsing and bitmap output data structure */44/** Log parsing and bitmap output data structure */
40struct log_bitmap_struct {45struct log_bitmap_struct {
41 byte read_buf[FOLLOW_SCAN_SIZE];46 byte read_buf[FOLLOW_SCAN_SIZE];
@@ -69,6 +74,7 @@
69 both the correct type and the tree does74 both the correct type and the tree does
70 not mind its overwrite during75 not mind its overwrite during
71 rbt_next() tree traversal. */76 rbt_next() tree traversal. */
77 mutex_t mutex; /*!< mutex protecting all the fields.*/
72};78};
7379
74/* The log parsing and bitmap output struct instance */80/* The log parsing and bitmap output struct instance */
@@ -172,6 +178,8 @@
172 byte search_page[MODIFIED_PAGE_BLOCK_SIZE];178 byte search_page[MODIFIED_PAGE_BLOCK_SIZE];
173 byte *page_ptr;179 byte *page_ptr;
174180
181 ut_ad(mutex_own(&log_bmp_sys->mutex));
182
175 ut_a(space != ULINT_UNDEFINED);183 ut_a(space != ULINT_UNDEFINED);
176 ut_a(page_no != ULINT_UNDEFINED);184 ut_a(page_no != ULINT_UNDEFINED);
177185
@@ -312,8 +320,8 @@
312@return the last fully tracked LSN */320@return the last fully tracked LSN */
313static321static
314ib_uint64_t322ib_uint64_t
315log_online_read_last_tracked_lsn()323log_online_read_last_tracked_lsn(void)
316/*==============================*/324/*==================================*/
317{325{
318 byte page[MODIFIED_PAGE_BLOCK_SIZE];326 byte page[MODIFIED_PAGE_BLOCK_SIZE];
319 ibool is_last_page = FALSE;327 ibool is_last_page = FALSE;
@@ -487,8 +495,8 @@
487Create a new empty bitmap output file. */495Create a new empty bitmap output file. */
488static496static
489void497void
490log_online_start_bitmap_file()498log_online_start_bitmap_file(void)
491/*==========================*/499/*==============================*/
492{500{
493 ibool success;501 ibool success;
494502
@@ -518,7 +526,10 @@
518 ib_uint64_t next_file_start_lsn) /*!<in: the start LSN name526 ib_uint64_t next_file_start_lsn) /*!<in: the start LSN name
519 part */527 part */
520{528{
521 os_file_close(log_bmp_sys->out.file);529 if (log_bmp_sys->out.file != -1) {
530 os_file_close(log_bmp_sys->out.file);
531 log_bmp_sys->out.file = -1;
532 }
522 log_bmp_sys->out_seq_num++;533 log_bmp_sys->out_seq_num++;
523 log_online_make_bitmap_name(next_file_start_lsn);534 log_online_make_bitmap_name(next_file_start_lsn);
524 log_online_start_bitmap_file();535 log_online_start_bitmap_file();
@@ -556,8 +567,8 @@
556Initialize the online log following subsytem. */567Initialize the online log following subsytem. */
557UNIV_INTERN568UNIV_INTERN
558void569void
559log_online_read_init()570log_online_read_init(void)
560/*==================*/571/*======================*/
561{572{
562 ibool success;573 ibool success;
563 ib_uint64_t tracking_start_lsn574 ib_uint64_t tracking_start_lsn
@@ -566,13 +577,16 @@
566 os_file_stat_t bitmap_dir_file_info;577 os_file_stat_t bitmap_dir_file_info;
567 ib_uint64_t last_file_start_lsn = MIN_TRACKED_LSN;578 ib_uint64_t last_file_start_lsn = MIN_TRACKED_LSN;
568579
569 /* Assert (could be compile-time assert) that bitmap data start and end580 /* Bitmap data start and end in a bitmap block must be 8-byte
570 in a bitmap block is 8-byte aligned */581 aligned. */
571 ut_a(MODIFIED_PAGE_BLOCK_BITMAP % 8 == 0);582 compile_time_assert(MODIFIED_PAGE_BLOCK_BITMAP % 8 == 0);
572 ut_a(MODIFIED_PAGE_BLOCK_BITMAP_LEN % 8 == 0);583 compile_time_assert(MODIFIED_PAGE_BLOCK_BITMAP_LEN % 8 == 0);
573584
574 log_bmp_sys = ut_malloc(sizeof(*log_bmp_sys));585 log_bmp_sys = ut_malloc(sizeof(*log_bmp_sys));
575586
587 mutex_create(log_bmp_sys_mutex_key, &log_bmp_sys->mutex,
588 SYNC_LOG_ONLINE);
589
576 /* Enumerate existing bitmap files to either open the last one to get590 /* Enumerate existing bitmap files to either open the last one to get
577 the last tracked LSN either to find that there are none and start591 the last tracked LSN either to find that there are none and start
578 tracking from scratch. */592 tracking from scratch. */
@@ -701,12 +715,15 @@
701Shut down the online log following subsystem. */715Shut down the online log following subsystem. */
702UNIV_INTERN716UNIV_INTERN
703void717void
704log_online_read_shutdown()718log_online_read_shutdown(void)
705/*======================*/719/*==========================*/
706{720{
707 ib_rbt_node_t *free_list_node = log_bmp_sys->page_free_list;721 ib_rbt_node_t *free_list_node = log_bmp_sys->page_free_list;
708722
709 os_file_close(log_bmp_sys->out.file);723 if (log_bmp_sys->out.file != -1) {
724 os_file_close(log_bmp_sys->out.file);
725 log_bmp_sys->out.file = -1;
726 }
710727
711 rbt_free(log_bmp_sys->modified_pages);728 rbt_free(log_bmp_sys->modified_pages);
712729
@@ -716,6 +733,8 @@
716 free_list_node = next;733 free_list_node = next;
717 }734 }
718735
736 mutex_free(&log_bmp_sys->mutex);
737
719 ut_free(log_bmp_sys);738 ut_free(log_bmp_sys);
720}739}
721740
@@ -759,14 +778,16 @@
759buffer. */778buffer. */
760static779static
761void780void
762log_online_parse_redo_log()781log_online_parse_redo_log(void)
763/*=======================*/782/*===========================*/
764{783{
765 byte *ptr = log_bmp_sys->parse_buf;784 byte *ptr = log_bmp_sys->parse_buf;
766 byte *end = log_bmp_sys->parse_buf_end;785 byte *end = log_bmp_sys->parse_buf_end;
767786
768 ulint len = 0;787 ulint len = 0;
769788
789 ut_ad(mutex_own(&log_bmp_sys->mutex));
790
770 while (ptr != end791 while (ptr != end
771 && log_bmp_sys->next_parse_lsn < log_bmp_sys->end_lsn) {792 && log_bmp_sys->next_parse_lsn < log_bmp_sys->end_lsn) {
772793
@@ -857,6 +878,8 @@
857 ulint actual_data_len = (end_offset >= start_offset)878 ulint actual_data_len = (end_offset >= start_offset)
858 ? end_offset - start_offset : 0;879 ? end_offset - start_offset : 0;
859880
881 ut_ad(mutex_own(&log_bmp_sys->mutex));
882
860 ut_memcpy(log_bmp_sys->parse_buf_end, log_block + start_offset,883 ut_memcpy(log_bmp_sys->parse_buf_end, log_block + start_offset,
861 actual_data_len);884 actual_data_len);
862885
@@ -881,6 +904,8 @@
881{904{
882 ulint block_data_len;905 ulint block_data_len;
883906
907 ut_ad(mutex_own(&log_bmp_sys->mutex));
908
884 block_data_len = log_block_get_data_len(log_block);909 block_data_len = log_block_get_data_len(log_block);
885910
886 ut_ad(block_data_len % OS_FILE_LOG_BLOCK_SIZE == 0911 ut_ad(block_data_len % OS_FILE_LOG_BLOCK_SIZE == 0
@@ -907,6 +932,8 @@
907 byte* log_block_end = log_bmp_sys->read_buf932 byte* log_block_end = log_bmp_sys->read_buf
908 + (block_end_lsn - block_start_lsn);933 + (block_end_lsn - block_start_lsn);
909934
935 ut_ad(mutex_own(&log_bmp_sys->mutex));
936
910 mutex_enter(&log_sys->mutex);937 mutex_enter(&log_sys->mutex);
911 log_group_read_log_seg(LOG_RECOVER, log_bmp_sys->read_buf,938 log_group_read_log_seg(LOG_RECOVER, log_bmp_sys->read_buf,
912 group, block_start_lsn, block_end_lsn);939 group, block_start_lsn, block_end_lsn);
@@ -969,6 +996,8 @@
969 ib_uint64_t block_start_lsn = contiguous_lsn;996 ib_uint64_t block_start_lsn = contiguous_lsn;
970 ib_uint64_t block_end_lsn;997 ib_uint64_t block_end_lsn;
971998
999 ut_ad(mutex_own(&log_bmp_sys->mutex));
1000
972 log_bmp_sys->next_parse_lsn = log_bmp_sys->start_lsn;1001 log_bmp_sys->next_parse_lsn = log_bmp_sys->start_lsn;
973 log_bmp_sys->parse_buf_end = log_bmp_sys->parse_buf;1002 log_bmp_sys->parse_buf_end = log_bmp_sys->parse_buf;
9741003
@@ -1005,6 +1034,8 @@
1005{1034{
1006 ibool success;1035 ibool success;
10071036
1037 ut_ad(mutex_own(&log_bmp_sys->mutex));
1038
1008 success = os_file_write(log_bmp_sys->out.name, log_bmp_sys->out.file,1039 success = os_file_write(log_bmp_sys->out.name, log_bmp_sys->out.file,
1009 block,1040 block,
1010 (ulint)(log_bmp_sys->out.offset & 0xFFFFFFFF),1041 (ulint)(log_bmp_sys->out.offset & 0xFFFFFFFF),
@@ -1038,12 +1069,14 @@
1038bitmap tree and recycles its nodes to the free list. */1069bitmap tree and recycles its nodes to the free list. */
1039static1070static
1040void1071void
1041log_online_write_bitmap()1072log_online_write_bitmap(void)
1042/*=====================*/1073/*=========================*/
1043{1074{
1044 ib_rbt_node_t *bmp_tree_node;1075 ib_rbt_node_t *bmp_tree_node;
1045 const ib_rbt_node_t *last_bmp_tree_node;1076 const ib_rbt_node_t *last_bmp_tree_node;
10461077
1078 ut_ad(mutex_own(&log_bmp_sys->mutex));
1079
1047 if (log_bmp_sys->out.offset >= srv_max_bitmap_file_size) {1080 if (log_bmp_sys->out.offset >= srv_max_bitmap_file_size) {
1048 log_online_rotate_bitmap_file(log_bmp_sys->start_lsn);1081 log_online_rotate_bitmap_file(log_bmp_sys->start_lsn);
1049 }1082 }
@@ -1084,18 +1117,21 @@
1084page bitmap which is then written to disk. */1117page bitmap which is then written to disk. */
1085UNIV_INTERN1118UNIV_INTERN
1086void1119void
1087log_online_follow_redo_log()1120log_online_follow_redo_log(void)
1088/*========================*/1121/*============================*/
1089{1122{
1090 ib_uint64_t contiguous_start_lsn;1123 ib_uint64_t contiguous_start_lsn;
1091 log_group_t* group;1124 log_group_t* group;
10921125
1126 mutex_enter(&log_bmp_sys->mutex);
1127
1093 /* Grab the LSN of the last checkpoint, we will parse up to it */1128 /* Grab the LSN of the last checkpoint, we will parse up to it */
1094 mutex_enter(&(log_sys->mutex));1129 mutex_enter(&(log_sys->mutex));
1095 log_bmp_sys->end_lsn = log_sys->last_checkpoint_lsn;1130 log_bmp_sys->end_lsn = log_sys->last_checkpoint_lsn;
1096 mutex_exit(&(log_sys->mutex));1131 mutex_exit(&(log_sys->mutex));
10971132
1098 if (log_bmp_sys->end_lsn == log_bmp_sys->start_lsn) {1133 if (log_bmp_sys->end_lsn == log_bmp_sys->start_lsn) {
1134 mutex_exit(&log_bmp_sys->mutex);
1099 return;1135 return;
1100 }1136 }
11011137
@@ -1117,6 +1153,8 @@
1117 log_online_write_bitmap();1153 log_online_write_bitmap();
1118 log_bmp_sys->start_lsn = log_bmp_sys->end_lsn;1154 log_bmp_sys->start_lsn = log_bmp_sys->end_lsn;
1119 log_set_tracked_lsn(log_bmp_sys->start_lsn);1155 log_set_tracked_lsn(log_bmp_sys->start_lsn);
1156
1157 mutex_exit(&log_bmp_sys->mutex);
1120}1158}
11211159
1122/*********************************************************************//**1160/*********************************************************************//**
@@ -1514,3 +1552,76 @@
15141552
1515 return TRUE;1553 return TRUE;
1516}1554}
1555
1556/************************************************************//**
1557Delete all the bitmap files for data less than the specified LSN.
1558If called with lsn == 0 (i.e. set by RESET request) or
1559IB_ULONGLONG_MAX, restart the bitmap file sequence, otherwise
1560continue it.
1561
1562@return FALSE to indicate success, TRUE for failure. */
1563UNIV_INTERN
1564ibool
1565log_online_purge_changed_page_bitmaps(
1566/*==================================*/
1567 ib_uint64_t lsn) /*!< in: LSN to purge files up to */
1568{
1569 log_online_bitmap_file_range_t bitmap_files;
1570 size_t i;
1571 ibool result = FALSE;
1572
1573 if (lsn == 0) {
1574 lsn = IB_ULONGLONG_MAX;
1575 }
1576
1577 if (srv_track_changed_pages) {
1578 /* User requests might happen with both enabled and disabled
1579 tracking */
1580 mutex_enter(&log_bmp_sys->mutex);
1581 }
1582
1583 if (!log_online_setup_bitmap_file_range(&bitmap_files, 0, lsn)) {
1584 if (srv_track_changed_pages) {
1585 mutex_exit(&log_bmp_sys->mutex);
1586 }
1587 return TRUE;
1588 }
1589
1590 if (srv_track_changed_pages && lsn >= log_bmp_sys->end_lsn) {
1591 /* If we have to delete the current output file, close it
1592 first. */
1593 os_file_close(log_bmp_sys->out.file);
1594 log_bmp_sys->out.file = -1;
1595 }
1596
1597 for (i = 0; i < bitmap_files.count; i++) {
1598 if (bitmap_files.files[i].seq_num == 0
1599 || bitmap_files.files[i].start_lsn >= lsn) {
1600 break;
1601 }
1602 if (!os_file_delete_if_exists(bitmap_files.files[i].name)) {
1603 os_file_get_last_error(TRUE);
1604 result = TRUE;
1605 break;
1606 }
1607 }
1608
1609 if (srv_track_changed_pages) {
1610 if (lsn > log_bmp_sys->end_lsn) {
1611 if (lsn == IB_ULONGLONG_MAX) {
1612 /* RESET restarts the sequence */
1613 log_bmp_sys->out_seq_num = 0;
1614 log_online_rotate_bitmap_file(0);
1615 } else {
1616 /* PURGE continues the sequence */
1617 log_online_rotate_bitmap_file
1618 (log_bmp_sys->end_lsn);
1619 }
1620 }
1621
1622 mutex_exit(&log_bmp_sys->mutex);
1623 }
1624
1625 free(bitmap_files.files);
1626 return result;
1627}

Subscribers

People subscribed via source and target branches