[MDEV-7758] Small buffer pool size causes XtraDB buffer flush thread to spin at 100% cpu Created: 2015-03-11  Updated: 2023-01-22  Resolved: 2023-01-22

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - XtraDB
Affects Version/s: 10.0.17
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Kristian Nielsen Assignee: Jan Lindström (Inactive)
Resolution: Won't Fix Votes: 0
Labels: verified


 Description   

Small innodb_buffer_pool_size causes mysqld to spin at 100% CPU.

Here is how I could repeat:

Start server with:

sql/mysqld --no-defaults --language=$(pwd)/sql/share/english --basedir=$(pwd) --datadir=$X --socket=$(pwd)/$X/mysql.sock --port=3310 --innodb-buffer-pool-size=5M

Create some dirty pages to trigger flush thread:

create table t1 (a int primary key auto_increment, b varchar (1000));
insert into t1 (b) values (repeat("a", 999));
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;
insert into t1 (b) select b from t1;

This causes the mysqld process to appear at 100% CPU in `top`.

The problem seems to be related to heuristics with hard-coded constants that
assume a certain minimum pool size. In page_cleaner_adapt_lru_sleep_time(),
if the number of free pages is less than @@innodb_lru_scan_depth / 20 (which
works out as 51 by default), it will never sleep between trying to flush
pages. Probably the page flusher has another heuristics that doesn't try to
flush out more than some percentage of total pages or something.

Se with small buffer pool, we end up with two heuristics fighting one another,
and 100% cpu spinning results.



 Comments   
Comment by Kristian Nielsen [ 2015-03-11 ]

Work-around: set --innodb-lru-scan-depth=100

Comment by Elena Stepanova [ 2015-03-12 ]

For me it took a few more INSERTs to get there, so if it's not reproducible with SQL above, just keep inserting.

Comment by Jan Lindström (Inactive) [ 2015-03-12 ]

Is this true for XtraDB only or is InnoDB also affected ?

Comment by Elena Stepanova [ 2015-03-12 ]

I didn't get it with InnoDB. "ERROR 1206 (HY000): The total number of locks exceeds the lock table size" happened sooner than it got into the spin.

Comment by Jan Lindström (Inactive) [ 2015-03-13 ]

Have you tested does Percona 5.6 has this problem ? If it has, I rather wait them to fix it.

Comment by Elena Stepanova [ 2015-03-13 ]

Yes, it also happens on Percona Server 5.6.22-72.0, but I don't know if it has been reported to them.

Comment by Laurynas Biveinis [ 2015-12-02 ]

https://github.com/percona/percona-server/pull/245

Comment by Laurynas Biveinis [ 2015-12-02 ]

But note https://bugs.launchpad.net/percona-server/+bug/1521905

Comment by Elena Stepanova [ 2023-01-22 ]

XtraDB is no longer provided.

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