[MDEV-23909] innodb_flush_neighbors=2 is treated like innodb_flush_neighbors=0 Created: 2020-10-07  Updated: 2020-10-30  Resolved: 2020-10-08

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5.4
Fix Version/s: 10.5.7

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Problem/Incident
is caused by MDEV-15053 Reduce buf_pool_t::mutex contention Closed
Relates
relates to MDEV-24054 Assertion `in_LRU_list' failed in buf... Closed

 Description   

In MDEV-15053, the code to handle the configuration parameter innodb_flush_neighbors was changed. We only test whether the parameter is 1, hence, the values 0 and 2 are being treated equally. The function buf_flush_try_neighbors() used to check for all 3 values.

Starting with MDEV-15053, the function buf_flush_check_neighbors() will always limit the page number range to be contiguous when it is being invoked. We should adjust the call and add another parameter to indicate whether the range needs to be contiguous:

diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -966,10 +966,12 @@ static bool buf_flush_check_neighbor(const page_id_t id, ulint fold, bool lru)
 /** Check which neighbors of a page can be flushed from the buf_pool.
 @param space       tablespace
 @param id          page identifier of a dirty page
+@param contiguous  whether to consider contiguous areas of pages
 @param lru         true=buf_pool.LRU; false=buf_pool.flush_list
 @return last page number that can be flushed */
 static page_id_t buf_flush_check_neighbors(const fil_space_t &space,
-                                           page_id_t &id, bool lru)
+                                           page_id_t &id, bool contiguous,
+                                           bool lru)
 {
   ut_ad(id.page_no() < space.size);
   /* When flushed, dirty blocks are searched in neighborhoods of this
@@ -983,6 +985,13 @@ static page_id_t buf_flush_check_neighbors(const fil_space_t &space,
   high.set_page_no(std::min(high.page_no(),
                             static_cast<uint32_t>(space.committed_size - 1)));
 
+  if (!contiguous)
+  {
+    high= std::max(id + 1, high);
+    id= low;
+    return high;
+  }
+
   /* Determine the contiguous dirty area around id. */
   const ulint id_fold= id.fold();
 
@@ -1090,13 +1099,15 @@ static ulint buf_flush_try_neighbors(const page_id_t page_id, bool lru,
         /* Flush the freed ranges while flushing the neighbors */
         buf_flush_freed_pages(space);
 
+	const auto neighbors = srv_flush_neighbors;
+
 	page_id_t id = page_id;
-	page_id_t high = (srv_flush_neighbors != 1
+	page_id_t high = (!neighbors
 			  || UT_LIST_GET_LEN(buf_pool.LRU)
 			  < BUF_LRU_OLD_MIN_LEN
 			  || !space->is_rotational())
 		? id + 1 /* Flush the minimum. */
-		: buf_flush_check_neighbors(*space, id, lru);
+		: buf_flush_check_neighbors(*space, id, neighbors == 1, lru);
 
 	ut_ad(page_id >= id);
 	ut_ad(page_id < high);


Generated at Thu Feb 08 09:25:59 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.