Merge lp:~vlad-lesin/percona-server/i_s-innodb-changed-pages into lp:percona-server/5.1
- i_s-innodb-changed-pages
- Merge into 5.1
Status: | Merged |
---|---|
Approved by: | Laurynas Biveinis |
Approved revision: | no longer in the source branch. |
Merged at revision: | 464 |
Proposed branch: | lp:~vlad-lesin/percona-server/i_s-innodb-changed-pages |
Merge into: | lp:percona-server/5.1 |
Diff against target: |
1010 lines (+703/-10) 19 files modified
Percona-Server/mysql-test/r/information_schema.result (+8/-4) Percona-Server/mysql-test/r/information_schema_db.result (+2/-1) Percona-Server/mysql-test/r/mysqlshow.result (+4/-2) Percona-Server/mysql-test/r/percona_server_variables_debug.result (+1/-0) Percona-Server/mysql-test/r/percona_server_variables_release.result (+1/-0) Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages.result (+41/-0) Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages_empty.result (+2/-0) Percona-Server/mysql-test/suite/innodb_plugin/r/percona_skip_innodb_i_s.result (+1/-0) Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages-master.opt (+1/-0) Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages.test (+103/-0) Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty-master.opt (+1/-0) Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty.test (+8/-0) Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc (+10/-1) Percona-Server/storage/innodb_plugin/handler/i_s.cc (+294/-1) Percona-Server/storage/innodb_plugin/handler/i_s.h (+1/-0) Percona-Server/storage/innodb_plugin/include/log0online.h (+60/-0) Percona-Server/storage/innodb_plugin/include/srv0srv.h (+3/-0) Percona-Server/storage/innodb_plugin/log/log0online.c (+160/-1) Percona-Server/storage/innodb_plugin/srv/srv0srv.c (+2/-0) |
To merge this branch: | bzr merge lp:~vlad-lesin/percona-server/i_s-innodb-changed-pages |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Approve | ||
Review via email: mp+117869@code.launchpad.net |
Commit message
Description of the change
This is implementation if INFORMATION_
Blueprint for this feature can be found here:
https:/
This merge proposal contains fixes of previous proposals and optimization of the table forming which allows to avoid full bitmap file scanning for certain condition templates(WHERE clauses).
This code was tested locally and all tests passed except "main.partition
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Vlad Lesin (vlad-lesin) wrote : | # |
> Diff line 281 query could be written as SELECT MAX(end_lsn) AS
> end_lsn FROM I_S....;
Done.
> The same comments re. server restart from
> https:/
> tracking-
> apply here too.
Done.
> srv_changed_
> need for separate extern declaration in i_s.cc.
Done.
> I'd name the max_lsn_struct to lsn_range_struct because that's
> what it is - or would get rid of it altogether, passing *min_lsn,
> *max_lsn to the get_max_
> a big deal. Likewise I'd rename get_max_
> to limit_lsn_
Done.
> The range start and end values are not updated correctly: they
> are both compared with their old values and updated if they are
> less. So if we have if start_lsn > 100 && start_lsn > 50, 50 will
> be chosen instead of 100. The way to do this is to start with
> start_lsn of zero and compare if it's greater than the old
> value, and end_lsn of +infinity, compared if it's smaller than the old
> value.
I think the current logic is right for "AND" operation and "less(or equal)" comparisons. The original task was to avoid full bitmap files scanning if we reach some limit value from condition. That's why only upper limits from "less(or equal)" comparisons are found. It finds the minimum value because if one of the "AND" operands is "false" the result of the whole operation is "false" too. For example for our expression "start_lsn < 100 && start_lsn < 50" there is no need to scan bitmaps further if start_lsn reaches 50 because the result of "AND" operation will be "false". For "start_lsn > 100 && start_lsn > 50 && start_lsn < 150 && 200 >= start_lsn" only last two comparisons will be parsed and "150" value will be a result because there is no sense to parse "greater(or equal)" comparisons as we can't calculate an offset of start bitmap block in a file. So any operand of "AND" is ignored if it is not a "(start|end)_lsn (<|<=) some_numeric_value" or "some_numeric_value (>=|>) (start|end)_lsn". And any conditions except "AND" and comparison itself are currently ignored.
> I am not sure if the condition range limiting is applied
> correctly in the main fill loop: if
> (LOG_BITMAP_
> In case we have requested an interval that has a checkpoint in
> the middle, this check will only output the rows up to that
> checkpoint and then ...START_LSN(i) > max_lsn.start will become
> true. I think currently (before we have multiple bitmap files)
> the only limitation we can do here is
> LOG_BTIMAP_
I'm not sure I understood you right. The function just stop scanning bitmap files if condition becomes "false" for certain condition pattern. The condition for "AND" operation becomes "false" if at least one operand is "false".
The condition:
if (LOG_BITMAP_
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Vlad -
You are right, I misunderstood the purpose of max start and max end lsn struct, I thought that it is meant to limit the lower bound of the read interval too, although this information cannot be usefully applied yet. In this case I am not sure we need to have the max start lsn at all and we can have a single end_lsn limit variable for simpler checks, where start_lsn is handled as follows: suppose the condition is start_lsn < 100, this means we have to read all blocks with start_lsn < 100. Which is equivalent to reading all the blocks with end_lsn <= 99, or just end_lsn < 100. And we know that have read all such blocks when we read a block where start_lsn >= 100. Condition LOG_BITMAP_
A check (whatever its final form is) in lines 627--629 should simply become a part of the while condition.
Should the "regular" ICP condition check (lines 659--660) be moved before table->
A few too long lines in the header comment of limit_lsn_
Misaligned comment starts in lines 737--747.
The log0online.h function declarations do not follow InnoDB style for their arguments. The log0online.c definitions follow them and have expanded comments, so probably should be re-copy-pasted to the header file. The header comments should be "Do something" instead of "Does something." The log_bitmap_
Vlad Lesin (vlad-lesin) wrote : | # |
> Vlad -
>
> You are right, I misunderstood the purpose of max start and max end lsn
> struct, I thought that it is meant to limit the lower bound of the read
> interval too, although this information cannot be usefully applied yet. In
> this case I am not sure we need to have the max start lsn at all and we can
> have a single end_lsn limit variable for simpler checks, where start_lsn is
> handled as follows: suppose the condition is start_lsn < 100, this means we
> have to read all blocks with start_lsn < 100. Which is equivalent to reading
> all the blocks with end_lsn <= 99, or just end_lsn < 100.
> And we know that
> have read all such blocks when we read a block where start_lsn >= 100.
> Condition LOG_BITMAP_
> Does this look correct to you?
Yes, that's a good idea, thanks. I changed limit_lsn_
> A check (whatever its final form is) in lines 627--629 should simply become a
> part of the while condition.
Done.
> Should the "regular" ICP condition check (lines 659--660) be moved before
> table->
No, it shouldn't. Because "cond->val_int()" use stored field values to calculate condition value. For example if condition is "page_id = 100" val_int() will use the table->field[1] value to calculate if condition for current iteration is true or false.
> A few too long lines in the header comment of
> limit_lsn_
>
> Misaligned comment starts in lines 737--747.
Done.
> The log0online.h function declarations do not follow InnoDB style for their
> arguments. The log0online.c definitions follow them and have expanded
> comments, so probably should be re-copy-pasted to the header file.
Done.
> The header
> comments should be "Do something" instead of "Does something."
If so there will not be uniformity because the other functions in "log0online.h" has "Does something" comments.
> The
> log_bitmap_
> instead of "out" because it is required that i is allocated beforehand.
Done.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Vlad -
The code looks good, I have some other minor comments:
Lines 461--462 and 464--465 should be exchanged for a bit
better comment readability (IMHO).
The function return value on line 588 is documented
incorrectly. It should not be a separate line with an /*!<out:
... */ comment but rather a "@return desription" tag at the end of
the header comment, grep InnoDB for "@return" for examples.
I am not sure what to do about the comment block in 610--630. It
is very descriptive and it is good to explain why the condition
it describes must look the way it does. But it breaks the code
flow and readability. Perhaps extract
LOG_
(static inline) function and make that comment its header comment?
Vlad Lesin (vlad-lesin) wrote : | # |
> Vlad -
>
> The code looks good, I have some other minor comments:
>
> Lines 461--462 and 464--465 should be exchanged for a bit
> better comment readability (IMHO).
>
Done.
> The function return value on line 588 is documented
> incorrectly. It should not be a separate line with an /*!<out:
> ... */ comment but rather a "@return desription" tag at the end of
> the header comment, grep InnoDB for "@return" for examples.
>
I saw the both styles. For example, see i_s_innodb_
> I am not sure what to do about the comment block in 610--630. It
> is very descriptive and it is good to explain why the condition
> it describes must look the way it does. But it breaks the code
> flow and readability. Perhaps extract
> LOG_BITMAP_
> (static inline) function and make that comment its header comment?
I think this comment will be out of context. Could you look at the padded version of the comment please? Maybe it looks readable enough. If no I will replace it in separate function.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Very minor comments:
Line 283: uppercase MIN()
Line 339: redundant --innodb
Line 494: s/filles/filled or maybe just "will be set to"
No need for another MP, just re-push with these fixes.
Vlad Lesin (vlad-lesin) wrote : | # |
> Very minor comments:
>
> Line 283: uppercase MIN()
> Line 339: redundant --innodb
> Line 494: s/filles/filled or maybe just "will be set to"
>
> No need for another MP, just re-push with these fixes.
Done.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Post-merge review: https:/
Preview Diff
1 | === modified file 'Percona-Server/mysql-test/r/information_schema.result' | |||
2 | --- Percona-Server/mysql-test/r/information_schema.result 2012-06-14 05:39:43 +0000 | |||
3 | +++ Percona-Server/mysql-test/r/information_schema.result 2012-08-15 14:14:06 +0000 | |||
4 | @@ -81,7 +81,7 @@ | |||
5 | 81 | VIEWS | 81 | VIEWS |
6 | 82 | INNODB_BUFFER_POOL_PAGES_INDEX | 82 | INNODB_BUFFER_POOL_PAGES_INDEX |
7 | 83 | INNODB_RSEG | 83 | INNODB_RSEG |
9 | 84 | INNODB_LOCKS | 84 | INNODB_CHANGED_PAGES |
10 | 85 | INNODB_BUFFER_POOL_PAGES | 85 | INNODB_BUFFER_POOL_PAGES |
11 | 86 | INNODB_TABLE_STATS | 86 | INNODB_TABLE_STATS |
12 | 87 | INNODB_TRX | 87 | INNODB_TRX |
13 | @@ -96,6 +96,7 @@ | |||
14 | 96 | INNODB_SYS_INDEXES | 96 | INNODB_SYS_INDEXES |
15 | 97 | INNODB_BUFFER_POOL_PAGES_BLOB | 97 | INNODB_BUFFER_POOL_PAGES_BLOB |
16 | 98 | INNODB_CMPMEM_RESET | 98 | INNODB_CMPMEM_RESET |
17 | 99 | INNODB_LOCKS | ||
18 | 99 | columns_priv | 100 | columns_priv |
19 | 100 | db | 101 | db |
20 | 101 | event | 102 | event |
21 | @@ -907,7 +908,7 @@ | |||
22 | 907 | flush privileges; | 908 | flush privileges; |
23 | 908 | SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA; | 909 | SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA; |
24 | 909 | table_schema count(*) | 910 | table_schema count(*) |
26 | 910 | information_schema 53 | 911 | information_schema 54 |
27 | 911 | mysql 22 | 912 | mysql 22 |
28 | 912 | create table t1 (i int, j int); | 913 | create table t1 (i int, j int); |
29 | 913 | create trigger trg1 before insert on t1 for each row | 914 | create trigger trg1 before insert on t1 for each row |
30 | @@ -1332,7 +1333,7 @@ | |||
31 | 1332 | VIEWS TABLE_SCHEMA | 1333 | VIEWS TABLE_SCHEMA |
32 | 1333 | INNODB_BUFFER_POOL_PAGES_INDEX index_id | 1334 | INNODB_BUFFER_POOL_PAGES_INDEX index_id |
33 | 1334 | INNODB_RSEG rseg_id | 1335 | INNODB_RSEG rseg_id |
35 | 1335 | INNODB_LOCKS lock_id | 1336 | INNODB_CHANGED_PAGES space_id |
36 | 1336 | INNODB_BUFFER_POOL_PAGES page_type | 1337 | INNODB_BUFFER_POOL_PAGES page_type |
37 | 1337 | INNODB_TABLE_STATS table_schema | 1338 | INNODB_TABLE_STATS table_schema |
38 | 1338 | INNODB_TRX trx_id | 1339 | INNODB_TRX trx_id |
39 | @@ -1347,6 +1348,7 @@ | |||
40 | 1347 | INNODB_SYS_INDEXES TABLE_ID | 1348 | INNODB_SYS_INDEXES TABLE_ID |
41 | 1348 | INNODB_BUFFER_POOL_PAGES_BLOB space_id | 1349 | INNODB_BUFFER_POOL_PAGES_BLOB space_id |
42 | 1349 | INNODB_CMPMEM_RESET page_size | 1350 | INNODB_CMPMEM_RESET page_size |
43 | 1351 | INNODB_LOCKS lock_id | ||
44 | 1350 | SELECT t.table_name, c1.column_name | 1352 | SELECT t.table_name, c1.column_name |
45 | 1351 | FROM information_schema.tables t | 1353 | FROM information_schema.tables t |
46 | 1352 | INNER JOIN | 1354 | INNER JOIN |
47 | @@ -1400,7 +1402,7 @@ | |||
48 | 1400 | VIEWS TABLE_SCHEMA | 1402 | VIEWS TABLE_SCHEMA |
49 | 1401 | INNODB_BUFFER_POOL_PAGES_INDEX index_id | 1403 | INNODB_BUFFER_POOL_PAGES_INDEX index_id |
50 | 1402 | INNODB_RSEG rseg_id | 1404 | INNODB_RSEG rseg_id |
52 | 1403 | INNODB_LOCKS lock_id | 1405 | INNODB_CHANGED_PAGES space_id |
53 | 1404 | INNODB_BUFFER_POOL_PAGES page_type | 1406 | INNODB_BUFFER_POOL_PAGES page_type |
54 | 1405 | INNODB_TABLE_STATS table_schema | 1407 | INNODB_TABLE_STATS table_schema |
55 | 1406 | INNODB_TRX trx_id | 1408 | INNODB_TRX trx_id |
56 | @@ -1415,6 +1417,7 @@ | |||
57 | 1415 | INNODB_SYS_INDEXES TABLE_ID | 1417 | INNODB_SYS_INDEXES TABLE_ID |
58 | 1416 | INNODB_BUFFER_POOL_PAGES_BLOB space_id | 1418 | INNODB_BUFFER_POOL_PAGES_BLOB space_id |
59 | 1417 | INNODB_CMPMEM_RESET page_size | 1419 | INNODB_CMPMEM_RESET page_size |
60 | 1420 | INNODB_LOCKS lock_id | ||
61 | 1418 | SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'); | 1421 | SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'); |
62 | 1419 | MAX(table_name) | 1422 | MAX(table_name) |
63 | 1420 | XTRADB_ADMIN_COMMAND | 1423 | XTRADB_ADMIN_COMMAND |
64 | @@ -1497,6 +1500,7 @@ | |||
65 | 1497 | INNODB_BUFFER_POOL_PAGES information_schema.INNODB_BUFFER_POOL_PAGES 1 | 1500 | INNODB_BUFFER_POOL_PAGES information_schema.INNODB_BUFFER_POOL_PAGES 1 |
66 | 1498 | INNODB_BUFFER_POOL_PAGES_BLOB information_schema.INNODB_BUFFER_POOL_PAGES_BLOB 1 | 1501 | INNODB_BUFFER_POOL_PAGES_BLOB information_schema.INNODB_BUFFER_POOL_PAGES_BLOB 1 |
67 | 1499 | INNODB_BUFFER_POOL_PAGES_INDEX information_schema.INNODB_BUFFER_POOL_PAGES_INDEX 1 | 1502 | INNODB_BUFFER_POOL_PAGES_INDEX information_schema.INNODB_BUFFER_POOL_PAGES_INDEX 1 |
68 | 1503 | INNODB_CHANGED_PAGES information_schema.INNODB_CHANGED_PAGES 1 | ||
69 | 1500 | INNODB_CMP information_schema.INNODB_CMP 1 | 1504 | INNODB_CMP information_schema.INNODB_CMP 1 |
70 | 1501 | INNODB_CMPMEM information_schema.INNODB_CMPMEM 1 | 1505 | INNODB_CMPMEM information_schema.INNODB_CMPMEM 1 |
71 | 1502 | INNODB_CMPMEM_RESET information_schema.INNODB_CMPMEM_RESET 1 | 1506 | INNODB_CMPMEM_RESET information_schema.INNODB_CMPMEM_RESET 1 |
72 | 1503 | 1507 | ||
73 | === modified file 'Percona-Server/mysql-test/r/information_schema_db.result' | |||
74 | --- Percona-Server/mysql-test/r/information_schema_db.result 2012-06-14 05:39:43 +0000 | |||
75 | +++ Percona-Server/mysql-test/r/information_schema_db.result 2012-08-15 14:14:06 +0000 | |||
76 | @@ -43,7 +43,7 @@ | |||
77 | 43 | VIEWS | 43 | VIEWS |
78 | 44 | INNODB_BUFFER_POOL_PAGES_INDEX | 44 | INNODB_BUFFER_POOL_PAGES_INDEX |
79 | 45 | INNODB_RSEG | 45 | INNODB_RSEG |
81 | 46 | INNODB_LOCKS | 46 | INNODB_CHANGED_PAGES |
82 | 47 | INNODB_BUFFER_POOL_PAGES | 47 | INNODB_BUFFER_POOL_PAGES |
83 | 48 | INNODB_TABLE_STATS | 48 | INNODB_TABLE_STATS |
84 | 49 | INNODB_TRX | 49 | INNODB_TRX |
85 | @@ -58,6 +58,7 @@ | |||
86 | 58 | INNODB_SYS_INDEXES | 58 | INNODB_SYS_INDEXES |
87 | 59 | INNODB_BUFFER_POOL_PAGES_BLOB | 59 | INNODB_BUFFER_POOL_PAGES_BLOB |
88 | 60 | INNODB_CMPMEM_RESET | 60 | INNODB_CMPMEM_RESET |
89 | 61 | INNODB_LOCKS | ||
90 | 61 | show tables from INFORMATION_SCHEMA like 'T%'; | 62 | show tables from INFORMATION_SCHEMA like 'T%'; |
91 | 62 | Tables_in_information_schema (T%) | 63 | Tables_in_information_schema (T%) |
92 | 63 | TABLES | 64 | TABLES |
93 | 64 | 65 | ||
94 | === modified file 'Percona-Server/mysql-test/r/mysqlshow.result' | |||
95 | --- Percona-Server/mysql-test/r/mysqlshow.result 2012-06-14 05:39:43 +0000 | |||
96 | +++ Percona-Server/mysql-test/r/mysqlshow.result 2012-08-15 14:14:06 +0000 | |||
97 | @@ -117,7 +117,7 @@ | |||
98 | 117 | | VIEWS | | 117 | | VIEWS | |
99 | 118 | | INNODB_BUFFER_POOL_PAGES_INDEX | | 118 | | INNODB_BUFFER_POOL_PAGES_INDEX | |
100 | 119 | | INNODB_RSEG | | 119 | | INNODB_RSEG | |
102 | 120 | | INNODB_LOCKS | | 120 | | INNODB_CHANGED_PAGES | |
103 | 121 | | INNODB_BUFFER_POOL_PAGES | | 121 | | INNODB_BUFFER_POOL_PAGES | |
104 | 122 | | INNODB_TABLE_STATS | | 122 | | INNODB_TABLE_STATS | |
105 | 123 | | INNODB_TRX | | 123 | | INNODB_TRX | |
106 | @@ -132,6 +132,7 @@ | |||
107 | 132 | | INNODB_SYS_INDEXES | | 132 | | INNODB_SYS_INDEXES | |
108 | 133 | | INNODB_BUFFER_POOL_PAGES_BLOB | | 133 | | INNODB_BUFFER_POOL_PAGES_BLOB | |
109 | 134 | | INNODB_CMPMEM_RESET | | 134 | | INNODB_CMPMEM_RESET | |
110 | 135 | | INNODB_LOCKS | | ||
111 | 135 | +---------------------------------------+ | 136 | +---------------------------------------+ |
112 | 136 | Database: INFORMATION_SCHEMA | 137 | Database: INFORMATION_SCHEMA |
113 | 137 | +---------------------------------------+ | 138 | +---------------------------------------+ |
114 | @@ -175,7 +176,7 @@ | |||
115 | 175 | | VIEWS | | 176 | | VIEWS | |
116 | 176 | | INNODB_BUFFER_POOL_PAGES_INDEX | | 177 | | INNODB_BUFFER_POOL_PAGES_INDEX | |
117 | 177 | | INNODB_RSEG | | 178 | | INNODB_RSEG | |
119 | 178 | | INNODB_LOCKS | | 179 | | INNODB_CHANGED_PAGES | |
120 | 179 | | INNODB_BUFFER_POOL_PAGES | | 180 | | INNODB_BUFFER_POOL_PAGES | |
121 | 180 | | INNODB_TABLE_STATS | | 181 | | INNODB_TABLE_STATS | |
122 | 181 | | INNODB_TRX | | 182 | | INNODB_TRX | |
123 | @@ -190,6 +191,7 @@ | |||
124 | 190 | | INNODB_SYS_INDEXES | | 191 | | INNODB_SYS_INDEXES | |
125 | 191 | | INNODB_BUFFER_POOL_PAGES_BLOB | | 192 | | INNODB_BUFFER_POOL_PAGES_BLOB | |
126 | 192 | | INNODB_CMPMEM_RESET | | 193 | | INNODB_CMPMEM_RESET | |
127 | 194 | | INNODB_LOCKS | | ||
128 | 193 | +---------------------------------------+ | 195 | +---------------------------------------+ |
129 | 194 | Wildcard: inf_rmation_schema | 196 | Wildcard: inf_rmation_schema |
130 | 195 | +--------------------+ | 197 | +--------------------+ |
131 | 196 | 198 | ||
132 | === modified file 'Percona-Server/mysql-test/r/percona_server_variables_debug.result' | |||
133 | --- Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-06-14 09:16:03 +0000 | |||
134 | +++ Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-08-15 14:14:06 +0000 | |||
135 | @@ -86,6 +86,7 @@ | |||
136 | 86 | INNODB_BUFFER_POOL_SHM_CHECKSUM | 86 | INNODB_BUFFER_POOL_SHM_CHECKSUM |
137 | 87 | INNODB_BUFFER_POOL_SHM_KEY | 87 | INNODB_BUFFER_POOL_SHM_KEY |
138 | 88 | INNODB_BUFFER_POOL_SIZE | 88 | INNODB_BUFFER_POOL_SIZE |
139 | 89 | INNODB_CHANGED_PAGES_LIMIT | ||
140 | 89 | INNODB_CHANGE_BUFFERING | 90 | INNODB_CHANGE_BUFFERING |
141 | 90 | INNODB_CHECKPOINT_AGE_TARGET | 91 | INNODB_CHECKPOINT_AGE_TARGET |
142 | 91 | INNODB_CHECKSUMS | 92 | INNODB_CHECKSUMS |
143 | 92 | 93 | ||
144 | === modified file 'Percona-Server/mysql-test/r/percona_server_variables_release.result' | |||
145 | --- Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-06-14 09:16:03 +0000 | |||
146 | +++ Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-08-15 14:14:06 +0000 | |||
147 | @@ -84,6 +84,7 @@ | |||
148 | 84 | INNODB_BUFFER_POOL_SHM_CHECKSUM | 84 | INNODB_BUFFER_POOL_SHM_CHECKSUM |
149 | 85 | INNODB_BUFFER_POOL_SHM_KEY | 85 | INNODB_BUFFER_POOL_SHM_KEY |
150 | 86 | INNODB_BUFFER_POOL_SIZE | 86 | INNODB_BUFFER_POOL_SIZE |
151 | 87 | INNODB_CHANGED_PAGES_LIMIT | ||
152 | 87 | INNODB_CHANGE_BUFFERING | 88 | INNODB_CHANGE_BUFFERING |
153 | 88 | INNODB_CHECKPOINT_AGE_TARGET | 89 | INNODB_CHECKPOINT_AGE_TARGET |
154 | 89 | INNODB_CHECKSUMS | 90 | INNODB_CHECKSUMS |
155 | 90 | 91 | ||
156 | === added file 'Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages.result' | |||
157 | --- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages.result 1970-01-01 00:00:00 +0000 | |||
158 | +++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages.result 2012-08-15 14:14:06 +0000 | |||
159 | @@ -0,0 +1,41 @@ | |||
160 | 1 | SELECT @@innodb_track_changed_pages; | ||
161 | 2 | @@innodb_track_changed_pages | ||
162 | 3 | 1 | ||
163 | 4 | SET @OLD_INNODB_CHANGED_PAGES_LIMIT = @@GLOBAL.INNODB_CHANGED_PAGES_LIMIT; | ||
164 | 5 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = 0; | ||
165 | 6 | CREATE TABLE T1 (F1 CHAR(255)) ENGINE=INNODB; | ||
166 | 7 | SET @t1_space_id = | ||
167 | 8 | (SELECT SPACE | ||
168 | 9 | FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES | ||
169 | 10 | WHERE | ||
170 | 11 | INFORMATION_SCHEMA.INNODB_SYS_TABLES.SCHEMA='test' AND | ||
171 | 12 | INFORMATION_SCHEMA.INNODB_SYS_TABLES.NAME='T1'); | ||
172 | 13 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = 0; | ||
173 | 14 | SELECT COUNT(DISTINCT PAGE_ID) >= (1024000/16384) | ||
174 | 15 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
175 | 16 | WHERE SPACE_ID = @t1_space_id; | ||
176 | 17 | COUNT(DISTINCT PAGE_ID) >= (1024000/16384) | ||
177 | 18 | 1 | ||
178 | 19 | SELECT MAX(PAGE_ID) < (3*1024000/16384) | ||
179 | 20 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
180 | 21 | WHERE SPACE_ID = @t1_space_id; | ||
181 | 22 | MAX(PAGE_ID) < (3*1024000/16384) | ||
182 | 23 | 1 | ||
183 | 24 | SELECT COUNT(*) | ||
184 | 25 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
185 | 26 | WHERE START_LSN >= END_LSN; | ||
186 | 27 | COUNT(*) | ||
187 | 28 | 0 | ||
188 | 29 | SELECT COUNT(*) = @cond_test_pages_count | ||
189 | 30 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
190 | 31 | WHERE | ||
191 | 32 | END_LSN > (@cond_test_lsn - 1) AND | ||
192 | 33 | END_LSN < (@cond_test_lsn + 1); | ||
193 | 34 | COUNT(*) = @cond_test_pages_count | ||
194 | 35 | 1 | ||
195 | 36 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = 1; | ||
196 | 37 | SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES; | ||
197 | 38 | COUNT(*) | ||
198 | 39 | 1 | ||
199 | 40 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = @OLD_INNODB_CHANGED_PAGES_LIMIT; | ||
200 | 41 | DROP TABLE T1; | ||
201 | 0 | 42 | ||
202 | === added file 'Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages_empty.result' | |||
203 | --- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages_empty.result 1970-01-01 00:00:00 +0000 | |||
204 | +++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_pages_empty.result 2012-08-15 14:14:06 +0000 | |||
205 | @@ -0,0 +1,2 @@ | |||
206 | 1 | SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES; | ||
207 | 2 | space_id page_id start_lsn end_lsn | ||
208 | 0 | 3 | ||
209 | === modified file 'Percona-Server/mysql-test/suite/innodb_plugin/r/percona_skip_innodb_i_s.result' | |||
210 | --- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_skip_innodb_i_s.result 2012-06-15 05:57:51 +0000 | |||
211 | +++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_skip_innodb_i_s.result 2012-08-15 14:14:06 +0000 | |||
212 | @@ -3,6 +3,7 @@ | |||
213 | 3 | INNODB_BUFFER_POOL_PAGES | 3 | INNODB_BUFFER_POOL_PAGES |
214 | 4 | INNODB_BUFFER_POOL_PAGES_BLOB | 4 | INNODB_BUFFER_POOL_PAGES_BLOB |
215 | 5 | INNODB_BUFFER_POOL_PAGES_INDEX | 5 | INNODB_BUFFER_POOL_PAGES_INDEX |
216 | 6 | INNODB_CHANGED_PAGES | ||
217 | 6 | INNODB_CMP | 7 | INNODB_CMP |
218 | 7 | INNODB_CMPMEM | 8 | INNODB_CMPMEM |
219 | 8 | INNODB_CMPMEM_RESET | 9 | INNODB_CMPMEM_RESET |
220 | 9 | 10 | ||
221 | === added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages-master.opt' | |||
222 | --- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages-master.opt 1970-01-01 00:00:00 +0000 | |||
223 | +++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages-master.opt 2012-08-15 14:14:06 +0000 | |||
224 | @@ -0,0 +1,1 @@ | |||
225 | 1 | --innodb_track_changed_pages=TRUE --innodb_log_file_size=1M --innodb-file-per-table | ||
226 | 0 | 2 | ||
227 | === added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages.test' | |||
228 | --- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages.test 1970-01-01 00:00:00 +0000 | |||
229 | +++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages.test 2012-08-15 14:14:06 +0000 | |||
230 | @@ -0,0 +1,103 @@ | |||
231 | 1 | ########################################### | ||
232 | 2 | # Test for I_S.INNODB_CHANGED_PAGES table # | ||
233 | 3 | ########################################### | ||
234 | 4 | |||
235 | 5 | --source include/have_innodb_plugin.inc | ||
236 | 6 | |||
237 | 7 | SELECT @@innodb_track_changed_pages; | ||
238 | 8 | |||
239 | 9 | SET @OLD_INNODB_CHANGED_PAGES_LIMIT = @@GLOBAL.INNODB_CHANGED_PAGES_LIMIT; | ||
240 | 10 | |||
241 | 11 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = 0; | ||
242 | 12 | |||
243 | 13 | CREATE TABLE T1 (F1 CHAR(255)) ENGINE=INNODB; | ||
244 | 14 | SET @t1_space_id = | ||
245 | 15 | (SELECT SPACE | ||
246 | 16 | FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES | ||
247 | 17 | WHERE | ||
248 | 18 | INFORMATION_SCHEMA.INNODB_SYS_TABLES.SCHEMA='test' AND | ||
249 | 19 | INFORMATION_SCHEMA.INNODB_SYS_TABLES.NAME='T1'); | ||
250 | 20 | |||
251 | 21 | --disable_query_log | ||
252 | 22 | --disable_result_log | ||
253 | 23 | |||
254 | 24 | ######################################################################### | ||
255 | 25 | # The maximum log size is 1MB. Each row occupies at least 256 bytes. # | ||
256 | 26 | # Each iteration inserts 100 rows. They occupies at least 25KB. To be # | ||
257 | 27 | # sure that tracking log thread wrote at least 1M/16K pages we need to # | ||
258 | 28 | # exceed maximum log size twice. That means we should do at least # | ||
259 | 29 | # 2M/25K = 80 iterations. # | ||
260 | 30 | ######################################################################### | ||
261 | 31 | --let $i=80 | ||
262 | 32 | |||
263 | 33 | while ($i) | ||
264 | 34 | { | ||
265 | 35 | --dec $i | ||
266 | 36 | INSERT INTO T1 (F1) VALUES | ||
267 | 37 | ("1"), ("2"), ("3"), ("4"), ("5"), ("6"), ("7"), ("8"), ("9"), ("10"), | ||
268 | 38 | ("11"), ("12"), ("13"), ("14"), ("15"), ("16"), ("17"), ("18"), ("19"), ("20"), | ||
269 | 39 | ("21"), ("22"), ("23"), ("24"), ("25"), ("26"), ("27"), ("28"), ("29"), ("30"), | ||
270 | 40 | ("31"), ("32"), ("33"), ("34"), ("35"), ("36"), ("37"), ("38"), ("39"), ("40"), | ||
271 | 41 | ("41"), ("42"), ("43"), ("44"), ("45"), ("46"), ("47"), ("48"), ("49"), ("50"), | ||
272 | 42 | ("51"), ("52"), ("53"), ("54"), ("55"), ("56"), ("57"), ("58"), ("59"), ("60"), | ||
273 | 43 | ("61"), ("62"), ("63"), ("64"), ("65"), ("66"), ("67"), ("68"), ("69"), ("70"), | ||
274 | 44 | ("71"), ("72"), ("73"), ("74"), ("75"), ("76"), ("77"), ("78"), ("79"), ("80"), | ||
275 | 45 | ("81"), ("82"), ("83"), ("84"), ("85"), ("86"), ("87"), ("88"), ("89"), ("90"), | ||
276 | 46 | ("91"), ("92"), ("93"), ("94"), ("95"), ("96"), ("97"), ("98"), ("99"), ("100"); | ||
277 | 47 | } | ||
278 | 48 | |||
279 | 49 | ################################################################### | ||
280 | 50 | # Gather data for condition pushdown testing not using conditions # | ||
281 | 51 | ################################################################### | ||
282 | 52 | SET @cond_test_lsn= | ||
283 | 53 | (SELECT MIN(end_lsn) | ||
284 | 54 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES); | ||
285 | 55 | |||
286 | 56 | SET @cond_test_pages_count= | ||
287 | 57 | (SELECT count(*) | ||
288 | 58 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
289 | 59 | GROUP BY end_lsn | ||
290 | 60 | ORDER BY end_lsn | ||
291 | 61 | LIMIT 1); | ||
292 | 62 | |||
293 | 63 | --enable_query_log | ||
294 | 64 | --enable_result_log | ||
295 | 65 | |||
296 | 66 | ############################################################### | ||
297 | 67 | # Check if the number of changed pages is greater than 1M/16K # | ||
298 | 68 | ############################################################### | ||
299 | 69 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = 0; | ||
300 | 70 | SELECT COUNT(DISTINCT PAGE_ID) >= (1024000/16384) | ||
301 | 71 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
302 | 72 | WHERE SPACE_ID = @t1_space_id; | ||
303 | 73 | ############################################################# | ||
304 | 74 | # Check if the maximum page id is less than resonable limit # | ||
305 | 75 | ############################################################# | ||
306 | 76 | SELECT MAX(PAGE_ID) < (3*1024000/16384) | ||
307 | 77 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
308 | 78 | WHERE SPACE_ID = @t1_space_id; | ||
309 | 79 | ######################################################## | ||
310 | 80 | # The records where START_LSN >= END_LSN should absent # | ||
311 | 81 | ######################################################## | ||
312 | 82 | SELECT COUNT(*) | ||
313 | 83 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
314 | 84 | WHERE START_LSN >= END_LSN; | ||
315 | 85 | |||
316 | 86 | ###################################################### | ||
317 | 87 | # Check condition if pushdown doesn't break anything # | ||
318 | 88 | ###################################################### | ||
319 | 89 | SELECT COUNT(*) = @cond_test_pages_count | ||
320 | 90 | FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES | ||
321 | 91 | WHERE | ||
322 | 92 | END_LSN > (@cond_test_lsn - 1) AND | ||
323 | 93 | END_LSN < (@cond_test_lsn + 1); | ||
324 | 94 | |||
325 | 95 | ################################################ | ||
326 | 96 | # Check how limit for maximum rows count works # | ||
327 | 97 | ################################################ | ||
328 | 98 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = 1; | ||
329 | 99 | SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES; | ||
330 | 100 | |||
331 | 101 | SET GLOBAL INNODB_CHANGED_PAGES_LIMIT = @OLD_INNODB_CHANGED_PAGES_LIMIT; | ||
332 | 102 | |||
333 | 103 | DROP TABLE T1; | ||
334 | 0 | 104 | ||
335 | === added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty-master.opt' | |||
336 | --- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty-master.opt 1970-01-01 00:00:00 +0000 | |||
337 | +++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty-master.opt 2012-08-15 14:14:06 +0000 | |||
338 | @@ -0,0 +1,1 @@ | |||
339 | 1 | --innodb_track_changed_pages=false | ||
340 | 0 | 2 | ||
341 | === added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty.test' | |||
342 | --- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty.test 1970-01-01 00:00:00 +0000 | |||
343 | +++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_pages_empty.test 2012-08-15 14:14:06 +0000 | |||
344 | @@ -0,0 +1,8 @@ | |||
345 | 1 | ############################################################################### | ||
346 | 2 | # Test for empty I_S.INNODB_CHANGED_PAGES table. The table should be empty if# | ||
347 | 3 | # innodb_track_changed_pages is false. # | ||
348 | 4 | ############################################################################### | ||
349 | 5 | |||
350 | 6 | --source include/have_innodb_plugin.inc | ||
351 | 7 | |||
352 | 8 | SELECT * FROM INFORMATION_SCHEMA.INNODB_CHANGED_PAGES; | ||
353 | 0 | 9 | ||
354 | === modified file 'Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc' | |||
355 | --- Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc 2012-07-02 02:04:45 +0000 | |||
356 | +++ Percona-Server/storage/innodb_plugin/handler/ha_innodb.cc 2012-08-15 14:14:06 +0000 | |||
357 | @@ -11934,6 +11934,13 @@ | |||
358 | 11934 | "Track the redo log for changed pages and output a changed page bitmap", | 11934 | "Track the redo log for changed pages and output a changed page bitmap", |
359 | 11935 | NULL, NULL, FALSE); | 11935 | NULL, NULL, FALSE); |
360 | 11936 | 11936 | ||
361 | 11937 | static MYSQL_SYSVAR_ULONGLONG(changed_pages_limit, srv_changed_pages_limit, | ||
362 | 11938 | PLUGIN_VAR_RQCMDARG, | ||
363 | 11939 | "The maximum number of rows for " | ||
364 | 11940 | "INFORMATION_SCHEMA.INNODB_CHANGED_PAGES table, " | ||
365 | 11941 | "0 - unlimited", | ||
366 | 11942 | NULL, NULL, 1000000, 0, ~0ULL, 0); | ||
367 | 11943 | |||
368 | 11937 | #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG | 11944 | #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG |
369 | 11938 | static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug, | 11945 | static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug, |
370 | 11939 | PLUGIN_VAR_RQCMDARG, | 11946 | PLUGIN_VAR_RQCMDARG, |
371 | @@ -12181,6 +12188,7 @@ | |||
372 | 12181 | MYSQL_SYSVAR(use_sys_malloc), | 12188 | MYSQL_SYSVAR(use_sys_malloc), |
373 | 12182 | MYSQL_SYSVAR(change_buffering), | 12189 | MYSQL_SYSVAR(change_buffering), |
374 | 12183 | MYSQL_SYSVAR(track_changed_pages), | 12190 | MYSQL_SYSVAR(track_changed_pages), |
375 | 12191 | MYSQL_SYSVAR(changed_pages_limit), | ||
376 | 12184 | #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG | 12192 | #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG |
377 | 12185 | MYSQL_SYSVAR(change_buffering_debug), | 12193 | MYSQL_SYSVAR(change_buffering_debug), |
378 | 12186 | #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ | 12194 | #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ |
379 | @@ -12230,7 +12238,8 @@ | |||
380 | 12230 | i_s_innodb_admin_command, | 12238 | i_s_innodb_admin_command, |
381 | 12231 | i_s_innodb_sys_tables, | 12239 | i_s_innodb_sys_tables, |
382 | 12232 | i_s_innodb_sys_indexes, | 12240 | i_s_innodb_sys_indexes, |
384 | 12233 | i_s_innodb_sys_stats | 12241 | i_s_innodb_sys_stats, |
385 | 12242 | i_s_innodb_changed_pages | ||
386 | 12234 | mysql_declare_plugin_end; | 12243 | mysql_declare_plugin_end; |
387 | 12235 | 12244 | ||
388 | 12236 | /** @brief Initialize the default value of innodb_commit_concurrency. | 12245 | /** @brief Initialize the default value of innodb_commit_concurrency. |
389 | 12237 | 12246 | ||
390 | === modified file 'Percona-Server/storage/innodb_plugin/handler/i_s.cc' | |||
391 | --- Percona-Server/storage/innodb_plugin/handler/i_s.cc 2012-06-15 05:57:51 +0000 | |||
392 | +++ Percona-Server/storage/innodb_plugin/handler/i_s.cc 2012-08-15 14:14:06 +0000 | |||
393 | @@ -22,8 +22,15 @@ | |||
394 | 22 | 22 | ||
395 | 23 | Created July 18, 2007 Vasil Dimov | 23 | Created July 18, 2007 Vasil Dimov |
396 | 24 | *******************************************************/ | 24 | *******************************************************/ |
397 | 25 | #ifndef MYSQL_SERVER | ||
398 | 26 | #define MYSQL_SERVER /* For Item_* classes */ | ||
399 | 27 | #include <mysql_priv.h> | ||
400 | 28 | /* Prevent influence of this definition to other headers */ | ||
401 | 29 | #undef MYSQL_SERVER | ||
402 | 30 | #else | ||
403 | 31 | #include <mysql_priv.h> | ||
404 | 32 | #endif //MYSQL_SERVER | ||
405 | 25 | 33 | ||
406 | 26 | #include <mysql_priv.h> | ||
407 | 27 | #include <mysqld_error.h> | 34 | #include <mysqld_error.h> |
408 | 28 | 35 | ||
409 | 29 | #include <m_ctype.h> | 36 | #include <m_ctype.h> |
410 | @@ -47,6 +54,7 @@ | |||
411 | 47 | #include "dict0dict.h" /* for dict_sys */ | 54 | #include "dict0dict.h" /* for dict_sys */ |
412 | 48 | #include "btr0pcur.h" | 55 | #include "btr0pcur.h" |
413 | 49 | #include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */ | 56 | #include "buf0lru.h" /* for XTRA_LRU_[DUMP/RESTORE] */ |
414 | 57 | #include "log0online.h" | ||
415 | 50 | } | 58 | } |
416 | 51 | 59 | ||
417 | 52 | static const char plugin_author[] = "Innobase Oy"; | 60 | static const char plugin_author[] = "Innobase Oy"; |
418 | @@ -3639,3 +3647,288 @@ | |||
419 | 3639 | STRUCT_FLD(system_vars, NULL), | 3647 | STRUCT_FLD(system_vars, NULL), |
420 | 3640 | STRUCT_FLD(__reserved1, NULL) | 3648 | STRUCT_FLD(__reserved1, NULL) |
421 | 3641 | }; | 3649 | }; |
422 | 3650 | |||
423 | 3651 | static ST_FIELD_INFO i_s_innodb_changed_pages_info[] = | ||
424 | 3652 | { | ||
425 | 3653 | {STRUCT_FLD(field_name, "space_id"), | ||
426 | 3654 | STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), | ||
427 | 3655 | STRUCT_FLD(field_type, MYSQL_TYPE_LONG), | ||
428 | 3656 | STRUCT_FLD(value, 0), | ||
429 | 3657 | STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), | ||
430 | 3658 | STRUCT_FLD(old_name, ""), | ||
431 | 3659 | STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, | ||
432 | 3660 | |||
433 | 3661 | {STRUCT_FLD(field_name, "page_id"), | ||
434 | 3662 | STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), | ||
435 | 3663 | STRUCT_FLD(field_type, MYSQL_TYPE_LONG), | ||
436 | 3664 | STRUCT_FLD(value, 0), | ||
437 | 3665 | STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), | ||
438 | 3666 | STRUCT_FLD(old_name, ""), | ||
439 | 3667 | STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, | ||
440 | 3668 | |||
441 | 3669 | {STRUCT_FLD(field_name, "start_lsn"), | ||
442 | 3670 | STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), | ||
443 | 3671 | STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), | ||
444 | 3672 | STRUCT_FLD(value, 0), | ||
445 | 3673 | STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), | ||
446 | 3674 | STRUCT_FLD(old_name, ""), | ||
447 | 3675 | STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, | ||
448 | 3676 | |||
449 | 3677 | {STRUCT_FLD(field_name, "end_lsn"), | ||
450 | 3678 | STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), | ||
451 | 3679 | STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), | ||
452 | 3680 | STRUCT_FLD(value, 0), | ||
453 | 3681 | STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), | ||
454 | 3682 | STRUCT_FLD(old_name, ""), | ||
455 | 3683 | STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, | ||
456 | 3684 | |||
457 | 3685 | END_OF_ST_FIELD_INFO | ||
458 | 3686 | }; | ||
459 | 3687 | |||
460 | 3688 | /*********************************************************************** | ||
461 | 3689 | This function parses condition and gets upper bounds for start and end LSN's | ||
462 | 3690 | if condition corresponds to certain pattern. | ||
463 | 3691 | |||
464 | 3692 | We can't know right position to avoid scanning bitmap files from the beginning | ||
465 | 3693 | to the lower bound. But we can stop scanning bitmap files if we reach upper bound. | ||
466 | 3694 | |||
467 | 3695 | It's expected the most used queries will be like the following: | ||
468 | 3696 | |||
469 | 3697 | SELECT * FROM INNODB_CHANGED_PAGES WHERE START_LSN > num1 AND start_lsn < num2; | ||
470 | 3698 | |||
471 | 3699 | That's why the pattern is: | ||
472 | 3700 | |||
473 | 3701 | pattern: comp | and_comp; | ||
474 | 3702 | comp: lsn < int_num | lsn <= int_num | int_num > lsn | int_num >= lsn; | ||
475 | 3703 | lsn: start_lsn | end_lsn; | ||
476 | 3704 | and_comp: some_expression AND some_expression | some_expression AND and_comp; | ||
477 | 3705 | some_expression: comp | any_other_expression; | ||
478 | 3706 | |||
479 | 3707 | Suppose the condition is start_lsn < 100, this means we have to read all | ||
480 | 3708 | blocks with start_lsn < 100. Which is equivalent to reading all the blocks | ||
481 | 3709 | with end_lsn <= 99, or just end_lsn < 100. That's why it's enough to find | ||
482 | 3710 | maximum lsn value, doesn't matter if this is start or end lsn and compare | ||
483 | 3711 | it with "start_lsn" field. | ||
484 | 3712 | |||
485 | 3713 | Example: | ||
486 | 3714 | |||
487 | 3715 | SELECT * FROM INNODB_CHANGED_PAGES | ||
488 | 3716 | WHERE | ||
489 | 3717 | start_lsn > 10 AND | ||
490 | 3718 | end_lsn <= 1111 AND | ||
491 | 3719 | 555 > end_lsn AND | ||
492 | 3720 | page_id = 100; | ||
493 | 3721 | |||
494 | 3722 | max_lsn will be set to 555. | ||
495 | 3723 | */ | ||
496 | 3724 | static | ||
497 | 3725 | void | ||
498 | 3726 | limit_lsn_range_from_condition( | ||
499 | 3727 | /*===========================*/ | ||
500 | 3728 | TABLE* table, /*!<in: table */ | ||
501 | 3729 | COND* cond, /*!<in: condition */ | ||
502 | 3730 | ib_uint64_t* max_lsn) /*!<in/out: maximum LSN | ||
503 | 3731 | (must be initialized with maximum | ||
504 | 3732 | available value) */ | ||
505 | 3733 | { | ||
506 | 3734 | if (cond->type() != Item::COND_ITEM && | ||
507 | 3735 | cond->type() != Item::FUNC_ITEM) | ||
508 | 3736 | return; | ||
509 | 3737 | |||
510 | 3738 | switch (((Item_func*) cond)->functype()) | ||
511 | 3739 | { | ||
512 | 3740 | case Item_func::COND_AND_FUNC: | ||
513 | 3741 | { | ||
514 | 3742 | List_iterator<Item> li(*((Item_cond*) cond)-> | ||
515 | 3743 | argument_list()); | ||
516 | 3744 | Item *item; | ||
517 | 3745 | while ((item= li++)) | ||
518 | 3746 | limit_lsn_range_from_condition(table, | ||
519 | 3747 | item, | ||
520 | 3748 | max_lsn); | ||
521 | 3749 | break; | ||
522 | 3750 | } | ||
523 | 3751 | case Item_func::LT_FUNC: | ||
524 | 3752 | case Item_func::LE_FUNC: | ||
525 | 3753 | case Item_func::GT_FUNC: | ||
526 | 3754 | case Item_func::GE_FUNC: | ||
527 | 3755 | { | ||
528 | 3756 | Item *left; | ||
529 | 3757 | Item *right; | ||
530 | 3758 | Item_field *item_field; | ||
531 | 3759 | ib_uint64_t tmp_result; | ||
532 | 3760 | |||
533 | 3761 | /* | ||
534 | 3762 | a <= b equals to b >= a that's why we just exchange | ||
535 | 3763 | "left" and "right" in the case of ">" or ">=" | ||
536 | 3764 | function | ||
537 | 3765 | */ | ||
538 | 3766 | if (((Item_func*) cond)->functype() == | ||
539 | 3767 | Item_func::LT_FUNC || | ||
540 | 3768 | ((Item_func*) cond)->functype() == | ||
541 | 3769 | Item_func::LE_FUNC) | ||
542 | 3770 | { | ||
543 | 3771 | left = ((Item_func*) cond)->arguments()[0]; | ||
544 | 3772 | right = ((Item_func*) cond)->arguments()[1]; | ||
545 | 3773 | } else { | ||
546 | 3774 | left = ((Item_func*) cond)->arguments()[1]; | ||
547 | 3775 | right = ((Item_func*) cond)->arguments()[0]; | ||
548 | 3776 | } | ||
549 | 3777 | |||
550 | 3778 | if (!left || !right) | ||
551 | 3779 | return; | ||
552 | 3780 | if (left->type() != Item::FIELD_ITEM) | ||
553 | 3781 | return; | ||
554 | 3782 | if (right->type() != Item::INT_ITEM) | ||
555 | 3783 | return; | ||
556 | 3784 | |||
557 | 3785 | item_field = (Item_field*)left; | ||
558 | 3786 | |||
559 | 3787 | if (/* START_LSN */ | ||
560 | 3788 | table->field[2] != item_field->field && | ||
561 | 3789 | /* END_LSN */ | ||
562 | 3790 | table->field[3] != item_field->field) | ||
563 | 3791 | { | ||
564 | 3792 | return; | ||
565 | 3793 | } | ||
566 | 3794 | |||
567 | 3795 | /* Check if the current field belongs to our table */ | ||
568 | 3796 | if (table != item_field->field->table) | ||
569 | 3797 | return; | ||
570 | 3798 | |||
571 | 3799 | tmp_result = right->val_int(); | ||
572 | 3800 | if (tmp_result < *max_lsn) | ||
573 | 3801 | *max_lsn = tmp_result; | ||
574 | 3802 | |||
575 | 3803 | break; | ||
576 | 3804 | } | ||
577 | 3805 | default:; | ||
578 | 3806 | } | ||
579 | 3807 | |||
580 | 3808 | } | ||
581 | 3809 | |||
582 | 3810 | /*********************************************************************** | ||
583 | 3811 | Fill the dynamic table information_schema.innodb_changed_pages. | ||
584 | 3812 | @return 0 on success, 1 on failure */ | ||
585 | 3813 | static | ||
586 | 3814 | int | ||
587 | 3815 | i_s_innodb_changed_pages_fill( | ||
588 | 3816 | /*==========================*/ | ||
589 | 3817 | THD* thd, /*!<in: thread */ | ||
590 | 3818 | TABLE_LIST* tables, /*!<in/out: tables to fill */ | ||
591 | 3819 | COND* cond) /*!<in: condition */ | ||
592 | 3820 | { | ||
593 | 3821 | TABLE* table = (TABLE *) tables->table; | ||
594 | 3822 | log_bitmap_iterator_t i; | ||
595 | 3823 | ib_uint64_t output_rows_num = 0UL; | ||
596 | 3824 | ib_uint64_t max_lsn = ~0ULL; | ||
597 | 3825 | |||
598 | 3826 | if (!srv_track_changed_pages) | ||
599 | 3827 | return 0; | ||
600 | 3828 | |||
601 | 3829 | if (!log_online_bitmap_iterator_init(&i)) | ||
602 | 3830 | return 1; | ||
603 | 3831 | |||
604 | 3832 | if (cond) | ||
605 | 3833 | limit_lsn_range_from_condition(table, cond, &max_lsn); | ||
606 | 3834 | |||
607 | 3835 | while(log_online_bitmap_iterator_next(&i) && | ||
608 | 3836 | (!srv_changed_pages_limit || | ||
609 | 3837 | output_rows_num < srv_changed_pages_limit) && | ||
610 | 3838 | /* | ||
611 | 3839 | There is no need to compare both start LSN and end LSN fields | ||
612 | 3840 | with maximum value. It's enough to compare only start LSN. | ||
613 | 3841 | Example: | ||
614 | 3842 | |||
615 | 3843 | max_lsn = 100 | ||
616 | 3844 | \\\\\\\\\\\\\\\\\\\\\\\\\|\\\\\\\\ - Query 1 | ||
617 | 3845 | I------I I-------I I-------------I I----I | ||
618 | 3846 | ////////////////// | - Query 2 | ||
619 | 3847 | 1 2 3 4 | ||
620 | 3848 | |||
621 | 3849 | Query 1: | ||
622 | 3850 | SELECT * FROM INNODB_CHANGED_PAGES WHERE start_lsn < 100 | ||
623 | 3851 | will select 1,2,3 bitmaps | ||
624 | 3852 | Query 2: | ||
625 | 3853 | SELECT * FROM INNODB_CHANGED_PAGES WHERE end_lsn < 100 | ||
626 | 3854 | will select 1,2 bitmaps | ||
627 | 3855 | |||
628 | 3856 | The condition start_lsn <= 100 will be false after reading | ||
629 | 3857 | 1,2,3 bitmaps which suits for both cases. | ||
630 | 3858 | */ | ||
631 | 3859 | LOG_BITMAP_ITERATOR_START_LSN(i) <= max_lsn) | ||
632 | 3860 | { | ||
633 | 3861 | if (!LOG_BITMAP_ITERATOR_PAGE_CHANGED(i)) | ||
634 | 3862 | continue; | ||
635 | 3863 | |||
636 | 3864 | /* SPACE_ID */ | ||
637 | 3865 | table->field[0]->store( | ||
638 | 3866 | LOG_BITMAP_ITERATOR_SPACE_ID(i)); | ||
639 | 3867 | /* PAGE_ID */ | ||
640 | 3868 | table->field[1]->store( | ||
641 | 3869 | LOG_BITMAP_ITERATOR_PAGE_NUM(i)); | ||
642 | 3870 | /* START_LSN */ | ||
643 | 3871 | table->field[2]->store( | ||
644 | 3872 | LOG_BITMAP_ITERATOR_START_LSN(i)); | ||
645 | 3873 | /* END_LSN */ | ||
646 | 3874 | table->field[3]->store( | ||
647 | 3875 | LOG_BITMAP_ITERATOR_END_LSN(i)); | ||
648 | 3876 | |||
649 | 3877 | /* | ||
650 | 3878 | I_S tables are in-memory tables. If bitmap file is big enough | ||
651 | 3879 | a lot of memory can be used to store the table. But the size | ||
652 | 3880 | of used memory can be diminished if we store only data which | ||
653 | 3881 | corresponds to some conditions (in WHERE sql clause). Here | ||
654 | 3882 | conditions are checked for the field values stored above. | ||
655 | 3883 | |||
656 | 3884 | Conditions are checked twice. The first is here (during table | ||
657 | 3885 | generation) and the second during query execution. Maybe it | ||
658 | 3886 | makes sense to use some flag in THD object to avoid double | ||
659 | 3887 | checking. | ||
660 | 3888 | */ | ||
661 | 3889 | if (cond && !cond->val_int()) | ||
662 | 3890 | continue; | ||
663 | 3891 | |||
664 | 3892 | if (schema_table_store_record(thd, table)) | ||
665 | 3893 | { | ||
666 | 3894 | log_online_bitmap_iterator_release(&i); | ||
667 | 3895 | return 1; | ||
668 | 3896 | } | ||
669 | 3897 | |||
670 | 3898 | ++output_rows_num; | ||
671 | 3899 | } | ||
672 | 3900 | |||
673 | 3901 | log_online_bitmap_iterator_release(&i); | ||
674 | 3902 | return 0; | ||
675 | 3903 | } | ||
676 | 3904 | |||
677 | 3905 | static | ||
678 | 3906 | int | ||
679 | 3907 | i_s_innodb_changed_pages_init( | ||
680 | 3908 | /*==========================*/ | ||
681 | 3909 | void* p) | ||
682 | 3910 | { | ||
683 | 3911 | DBUG_ENTER("i_s_innodb_changed_pages_init"); | ||
684 | 3912 | ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; | ||
685 | 3913 | |||
686 | 3914 | schema->fields_info = i_s_innodb_changed_pages_info; | ||
687 | 3915 | schema->fill_table = i_s_innodb_changed_pages_fill; | ||
688 | 3916 | |||
689 | 3917 | DBUG_RETURN(0); | ||
690 | 3918 | } | ||
691 | 3919 | |||
692 | 3920 | UNIV_INTERN struct st_mysql_plugin i_s_innodb_changed_pages = | ||
693 | 3921 | { | ||
694 | 3922 | STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN), | ||
695 | 3923 | STRUCT_FLD(info, &i_s_info), | ||
696 | 3924 | STRUCT_FLD(name, "INNODB_CHANGED_PAGES"), | ||
697 | 3925 | STRUCT_FLD(author, "Percona"), | ||
698 | 3926 | STRUCT_FLD(descr, "InnoDB CHANGED_PAGES table"), | ||
699 | 3927 | STRUCT_FLD(license, PLUGIN_LICENSE_GPL), | ||
700 | 3928 | STRUCT_FLD(init, i_s_innodb_changed_pages_init), | ||
701 | 3929 | STRUCT_FLD(deinit, i_s_common_deinit), | ||
702 | 3930 | STRUCT_FLD(version, 0x0100 /* 1.0 */), | ||
703 | 3931 | STRUCT_FLD(status_vars, NULL), | ||
704 | 3932 | STRUCT_FLD(system_vars, NULL), | ||
705 | 3933 | STRUCT_FLD(__reserved1, NULL) | ||
706 | 3934 | }; | ||
707 | 3642 | 3935 | ||
708 | === modified file 'Percona-Server/storage/innodb_plugin/handler/i_s.h' | |||
709 | --- Percona-Server/storage/innodb_plugin/handler/i_s.h 2012-06-14 05:39:43 +0000 | |||
710 | +++ Percona-Server/storage/innodb_plugin/handler/i_s.h 2012-08-15 14:14:06 +0000 | |||
711 | @@ -43,5 +43,6 @@ | |||
712 | 43 | extern struct st_mysql_plugin i_s_innodb_sys_tables; | 43 | extern struct st_mysql_plugin i_s_innodb_sys_tables; |
713 | 44 | extern struct st_mysql_plugin i_s_innodb_sys_indexes; | 44 | extern struct st_mysql_plugin i_s_innodb_sys_indexes; |
714 | 45 | extern struct st_mysql_plugin i_s_innodb_sys_stats; | 45 | extern struct st_mysql_plugin i_s_innodb_sys_stats; |
715 | 46 | extern struct st_mysql_plugin i_s_innodb_changed_pages; | ||
716 | 46 | 47 | ||
717 | 47 | #endif /* i_s_h */ | 48 | #endif /* i_s_h */ |
718 | 48 | 49 | ||
719 | === modified file 'Percona-Server/storage/innodb_plugin/include/log0online.h' | |||
720 | --- Percona-Server/storage/innodb_plugin/include/log0online.h 2012-06-14 09:16:03 +0000 | |||
721 | +++ Percona-Server/storage/innodb_plugin/include/log0online.h 2012-08-15 14:14:06 +0000 | |||
722 | @@ -25,6 +25,7 @@ | |||
723 | 25 | #define log0online_h | 25 | #define log0online_h |
724 | 26 | 26 | ||
725 | 27 | #include "univ.i" | 27 | #include "univ.i" |
726 | 28 | #include "os0file.h" | ||
727 | 28 | 29 | ||
728 | 29 | /*********************************************************************//** | 30 | /*********************************************************************//** |
729 | 30 | Initializes the online log following subsytem. */ | 31 | Initializes the online log following subsytem. */ |
730 | @@ -48,4 +49,63 @@ | |||
731 | 48 | log_online_follow_redo_log(); | 49 | log_online_follow_redo_log(); |
732 | 49 | /*=========================*/ | 50 | /*=========================*/ |
733 | 50 | 51 | ||
734 | 52 | /** The iterator through all bits of changed pages bitmap blocks */ | ||
735 | 53 | struct log_bitmap_iterator_struct | ||
736 | 54 | { | ||
737 | 55 | char in_name[FN_REFLEN]; /*!< the file name for bitmap | ||
738 | 56 | input */ | ||
739 | 57 | os_file_t in; /*!< the bitmap input file */ | ||
740 | 58 | ib_uint64_t in_offset; /*!< the next write position in the | ||
741 | 59 | bitmap output file */ | ||
742 | 60 | ib_uint32_t bit_offset; /*!< bit offset inside of bitmap | ||
743 | 61 | block*/ | ||
744 | 62 | ib_uint64_t start_lsn; /*!< Start lsn of the block */ | ||
745 | 63 | ib_uint64_t end_lsn; /*!< End lsn of the block */ | ||
746 | 64 | ib_uint32_t space_id; /*!< Block space id */ | ||
747 | 65 | ib_uint32_t first_page_id; /*!< First block page id */ | ||
748 | 66 | ibool changed; /*!< true if current page was changed */ | ||
749 | 67 | byte* page; /*!< Bitmap block */ | ||
750 | 68 | }; | ||
751 | 69 | |||
752 | 70 | typedef struct log_bitmap_iterator_struct log_bitmap_iterator_t; | ||
753 | 71 | |||
754 | 72 | #define LOG_BITMAP_ITERATOR_START_LSN(i) \ | ||
755 | 73 | ((i).start_lsn) | ||
756 | 74 | #define LOG_BITMAP_ITERATOR_END_LSN(i) \ | ||
757 | 75 | ((i).end_lsn) | ||
758 | 76 | #define LOG_BITMAP_ITERATOR_SPACE_ID(i) \ | ||
759 | 77 | ((i).space_id) | ||
760 | 78 | #define LOG_BITMAP_ITERATOR_PAGE_NUM(i) \ | ||
761 | 79 | ((i).first_page_id + (i).bit_offset) | ||
762 | 80 | #define LOG_BITMAP_ITERATOR_PAGE_CHANGED(i) \ | ||
763 | 81 | ((i).changed) | ||
764 | 82 | |||
765 | 83 | /*********************************************************************//** | ||
766 | 84 | Initializes log bitmap iterator. | ||
767 | 85 | @return TRUE if the iterator is initialized OK, FALSE otherwise. */ | ||
768 | 86 | UNIV_INTERN | ||
769 | 87 | ibool | ||
770 | 88 | log_online_bitmap_iterator_init( | ||
771 | 89 | /*============================*/ | ||
772 | 90 | log_bitmap_iterator_t *i); /*!<in/out: iterator */ | ||
773 | 91 | |||
774 | 92 | /*********************************************************************//** | ||
775 | 93 | Releases log bitmap iterator. */ | ||
776 | 94 | UNIV_INTERN | ||
777 | 95 | void | ||
778 | 96 | log_online_bitmap_iterator_release( | ||
779 | 97 | /*===============================*/ | ||
780 | 98 | log_bitmap_iterator_t *i); /*!<in/out: iterator */ | ||
781 | 99 | |||
782 | 100 | /*********************************************************************//** | ||
783 | 101 | Iterates through bits of saved bitmap blocks. | ||
784 | 102 | Sequentially reads blocks from bitmap file(s) and interates through | ||
785 | 103 | their bits. Ignores blocks with wrong checksum. | ||
786 | 104 | @return TRUE if iteration is successful, FALSE if all bits are iterated. */ | ||
787 | 105 | UNIV_INTERN | ||
788 | 106 | ibool | ||
789 | 107 | log_online_bitmap_iterator_next( | ||
790 | 108 | /*============================*/ | ||
791 | 109 | log_bitmap_iterator_t *i); /*!<in/out: iterator */ | ||
792 | 110 | |||
793 | 51 | #endif | 111 | #endif |
794 | 52 | 112 | ||
795 | === modified file 'Percona-Server/storage/innodb_plugin/include/srv0srv.h' | |||
796 | --- Percona-Server/storage/innodb_plugin/include/srv0srv.h 2012-06-14 09:16:03 +0000 | |||
797 | +++ Percona-Server/storage/innodb_plugin/include/srv0srv.h 2012-08-15 14:14:06 +0000 | |||
798 | @@ -136,6 +136,9 @@ | |||
799 | 136 | 136 | ||
800 | 137 | extern my_bool srv_track_changed_pages; | 137 | extern my_bool srv_track_changed_pages; |
801 | 138 | 138 | ||
802 | 139 | extern | ||
803 | 140 | ulonglong srv_changed_pages_limit; | ||
804 | 141 | |||
805 | 139 | extern ibool srv_auto_extend_last_data_file; | 142 | extern ibool srv_auto_extend_last_data_file; |
806 | 140 | extern ulint srv_last_file_size_max; | 143 | extern ulint srv_last_file_size_max; |
807 | 141 | extern char** srv_log_group_home_dirs; | 144 | extern char** srv_log_group_home_dirs; |
808 | 142 | 145 | ||
809 | === modified file 'Percona-Server/storage/innodb_plugin/log/log0online.c' | |||
810 | --- Percona-Server/storage/innodb_plugin/log/log0online.c 2012-06-14 09:16:03 +0000 | |||
811 | +++ Percona-Server/storage/innodb_plugin/log/log0online.c 2012-08-15 14:14:06 +0000 | |||
812 | @@ -29,7 +29,6 @@ | |||
813 | 29 | #include "log0recv.h" | 29 | #include "log0recv.h" |
814 | 30 | #include "mach0data.h" | 30 | #include "mach0data.h" |
815 | 31 | #include "mtr0log.h" | 31 | #include "mtr0log.h" |
816 | 32 | #include "os0file.h" | ||
817 | 33 | #include "srv0srv.h" | 32 | #include "srv0srv.h" |
818 | 34 | #include "srv0start.h" | 33 | #include "srv0start.h" |
819 | 35 | #include "trx0sys.h" | 34 | #include "trx0sys.h" |
820 | @@ -84,6 +83,10 @@ | |||
821 | 84 | which case the first LSN of actual log records will be this. */ | 83 | which case the first LSN of actual log records will be this. */ |
822 | 85 | #define MIN_TRACKED_LSN ((LOG_START_LSN) + (LOG_BLOCK_HDR_SIZE)) | 84 | #define MIN_TRACKED_LSN ((LOG_START_LSN) + (LOG_BLOCK_HDR_SIZE)) |
823 | 86 | 85 | ||
824 | 86 | /* Tests if num bit of bitmap is set */ | ||
825 | 87 | #define IS_BIT_SET(bitmap, num) \ | ||
826 | 88 | (*((bitmap) + ((num) >> 3)) & (1UL << ((num) & 7UL))) | ||
827 | 89 | |||
828 | 87 | /** The bitmap file block size in bytes. All writes will be multiples of this. | 90 | /** The bitmap file block size in bytes. All writes will be multiples of this. |
829 | 88 | */ | 91 | */ |
830 | 89 | enum { | 92 | enum { |
831 | @@ -117,6 +120,7 @@ | |||
832 | 117 | enum { MODIFIED_PAGE_BLOCK_BITMAP_LEN | 120 | enum { MODIFIED_PAGE_BLOCK_BITMAP_LEN |
833 | 118 | = MODIFIED_PAGE_BLOCK_UNUSED_2 - MODIFIED_PAGE_BLOCK_BITMAP }; | 121 | = MODIFIED_PAGE_BLOCK_UNUSED_2 - MODIFIED_PAGE_BLOCK_BITMAP }; |
834 | 119 | 122 | ||
835 | 123 | |||
836 | 120 | /****************************************************************//** | 124 | /****************************************************************//** |
837 | 121 | Provide a comparisson function for the RB-tree tree (space, | 125 | Provide a comparisson function for the RB-tree tree (space, |
838 | 122 | block_start_page) pairs. Actual implementation does not matter as | 126 | block_start_page) pairs. Actual implementation does not matter as |
839 | @@ -922,3 +926,158 @@ | |||
840 | 922 | log_bmp_sys->start_lsn = log_bmp_sys->end_lsn; | 926 | log_bmp_sys->start_lsn = log_bmp_sys->end_lsn; |
841 | 923 | log_set_tracked_lsn(log_bmp_sys->start_lsn); | 927 | log_set_tracked_lsn(log_bmp_sys->start_lsn); |
842 | 924 | } | 928 | } |
843 | 929 | |||
844 | 930 | /*********************************************************************//** | ||
845 | 931 | Initializes log bitmap iterator. | ||
846 | 932 | @return TRUE if the iterator is initialized OK, FALSE otherwise. */ | ||
847 | 933 | UNIV_INTERN | ||
848 | 934 | ibool | ||
849 | 935 | log_online_bitmap_iterator_init( | ||
850 | 936 | /*============================*/ | ||
851 | 937 | log_bitmap_iterator_t *i) /*!<in/out: iterator */ | ||
852 | 938 | { | ||
853 | 939 | ibool success; | ||
854 | 940 | |||
855 | 941 | ut_a(i); | ||
856 | 942 | ut_snprintf(i->in_name, FN_REFLEN, "%s%s%d", srv_data_home, | ||
857 | 943 | modified_page_stem, 1); | ||
858 | 944 | i->in_offset = 0; | ||
859 | 945 | /* | ||
860 | 946 | Set up bit offset out of the reasonable limit | ||
861 | 947 | to intiate reading block from file in | ||
862 | 948 | log_online_bitmap_iterator_next() | ||
863 | 949 | */ | ||
864 | 950 | i->bit_offset = MODIFIED_PAGE_BLOCK_BITMAP_LEN; | ||
865 | 951 | i->in = | ||
866 | 952 | os_file_create_simple_no_error_handling( | ||
867 | 953 | i->in_name, | ||
868 | 954 | OS_FILE_OPEN, | ||
869 | 955 | OS_FILE_READ_ONLY, | ||
870 | 956 | &success); | ||
871 | 957 | |||
872 | 958 | if (!success) { | ||
873 | 959 | /* The following call prints an error message */ | ||
874 | 960 | os_file_get_last_error(TRUE); | ||
875 | 961 | fprintf(stderr, | ||
876 | 962 | "InnoDB: Error: Cannot open \'%s\'\n", | ||
877 | 963 | i->in_name); | ||
878 | 964 | return FALSE; | ||
879 | 965 | } | ||
880 | 966 | |||
881 | 967 | i->page = ut_malloc(MODIFIED_PAGE_BLOCK_SIZE); | ||
882 | 968 | |||
883 | 969 | i->start_lsn = i->end_lsn = 0; | ||
884 | 970 | i->space_id = 0; | ||
885 | 971 | i->first_page_id = 0; | ||
886 | 972 | i->changed = FALSE; | ||
887 | 973 | |||
888 | 974 | return TRUE; | ||
889 | 975 | } | ||
890 | 976 | |||
891 | 977 | /*********************************************************************//** | ||
892 | 978 | Releases log bitmap iterator. */ | ||
893 | 979 | UNIV_INTERN | ||
894 | 980 | void | ||
895 | 981 | log_online_bitmap_iterator_release( | ||
896 | 982 | /*===============================*/ | ||
897 | 983 | log_bitmap_iterator_t *i) /*!<in/out: iterator */ | ||
898 | 984 | { | ||
899 | 985 | ut_a(i); | ||
900 | 986 | os_file_close(i->in); | ||
901 | 987 | ut_free(i->page); | ||
902 | 988 | } | ||
903 | 989 | |||
904 | 990 | /*********************************************************************//** | ||
905 | 991 | Iterates through bits of saved bitmap blocks. | ||
906 | 992 | Sequentially reads blocks from bitmap file(s) and interates through | ||
907 | 993 | their bits. Ignores blocks with wrong checksum. | ||
908 | 994 | @return TRUE if iteration is successful, FALSE if all bits are iterated. */ | ||
909 | 995 | UNIV_INTERN | ||
910 | 996 | ibool | ||
911 | 997 | log_online_bitmap_iterator_next( | ||
912 | 998 | /*============================*/ | ||
913 | 999 | log_bitmap_iterator_t *i) /*!<in/out: iterator */ | ||
914 | 1000 | { | ||
915 | 1001 | ulint offset_low; | ||
916 | 1002 | ulint offset_high; | ||
917 | 1003 | ulint size_low; | ||
918 | 1004 | ulint size_high; | ||
919 | 1005 | ulint checksum = 0; | ||
920 | 1006 | ulint actual_checksum = !checksum; | ||
921 | 1007 | |||
922 | 1008 | ibool success; | ||
923 | 1009 | |||
924 | 1010 | ut_a(i); | ||
925 | 1011 | |||
926 | 1012 | if (i->bit_offset < MODIFIED_PAGE_BLOCK_BITMAP_LEN) | ||
927 | 1013 | { | ||
928 | 1014 | ++i->bit_offset; | ||
929 | 1015 | i->changed = | ||
930 | 1016 | IS_BIT_SET(i->page + MODIFIED_PAGE_BLOCK_BITMAP, | ||
931 | 1017 | i->bit_offset); | ||
932 | 1018 | return TRUE; | ||
933 | 1019 | } | ||
934 | 1020 | |||
935 | 1021 | while (checksum != actual_checksum) | ||
936 | 1022 | { | ||
937 | 1023 | success = os_file_get_size(i->in, | ||
938 | 1024 | &size_low, | ||
939 | 1025 | &size_high); | ||
940 | 1026 | if (!success) { | ||
941 | 1027 | os_file_get_last_error(TRUE); | ||
942 | 1028 | fprintf(stderr, | ||
943 | 1029 | "InnoDB: Warning: can't get size of " | ||
944 | 1030 | "page bitmap file \'%s\'\n", | ||
945 | 1031 | i->in_name); | ||
946 | 1032 | return FALSE; | ||
947 | 1033 | } | ||
948 | 1034 | |||
949 | 1035 | if (i->in_offset >= | ||
950 | 1036 | (ib_uint64_t)(size_low) + | ||
951 | 1037 | ((ib_uint64_t)(size_high) << 32)) | ||
952 | 1038 | return FALSE; | ||
953 | 1039 | |||
954 | 1040 | offset_high = (ulint)(i->in_offset >> 32); | ||
955 | 1041 | offset_low = (ulint)(i->in_offset & 0xFFFFFFFF); | ||
956 | 1042 | |||
957 | 1043 | success = os_file_read( | ||
958 | 1044 | i->in, | ||
959 | 1045 | i->page, | ||
960 | 1046 | offset_low, | ||
961 | 1047 | offset_high, | ||
962 | 1048 | MODIFIED_PAGE_BLOCK_SIZE); | ||
963 | 1049 | |||
964 | 1050 | if (!success) { | ||
965 | 1051 | os_file_get_last_error(TRUE); | ||
966 | 1052 | fprintf(stderr, | ||
967 | 1053 | "InnoDB: Warning: failed reading " | ||
968 | 1054 | "changed page bitmap file \'%s\'\n", | ||
969 | 1055 | i->in_name); | ||
970 | 1056 | return FALSE; | ||
971 | 1057 | } | ||
972 | 1058 | |||
973 | 1059 | checksum = mach_read_from_4( | ||
974 | 1060 | i->page + MODIFIED_PAGE_BLOCK_CHECKSUM); | ||
975 | 1061 | |||
976 | 1062 | actual_checksum = log_online_calc_checksum(i->page); | ||
977 | 1063 | |||
978 | 1064 | i->in_offset += MODIFIED_PAGE_BLOCK_SIZE; | ||
979 | 1065 | } | ||
980 | 1066 | |||
981 | 1067 | i->start_lsn = | ||
982 | 1068 | mach_read_ull(i->page + MODIFIED_PAGE_START_LSN); | ||
983 | 1069 | i->end_lsn = | ||
984 | 1070 | mach_read_ull(i->page + MODIFIED_PAGE_END_LSN); | ||
985 | 1071 | i->space_id = | ||
986 | 1072 | mach_read_from_4(i->page + MODIFIED_PAGE_SPACE_ID); | ||
987 | 1073 | i->first_page_id = | ||
988 | 1074 | mach_read_from_4(i->page + MODIFIED_PAGE_1ST_PAGE_ID); | ||
989 | 1075 | i->bit_offset = | ||
990 | 1076 | 0; | ||
991 | 1077 | i->changed = | ||
992 | 1078 | IS_BIT_SET(i->page + MODIFIED_PAGE_BLOCK_BITMAP, | ||
993 | 1079 | i->bit_offset); | ||
994 | 1080 | |||
995 | 1081 | return TRUE; | ||
996 | 1082 | } | ||
997 | 1083 | |||
998 | 925 | 1084 | ||
999 | === modified file 'Percona-Server/storage/innodb_plugin/srv/srv0srv.c' | |||
1000 | --- Percona-Server/storage/innodb_plugin/srv/srv0srv.c 2012-06-14 09:16:03 +0000 | |||
1001 | +++ Percona-Server/storage/innodb_plugin/srv/srv0srv.c 2012-08-15 14:14:06 +0000 | |||
1002 | @@ -164,6 +164,8 @@ | |||
1003 | 164 | 164 | ||
1004 | 165 | UNIV_INTERN my_bool srv_track_changed_pages = TRUE; | 165 | UNIV_INTERN my_bool srv_track_changed_pages = TRUE; |
1005 | 166 | 166 | ||
1006 | 167 | UNIV_INTERN ulonglong srv_changed_pages_limit = 0; | ||
1007 | 168 | |||
1008 | 167 | /* if TRUE, then we auto-extend the last data file */ | 169 | /* if TRUE, then we auto-extend the last data file */ |
1009 | 168 | UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE; | 170 | UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE; |
1010 | 169 | /* if != 0, this tells the max size auto-extending may increase the | 171 | /* if != 0, this tells the max size auto-extending may increase the |
Diff line 281 query could be written as SELECT MAX(end_lsn) AS
end_lsn FROM I_S....;
The same comments re. server restart from /code.launchpad .net/~vlad- lesin/percona- server/ i_s-innodb- log-tracking- status/ +merge/ 117871
https:/
apply here too.
srv_ changed_ pages_limit is declared in srv0srv.h, there is no
need for separate extern declaration in i_s.cc.
I'd name the max_lsn_struct to lsn_range_struct because that's lsn_from_ and_condition does not seem like lsn_from_ and_condition( ) range_from_ condition( )
what it is - or would get rid of it altogether, passing *min_lsn,
*max_lsn to the get_max_
a big deal. Likewise I'd rename get_max_
to limit_lsn_
The range start and end values are not updated correctly: they
are both compared with their old values and updated if they are
less. So if we have if start_lsn > 100 && start_lsn > 50, 50 will
be chosen instead of 100. The way to do this is to start with
start_lsn of zero and compare if it's greater than the old
value, and end_lsn of +infinity, compared if it's smaller than the old
value.
I am not sure if the condition range limiting is applied BITMAP_ ITERATOR_ START_LSN( i) > max_lsn.start || ...) break; BTIMAP_ ITERATOR_ START_LSN > max_lsn.end
correctly in the main fill loop: if
(LOG_
In case we have requested an interval that has a checkpoint in
the middle, this check will only output the rows up to that
checkpoint and then ...START_LSN(i) > max_lsn.start will become
true. I think currently (before we have multiple bitmap files)
the only limitation we can do here is
LOG_
It is also possible to check if the condition range limitation
resulted in empty range of start_lsn > end_lsn and not to
anything then.
Line 481: "expression".
Line 486: not sure what " if fill max_lsn with the minimum
values." means.
Line 543: s/cause/case