Commit 0f9c8185 authored by Inaam Rana's avatar Inaam Rana

When the caller of buf_flush_list() provides us with the number of

pages that it wants to flush then we should honor that value as in
not going beyond that in our eagerness to flush the neighbors of
the selected victim.
parent c0285935
...@@ -1248,8 +1248,12 @@ buf_flush_try_neighbors( ...@@ -1248,8 +1248,12 @@ buf_flush_try_neighbors(
/*====================*/ /*====================*/
ulint space, /*!< in: space id */ ulint space, /*!< in: space id */
ulint offset, /*!< in: page offset */ ulint offset, /*!< in: page offset */
enum buf_flush flush_type) /*!< in: BUF_FLUSH_LRU or enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU or
BUF_FLUSH_LIST */ BUF_FLUSH_LIST */
ulint n_flushed, /*!< in: number of pages
flushed so far in this batch */
ulint n_to_flush) /*!< in: maximum number of pages
we are allowed to flush */
{ {
ulint i; ulint i;
ulint low; ulint low;
...@@ -1290,6 +1294,21 @@ buf_flush_try_neighbors( ...@@ -1290,6 +1294,21 @@ buf_flush_try_neighbors(
buf_page_t* bpage; buf_page_t* bpage;
if ((count + n_flushed) >= n_to_flush) {
/* We have already flushed enough pages and
should call it a day. There is, however, one
exception. If the page whose neighbors we
are flushing has not been flushed yet then
we'll try to flush the victim that we
selected originally. */
if (i <= offset) {
i = offset;
} else {
break;
}
}
buf_pool = buf_pool_get(space, i); buf_pool = buf_pool_get(space, i);
buf_pool_mutex_enter(buf_pool); buf_pool_mutex_enter(buf_pool);
...@@ -1357,6 +1376,8 @@ buf_flush_page_and_try_neighbors( ...@@ -1357,6 +1376,8 @@ buf_flush_page_and_try_neighbors(
buf_page_in_file(bpage) */ buf_page_in_file(bpage) */
enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */ or BUF_FLUSH_LIST */
ulint n_to_flush, /*!< in: number of pages to
flush */
ulint* count) /*!< in/out: number of pages ulint* count) /*!< in/out: number of pages
flushed */ flushed */
{ {
...@@ -1390,7 +1411,11 @@ buf_flush_page_and_try_neighbors( ...@@ -1390,7 +1411,11 @@ buf_flush_page_and_try_neighbors(
mutex_exit(block_mutex); mutex_exit(block_mutex);
/* Try to flush also all the neighbors */ /* Try to flush also all the neighbors */
*count += buf_flush_try_neighbors(space, offset, flush_type); *count += buf_flush_try_neighbors(space,
offset,
flush_type,
*count,
n_to_flush);
buf_pool_mutex_enter(buf_pool); buf_pool_mutex_enter(buf_pool);
flushed = TRUE; flushed = TRUE;
...@@ -1430,7 +1455,7 @@ buf_flush_LRU_list_batch( ...@@ -1430,7 +1455,7 @@ buf_flush_LRU_list_batch(
a page that isn't ready for flushing. */ a page that isn't ready for flushing. */
while (bpage != NULL while (bpage != NULL
&& !buf_flush_page_and_try_neighbors( && !buf_flush_page_and_try_neighbors(
bpage, BUF_FLUSH_LRU, &count)) { bpage, BUF_FLUSH_LRU, max, &count)) {
bpage = UT_LIST_GET_PREV(LRU, bpage); bpage = UT_LIST_GET_PREV(LRU, bpage);
} }
...@@ -1511,7 +1536,7 @@ buf_flush_flush_list_batch( ...@@ -1511,7 +1536,7 @@ buf_flush_flush_list_batch(
while (bpage != NULL while (bpage != NULL
&& len > 0 && len > 0
&& !buf_flush_page_and_try_neighbors( && !buf_flush_page_and_try_neighbors(
bpage, BUF_FLUSH_LIST, &count)) { bpage, BUF_FLUSH_LIST, min_n, &count)) {
buf_flush_list_mutex_enter(buf_pool); buf_flush_list_mutex_enter(buf_pool);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment