Skip to content

Commit

Permalink
MDEV-15384 buf_flush_LRU_list_batch() always reports n->flushed=0, n-…
Browse files Browse the repository at this point in the history
…>evicted=0

- buf_flush_LRU_list_batch() initializes the count to zero and updates them
correctly.
  • Loading branch information
Thirunarayanan committed Mar 13, 2018
1 parent ff909ac commit 76ae6e7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
16 changes: 16 additions & 0 deletions mysql-test/suite/innodb/r/purge_secondary.result
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ LENGTH(l)
11197
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
Expand All @@ -139,6 +143,18 @@ SELECT OTHER_INDEX_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE NAME='test/t1';
OTHER_INDEX_SIZE
1
SELECT NAME, SUBSYSTEM FROM INFORMATION_SCHEMA.INNODB_METRICS
WHERE NAME="buffer_LRU_batch_evict_total_pages" AND COUNT > 0;
NAME SUBSYSTEM
buffer_LRU_batch_evict_total_pages buffer
SELECT NAME, SUBSYSTEM FROM INFORMATION_SCHEMA.INNODB_METRICS
WHERE NAME="buffer_LRU_batch_flush_total_pages" AND COUNT > 0;
NAME SUBSYSTEM
buffer_LRU_batch_flush_total_pages buffer
SELECT (variable_value > 0) FROM information_schema.global_status
WHERE LOWER(variable_name) LIKE 'INNODB_BUFFER_POOL_PAGES_FLUSHED';
(variable_value > 0)
1
# Note: The OTHER_INDEX_SIZE does not cover any SPATIAL INDEX.
# To test that all indexes were emptied, replace DROP TABLE
# with the following, and examine the root pages in t1.ibd:
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/innodb/t/purge_secondary.opt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--innodb-sys-tablestats
--innodb_buffer_pool_size=5M
--innodb_monitor_enable=module_buffer
13 changes: 13 additions & 0 deletions mysql-test/suite/innodb/t/purge_secondary.test
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ INSERT INTO t1 () VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
SELECT LENGTH(l) FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
INSERT INTO t1 (a) SELECT NULL FROM t1;
CHECK TABLE t1;
UPDATE t1 SET c=true, l=ST_linefromtext('linestring(0 0,1 1,2 2)');
DELETE FROM t1;
Expand All @@ -120,6 +124,15 @@ ANALYZE TABLE t1;
SELECT OTHER_INDEX_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
WHERE NAME='test/t1';

SELECT NAME, SUBSYSTEM FROM INFORMATION_SCHEMA.INNODB_METRICS
WHERE NAME="buffer_LRU_batch_evict_total_pages" AND COUNT > 0;

SELECT NAME, SUBSYSTEM FROM INFORMATION_SCHEMA.INNODB_METRICS
WHERE NAME="buffer_LRU_batch_flush_total_pages" AND COUNT > 0;

SELECT (variable_value > 0) FROM information_schema.global_status
WHERE LOWER(variable_name) LIKE 'INNODB_BUFFER_POOL_PAGES_FLUSHED';

--echo # Note: The OTHER_INDEX_SIZE does not cover any SPATIAL INDEX.
--echo # To test that all indexes were emptied, replace DROP TABLE
--echo # with the following, and examine the root pages in t1.ibd:
Expand Down
22 changes: 10 additions & 12 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1631,8 +1631,6 @@ buf_flush_LRU_list_batch(
{
buf_page_t* bpage;
ulint scanned = 0;
ulint evict_count = 0;
ulint count = 0;
ulint free_len = UT_LIST_GET_LEN(buf_pool->free);
ulint lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
ulint withdraw_depth = 0;
Expand All @@ -1648,7 +1646,7 @@ buf_flush_LRU_list_batch(
}

for (bpage = UT_LIST_GET_LAST(buf_pool->LRU);
bpage != NULL && count + evict_count < max
bpage != NULL && n->flushed + n->evicted < max
&& free_len < srv_LRU_scan_depth + withdraw_depth
&& lru_len > BUF_LRU_MIN_LEN;
++scanned,
Expand All @@ -1666,15 +1664,15 @@ buf_flush_LRU_list_batch(
clean and is not IO-fixed or buffer fixed. */
mutex_exit(block_mutex);
if (buf_LRU_free_page(bpage, true)) {
++evict_count;
++n->evicted;
}
} else if (buf_flush_ready_for_flush(bpage, BUF_FLUSH_LRU)) {
/* Block is ready for flush. Dispatch an IO
request. The IO helper thread will put it on
free list in IO completion routine. */
mutex_exit(block_mutex);
buf_flush_page_and_try_neighbors(
bpage, BUF_FLUSH_LRU, max, &count);
bpage, BUF_FLUSH_LRU, max, &n->flushed);
} else {
/* Can't evict or dispatch this block. Go to
previous. */
Expand All @@ -1698,12 +1696,12 @@ buf_flush_LRU_list_batch(

ut_ad(buf_pool_mutex_own(buf_pool));

if (evict_count) {
if (n->evicted) {
MONITOR_INC_VALUE_CUMULATIVE(
MONITOR_LRU_BATCH_EVICT_TOTAL_PAGE,
MONITOR_LRU_BATCH_EVICT_COUNT,
MONITOR_LRU_BATCH_EVICT_PAGES,
evict_count);
n->evicted);
}

if (scanned) {
Expand Down Expand Up @@ -2160,16 +2158,16 @@ buf_flush_lists(
failure. */
success = false;

continue;
}

n_flushed += n.flushed;
}

if (n_flushed) {
buf_flush_stats(n_flushed, 0);
}

if (n_processed) {
*n_processed = n_flushed;
if (n_processed) {
*n_processed = n_flushed;
}
}

return(success);
Expand Down

0 comments on commit 76ae6e7

Please sign in to comment.