The fix of bug MDEV-21572 introduced a rarely holding condition in a commonly executed function buf_page_get_gen(), which is only needed while crash recovery is in progress.
Before the last recovery batch is completed by invoking recv_sys.apply(true), we have the following accesses to the buffer pool:
- Reading the TRX_SYS page (page 5 in the system tablespace) to determine the number of undo tablespaces.
- Reading the DICT_HDR page (page 7 in the system tablespace) to initialize the maximum tablespace identifier, in dict_boot()
- Before
MDEV-29694 (MariaDB Server 11.0), reading at least 3 pages to initialize the change buffer.
- Loading the definitions of some system tables. This can be deferred after recv_sys.apply(true) has been called.
If we write a separate function that will be used for these 2 special cases of page access, we can simplify the function buf_page_get_gen(). Furthermore, the function buf_flush_LRU_list_batch() may be simplified so that it can enforce the innodb_io_capacity rate limit during recovery, because recv_sys_t::wait_for_pool() (MDEV-29911) would be able to ensure that enough buffer pool is available.