| 1 |
# |
| 2 |
# Confirm that evicting a page from the buffer pool accounts it correctly |
| 3 |
# in the stats for how much pages per index are cached. |
| 4 |
# |
| 5 |
|
| 6 |
|
| 7 |
let $get_n_cached_pages= |
| 8 |
SELECT cached.n_cached_pages AS n_cached_pages |
| 9 |
FROM |
| 10 |
information_schema.innodb_cached_indexes AS cached, |
| 11 |
information_schema.innodb_indexes AS indexes, |
| 12 |
information_schema.innodb_tables AS tables |
| 13 |
WHERE |
| 14 |
cached.index_id = indexes.index_id |
| 15 |
AND cached.space_id = indexes.space |
| 16 |
AND indexes.table_id = tables.table_id |
| 17 |
AND tables.name LIKE '%pct_cached_evict'; |
| 18 |
|
| 19 |
CREATE TABLE pct_cached_evict (a TEXT) ENGINE=INNODB; |
| 20 |
|
| 21 |
-- disable_query_log |
| 22 |
-- echo # Populating pct_cached_evict with a few pages |
| 23 |
BEGIN; |
| 24 |
-- let $i = 64 |
| 25 |
while ($i) |
| 26 |
{ |
| 27 |
INSERT INTO pct_cached_evict VALUES (REPEAT('a', 1024)); |
| 28 |
dec $i; |
| 29 |
} |
| 30 |
COMMIT; |
| 31 |
-- enable_query_log |
| 32 |
|
| 33 |
-- let $before_evict = `$get_n_cached_pages` |
| 34 |
|
| 35 |
-- source suite/innodb/include/evict_everything_from_buffer_pool.inc |
| 36 |
|
| 37 |
-- let $after_evict = `$get_n_cached_pages` |
| 38 |
|
| 39 |
if ($before_evict > $after_evict) |
| 40 |
{ |
| 41 |
# Decreased. |
| 42 |
-- echo OK |
| 43 |
} |
| 44 |
if ($before_evict <= $after_evict) |
| 45 |
{ |
| 46 |
# Sometimes evict_everything_from_buffer_pool.inc does not evict |
| 47 |
# the pages of pct_cached_evict from the buffer pool. In this |
| 48 |
# sporadic case we just pretend everything is OK. |
| 49 |
|
| 50 |
-- let $actual = `SELECT COUNT(*) FROM information_schema.innodb_buffer_page WHERE table_name LIKE '%pct_cached_evict%'` |
| 51 |
if ($actual == $after_evict) |
| 52 |
{ |
| 53 |
-- echo OK |
| 54 |
} |
| 55 |
if ($actual != $after_evict) |
| 56 |
{ |
| 57 |
-- echo The reported number of cached pages of pct_cached_evict did not decrease, dumping some data to help analysis. |
| 58 |
-- echo Pages of pct_cached_evict before evict: $before_evict |
| 59 |
-- echo Pages of pct_cached_evict after evict: $after_evict |
| 60 |
-- echo Actual number of pages of pct_cached_evict after evict from innodb_buffer_page: $actual |
| 61 |
|
| 62 |
SELECT |
| 63 |
tables.name AS table_name, |
| 64 |
indexes.name AS index_name, |
| 65 |
cached.n_cached_pages AS n_cached_pages |
| 66 |
FROM |
| 67 |
information_schema.innodb_cached_indexes AS cached, |
| 68 |
information_schema.innodb_indexes AS indexes, |
| 69 |
information_schema.innodb_tables AS tables |
| 70 |
WHERE |
| 71 |
cached.index_id = indexes.index_id |
| 72 |
AND cached.space_id = indexes.space |
| 73 |
AND indexes.table_id = tables.table_id; |
| 74 |
|
| 75 |
SELECT * FROM information_schema.innodb_buffer_page; |
| 76 |
SELECT * FROM information_schema.innodb_buffer_pool_stats; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
DROP TABLE pct_cached_evict; |