From 449e6af3c640682a6c24c472e27e22617baac44a Mon Sep 17 00:00:00 2001 From: inaam <> Date: Tue, 7 Jul 2009 22:00:49 +0000 Subject: [PATCH] branches/zip rb://138 The current implementation is to try to flush the neighbors of every page that we flush. This patch makes the following distinction: 1) If the flush is from flush_list AND 2) If the flush is intended to move the oldest_modification LSN ahead (this happens when a user thread sees little space in the log file and attempts to flush pages from the buffer pool so that a checkpoint can be made) THEN Do not try to flush the neighbors. Just focus on flushing dirty pages at the end of flush_list Approved by: Heikki --- buf/buf0flu.c | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/buf/buf0flu.c b/buf/buf0flu.c index c8bf05bde51..f8c19d4a299 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -979,6 +979,7 @@ buf_flush_batch( ulint old_page_count; ulint space; ulint offset; + ibool try_neighbors = TRUE; ut_ad((flush_type == BUF_FLUSH_LRU) || (flush_type == BUF_FLUSH_LIST)); @@ -986,6 +987,17 @@ buf_flush_batch( ut_ad((flush_type != BUF_FLUSH_LIST) || sync_thread_levels_empty_gen(TRUE)); #endif /* UNIV_SYNC_DEBUG */ + + /* If we are being asked to do a BUF_FLUSH_LIST flush and + min_n is ULINT_MAX and lsn_limit is provided then we are doing + this flush from within a query thread i.e.: not in background + and therefore we should not try to flush the neighbors and just + focus on getting the flushed LSN to the lsn_limit. */ + if (flush_type == BUF_FLUSH_LIST && min_n == ULINT_MAX + && lsn_limit != IB_ULONGLONG_MAX) { + try_neighbors = FALSE; + } + buf_pool_mutex_enter(); if ((buf_pool->n_flush[flush_type] > 0) @@ -1045,18 +1057,36 @@ flush_next: if (ready) { space = buf_page_get_space(bpage); offset = buf_page_get_page_no(bpage); + old_page_count = page_count; - buf_pool_mutex_exit(); + if (try_neighbors) { - old_page_count = page_count; + buf_pool_mutex_exit(); + + /* Try to flush also all the + neighbors */ + page_count += buf_flush_try_neighbors( + space, offset, flush_type); + /* fprintf(stderr, + "Flush type %lu, page no %lu," + " neighb %lu\n", + flush_type, offset, + page_count - old_page_count); */ + + } else { + + /* Just flush this page. */ + mutex_enter(block_mutex); + + ut_a(buf_page_in_file(bpage)); + ut_ad(bpage->in_page_hash); - /* Try to flush also all the neighbors */ - page_count += buf_flush_try_neighbors( - space, offset, flush_type); - /* fprintf(stderr, - "Flush type %lu, page no %lu, neighb %lu\n", - flush_type, offset, - page_count - old_page_count); */ + /* buf_pool and block mutexes are + released inside the following + function. */ + buf_flush_page(bpage, flush_type); + ++page_count; + } buf_pool_mutex_enter(); goto flush_next;