Commit c7e307e9 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 c402eccf
......@@ -1248,8 +1248,12 @@ buf_flush_try_neighbors(
/*====================*/
ulint space, /*!< in: space id */
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 */
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 low;
......@@ -1290,6 +1294,21 @@ buf_flush_try_neighbors(
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_mutex_enter(buf_pool);
......@@ -1357,6 +1376,8 @@ buf_flush_page_and_try_neighbors(
buf_page_in_file(bpage) */
enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
ulint n_to_flush, /*!< in: number of pages to
flush */
ulint* count) /*!< in/out: number of pages
flushed */
{
......@@ -1390,7 +1411,11 @@ buf_flush_page_and_try_neighbors(
mutex_exit(block_mutex);
/* 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);
flushed = TRUE;
......@@ -1430,7 +1455,7 @@ buf_flush_LRU_list_batch(
a page that isn't ready for flushing. */
while (bpage != NULL
&& !buf_flush_page_and_try_neighbors(
bpage, BUF_FLUSH_LRU, &count)) {
bpage, BUF_FLUSH_LRU, max, &count)) {
bpage = UT_LIST_GET_PREV(LRU, bpage);
}
......@@ -1511,7 +1536,7 @@ buf_flush_flush_list_batch(
while (bpage != NULL
&& len > 0
&& !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);
......
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