[MDEV-26662] buf_read_page_background() is blocking on LRU eviction Created: 2021-09-22  Updated: 2024-01-05  Resolved: 2024-01-05

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5, 10.6, 10.7
Fix Version/s: 11.1.0, 11.0.1

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

Issue Links:
PartOf
is part of MDEV-30216 Read-ahead unnecessarily allocates an... Closed
Relates
relates to MDEV-28828 SIGSEGV in buf_flush_LRU_list_batch Closed
relates to MDEV-26445 innodb_undo_log_truncate is unnecessa... Closed

 Description   

I noticed this while debugging a fix of MDEV-26445 by running the test innodb.undo_truncate:

10.5 699de65d5e1cda0b8c6a994f8513e97804b1a7ad with some changes

#9  0x000055af0cd10286 in buf_flush_LRU_list_batch (n=<synthetic pointer>, max=32) at /mariadb/10.5m/storage/innobase/buf/buf0flu.cc:1332
#10 buf_do_LRU_batch (max=32) at /mariadb/10.5m/storage/innobase/buf/buf0flu.cc:1380
#11 buf_flush_LRU (max_n=32) at /mariadb/10.5m/storage/innobase/buf/buf0flu.cc:1704
#12 0x000055af0cd1357d in buf_LRU_get_free_block (have_mutex=have_mutex@entry=false) at /mariadb/10.5m/storage/innobase/buf/buf0lru.cc:499
#13 0x000055af0cd13d4f in buf_page_init_for_read (unzip=false, zip_size=0, page_id={m_id = 326417514774}, mode=132) at /mariadb/10.5m/storage/innobase/buf/buf0rea.cc:110
#14 buf_read_page_low (err=0x7f825810545c, space=0x7f81b01354f0, sync=false, mode=132, page_id={m_id = 326417514774}, zip_size=0, unzip=false) at /mariadb/10.5m/storage/innobase/buf/buf0rea.cc:309
#15 0x000055af0cd14c16 in buf_read_page_background (space=space@entry=0x7f81b01354f0, page_id={m_id = 326417514774}, zip_size=<optimized out>) at /mariadb/10.5m/storage/innobase/buf/buf0rea.cc:506
#16 0x000055af0ccf02c0 in btr_cur_prefetch_siblings (block=0x7f8258d7eac0, index=<optimized out>) at /mariadb/10.5m/storage/innobase/include/buf0types.h:127

While this is executing, another thread is waiting as well:

#3  0x000055af0cd1343e in buf_LRU_get_free_block (have_mutex=have_mutex@entry=false) at /mariadb/10.5m/storage/innobase/buf/buf0lru.cc:458
#4  0x000055af0cd13d4f in buf_page_init_for_read (unzip=false, zip_size=0, page_id={m_id = 322122547570}, mode=132) at /mariadb/10.5m/storage/innobase/buf/buf0rea.cc:110
#5  buf_read_page_low (err=0x7f825815045c, space=0x7f81b005d490, sync=false, mode=132, page_id={m_id = 322122547570}, zip_size=0, unzip=false) at /mariadb/10.5m/storage/innobase/buf/buf0rea.cc:309
#6  0x000055af0cd14c16 in buf_read_page_background (space=space@entry=0x7f81b005d490, page_id={m_id = 322122547570}, zip_size=<optimized out>) at /mariadb/10.5m/storage/innobase/buf/buf0rea.cc:506
#7  0x000055af0ccf02c0 in btr_cur_prefetch_siblings (block=0x7f8258d703c0, index=<optimized out>) at /mariadb/10.5m/storage/innobase/include/buf0types.h:127

This prefetch could be detrimental to performance when we have a small buffer pool.

Possible fix: Allow buf_page_init_for_read() to instantly fail if a buffer pool block is not immediately available when initiating a background read.

The performance of any fix would of course have to be evaluaed carefully on different types of storage (ranging from HDD to NVMe).



 Comments   
Comment by Marko Mäkelä [ 2024-01-05 ]

The function buf_read_acquire(), which will fail if no buffer pool is available, was implemented as part of fixing MDEV-30216.

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