[MDEV-13057] innodb_read_only=1 should avoid creating buf_flush_page_cleaner_thread Created: 2017-06-12  Updated: 2018-01-23  Resolved: 2018-01-23

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - XtraDB
Affects Version/s: 10.0
Fix Version/s: 10.1.25, 10.0.32

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

Issue Links:
Relates
relates to MDEV-13059 XtraDB hangs on Windows due to failin... Closed
Sprint: 10.0.34

 Description   

When the server is started in innodb_read_only mode, there cannot be any writes to persistent InnoDB/XtraDB files. Just like the creation of buf_flush_page_cleaner_thread is skipped in this case, also the creation of the XtraDB-specific buf_flush_lru_manager_thread should be skipped.



 Comments   
Comment by Laurynas Biveinis [ 2017-06-12 ]

I believe we have worked out the correct conditions for starting/not starting page cleaners / LRU managers in the latest XtraDB source. Specifically, LRU manager has to be started on innodb_read_only too - it evicts in addition to flushing, and so without it, a --innodb-empty-free-list-algorithm=backoff would starve InnoDB of free pages.

Comment by Marko Mäkelä [ 2018-01-22 ]

I noticed that I had forgotten to update this ticket when I committed the change to MariaDB 10.0.32, 10.1.25. In MariaDB 10.2 there is no buf_flush_lru_manager_thread.

laurynas, thank you for the hint. It looks like I should revert this change, or otherwise if innodb_read_only in combination with innodb_empty_free_list_algorithm=backoff may cause the buffer pool to run out. I will construct and run a test case.

Comment by Marko Mäkelä [ 2018-01-23 ]

I tried and failed to reproduce the buffer pool starvation. It turns out that when the buf_flush_lru_manager_thread is not running, buf_LRU_get_free_block() will choose the legacy algorithm:

	if (srv_empty_free_list_algorithm == SRV_EMPTY_FREE_LIST_BACKOFF
	    && buf_lru_manager_is_active
	    && (srv_shutdown_state == SRV_SHUTDOWN_NONE
		|| srv_shutdown_state == SRV_SHUTDOWN_CLEANUP)) {

The condition buf_lru_manager_is_active would not hold, because innobase_start_or_create_for_mysql() will not set the variable unless it is starting the buf_flush_lru_manager_thread.
For the record, I used the following test case:

--source include/have_innodb.inc
--source include/not_embedded.inc
 
SET GLOBAL innodb_file_per_table=on;
create table t(a char(255),b char(255),c char(255), d char(255) not null unique,
primary key(a,b,c))engine=innodb;
 
begin;
--disable_query_log
let $n=30000;
while ($n)
{
eval insert into t values($n,$n,$n,$n);
dec $n;
}
--enable_query_log
commit;
-- let $restart_parameters=--innodb-read-only --innodb-buffer-pool-size=20m --innodb-buffer-pool-instances=1
-- source include/restart_mysqld.inc
 
check table t;

By default, innodb_buffer_pool_instances would be 0, which would be replaced with 8 if the innodb_buffer_pool_size is large enough.
It seems that MariaDB has little or no regression test coverage of the innodb_empty_free_list_algorithm=backoff (which is the XtraDB default in 10.0 and 10.1), because the size of a single buffer pool instance would be smaller than 20MiB by default. 1280 pages (20MiB at innodb_page_size=16k) is the limit that is enforced by innodb_empty_free_list_algorithm_allowed().

Comment by Laurynas Biveinis [ 2018-01-23 ]

That is correct, I had forgotten about the added && buf_lru_manager_is_active condition.

Generated at Thu Feb 08 08:02:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.