From 3f4b7ed95a4f5599fe41ab0ebe83e5cc123b5e80 Mon Sep 17 00:00:00 2001 From: Krunal Bauskar Date: Mon, 29 Mar 2021 13:14:02 +0800 Subject: MDEV-25093: Adaptive flushing fails to kick in even if innodb_adaptive_flushing_lwm is hit. (possible regression) adaptive flushing should kick in if a. dirty_pct (dirty pages in buffer pool) > innodb_max_dirty_pages_pct_lwm OR b. innodb_adaptive_flushing_lwm limit is reached (default to 10%) both conditions are mutually exclusive and whichever is first to evaluate true should kick-start the adaptive flushing. After recent changes to simplify the flushing algorithm logic, (b) got ignored that introduced the said regression. --- storage/innobase/buf/buf0flu.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'storage/innobase/buf') diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 339b30659fe..fb3a9687cfc 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1898,6 +1898,20 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn) } } +/** Check if the adpative flushing threshold is recommended based on +redo log capacity filled threshold. +@param oldest_lsn buf_pool.get_oldest_modification() +@return true if adaptive flushing is recommended. */ +static bool af_needed_for_redo(lsn_t oldest_lsn) +{ + lsn_t age= (log_sys.get_lsn() - oldest_lsn); + lsn_t af_lwm= static_cast(srv_adaptive_flushing_lwm * + static_cast(log_sys.log_capacity) / 100); + + /* if age > af_lwm adaptive flushing is recommended */ + return (age > af_lwm); +} + /*********************************************************************//** Calculates if flushing is required based on redo generation rate. @return percent of io_capacity to flush to manage redo space */ @@ -2148,9 +2162,14 @@ unemployed: const double dirty_pct= double(dirty_blocks) * 100.0 / double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free)); + const lsn_t oldest_lsn= buf_pool.get_oldest_modified() + ->oldest_modification(); + ut_ad(oldest_lsn); + bool idle_flush= false; if (lsn_limit); + else if (af_needed_for_redo(oldest_lsn)); else if (srv_max_dirty_pages_pct_lwm != 0.0) { const ulint activity_count= srv_get_activity_count(); @@ -2173,10 +2192,6 @@ unemployed: else if (dirty_pct < srv_max_buf_pool_modified_pct) goto unemployed; - const lsn_t oldest_lsn= buf_pool.get_oldest_modified() - ->oldest_modification(); - ut_ad(oldest_lsn); - if (UNIV_UNLIKELY(lsn_limit != 0) && oldest_lsn >= lsn_limit) buf_flush_sync_lsn= 0; -- cgit v1.2.1