1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-29445: Reimplement SET GLOBAL innodb_buffer_pool_size

We deprecate and ignore the parameter innodb_buffer_pool_chunk_size
and let the buffer pool size to be changed in arbitrary 1-megabyte
increments.

innodb_buffer_pool_size_max: A new read-only startup parameter
that specifies the maximum innodb_buffer_pool_size.  If 0 or
unspecified, it will default to the specified innodb_buffer_pool_size
rounded up to the allocation unit (2 MiB or 8 MiB).  The maximum value
is 4GiB-2MiB on 32-bit systems and 16EiB-8MiB on 64-bit systems.
This maximum is very likely to be limited further by the operating system.

The status variable Innodb_buffer_pool_resize_status will reflect
the status of shrinking the buffer pool. When no shrinking is in
progress, the string will be empty.

Unlike before, the execution of SET GLOBAL innodb_buffer_pool_size
will block until the requested buffer pool size change has been
implemented, or the execution is interrupted by a KILL statement
a client disconnect, or server shutdown.  If the
buf_flush_page_cleaner() thread notices that we are running out of
memory, the operation may fail with ER_WRONG_USAGE.

SET GLOBAL innodb_buffer_pool_size will be refused
if the server was started with --large-pages (even if
no HugeTLB pages were successfully allocated). This functionality
is somewhat exercised by the test main.large_pages, which now runs
also on Microsoft Windows.  On Linux, explicit HugeTLB mappings are
apparently excluded from the reported Redident Set Size (RSS), and
apparently unshrinkable between mmap(2) and munmap(2).

The buffer pool will be mapped to a contiguous virtual memory area
that will be aligned and partitioned into extents of 8 MiB on
64-bit systems and 2 MiB on 32-bit systems.

Within an extent, the first few innodb_page_size blocks contain
buf_block_t objects that will cover the page frames in the rest
of the extent.  The number of such frames is precomputed in the
array first_page_in_extent[] for each innodb_page_size.
In this way, there is a trivial mapping between
page frames and block descriptors and we do not need any
lookup tables like buf_pool.zip_hash or buf_pool_t::chunk_t::map.

We will always allocate the same number of block descriptors for
an extent, even if we do not need all the buf_block_t in the last
extent in case the innodb_buffer_pool_size is not an integer multiple
of the of extents size.

The minimum innodb_buffer_pool_size is 256*5/4 pages.  At the default
innodb_page_size=16k this corresponds to 5 MiB.  However, now that the
innodb_buffer_pool_size includes the memory allocated for the block
descriptors, the minimum would be innodb_buffer_pool_size=6m.

my_large_virtual_alloc(): A new function, similar to my_large_malloc().

my_virtual_mem_reserve(), my_virtual_mem_commit(),
my_virtual_mem_decommit(), my_virtual_mem_release():
New interface mostly by Vladislav Vaintroub, to separately
reserve and release virtual address space, as well as to
commit and decommit memory within it.

After my_virtual_mem_decommit(), the virtual memory range will be
read-only or unaccessible, depending on whether the build option
cmake -DHAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT=1
has been specified.  This option is hard-coded on Microsoft Windows,
where VirtualMemory(MEM_DECOMMIT) will make the memory unaccessible.
On IBM AIX, Linux, Illumos and possibly Apple macOS, the virtual memory
will be zeroed out immediately.  On other POSIX-like systems,
madvise(MADV_FREE) will be used if available, to give the operating
system kernel a permission to zero out the virtual memory range.
We prefer immediate freeing so that the reported
resident set size (RSS) of the process will reflect the current
innodb_buffer_pool_size.  Shrinking the buffer pool is a rarely
executed resource intensive operation, and the immediate configuration
of the MMU mappings should not incur significant additional penalty.

opt_super_large_pages: Declare only on Solaris. Actually, this is
specific to the SPARC implementation of Solaris, but because we
lack access to a Solaris development environment, we will not revise
this for other MMU and ISA.

buf_pool_t::chunk_t::create(): Remove.

buf_pool_t::create(): Initialize all n_blocks of the buf_pool.free list.

buf_pool_t::allocate(): Renamed from buf_LRU_get_free_only().

buf_pool_t::LRU_warned: Changed to Atomic_relaxed<bool>,
only to be modified by the buf_flush_page_cleaner() thread.

buf_pool_t::shrink(): Attempt to shrink the buffer pool.
There are 3 possible outcomes: SHRINK_DONE (success),
SHRINK_IN_PROGRESS (the caller may keep trying),
and SHRINK_ABORT (we seem to be running out of buffer pool).
While traversing buf_pool.LRU, release the contended
buf_pool.mutex once in every 32 iterations in order to
reduce starvation. Use lru_scan_itr for efficient traversal,
similar to buf_LRU_free_from_common_LRU_list().

buf_pool_t::shrunk(): Update the reduced size of the buffer pool
in a way that is compatible with buf_pool_t::page_guess(),
and invoke my_virtual_mem_decommit().

buf_pool_t::resize(): Before invoking shrink(), run one batch of
buf_flush_page_cleaner() in order to prevent LRU_warn().
Abort if shrink() recommends it, or no blocks were withdrawn in
the past 15 seconds, or the execution of the statement
SET GLOBAL innodb_buffer_pool_size was interrupted.

buf_pool_t::first_to_withdraw: The first block descriptor that is
out of the bounds of the shrunk buffer pool.

buf_pool_t::withdrawn: The list of withdrawn blocks.
If buf_pool_t::resize() is aborted before shrink() completes,
we must be able to resurrect the withdrawn blocks in the free list.

buf_pool_t::contains_zip(): Added a parameter for the
number of least significant pointer bits to disregard,
so that we can find any pointers to within a block
that is supposed to be free.

buf_pool_t::is_shrinking(): Return the total number or blocks that
were withdrawn or are to be withdrawn.

buf_pool_t::to_withdraw(): Return the number of blocks that will need to
be withdrawn.

buf_pool_t::usable_size(): Number of usable pages, considering possible
in-progress attempt at shrinking the buffer pool.

buf_pool_t::page_guess(): Try to buffer-fix a guessed block pointer.
If HAVE_UNACCESSIBLE_AFTER_MEM_DECOMMIT is set, the pointer will
be validated before being dereferenced.

buf_pool_t::get_info(): Replaces buf_stats_get_pool_info().

innodb_init_param(): Refactored. We must first compute
srv_page_size_shift and then determine the valid bounds of
innodb_buffer_pool_size.

buf_buddy_shrink(): Replaces buf_buddy_realloc().
Part of the work is deferred to buf_buddy_condense_free(),
which is being executed when we are not holding any
buf_pool.page_hash latch.

buf_buddy_condense_free(): Do not relocate blocks.

buf_buddy_free_low(): Do not care about buffer pool shrinking.
This will be handled by buf_buddy_shrink() and
buf_buddy_condense_free().

buf_buddy_alloc_zip(): Assert !buf_pool.contains_zip()
when we are allocating from the binary buddy system.
Previously we were asserting this on multiple recursion levels.

buf_buddy_block_free(), buf_buddy_free_low():
Assert !buf_pool.contains_zip().

buf_buddy_alloc_from(): Remove the redundant parameter j.

buf_flush_LRU_list_batch(): Add the parameter to_withdraw
to keep track of buf_pool.n_blocks_to_withdraw.

buf_do_LRU_batch(): Skip buf_free_from_unzip_LRU_list_batch()
if we are shrinking the buffer pool. In that case, we want
to minimize the page relocations and just finish as quickly
as possible.

trx_purge_attach_undo_recs(): Limit purge_sys.n_pages_handled()
in every iteration, in case the buffer pool is being shrunk
in the middle of a purge batch.

Reviewed by: Debarun Banerjee
This commit is contained in:
Marko Mäkelä
2025-03-26 17:05:44 +02:00
parent 3b4de4c281
commit b6923420f3
86 changed files with 2692 additions and 3175 deletions

View File

@@ -1,8 +0,0 @@
#
# Bug #21348684 SIGABRT DURING RESIZING THE INNODB BUFFER POOL
# ONLINE WITH MEMORY FULL CONDITION
#
call mtr.add_suppression("InnoDB: failed to allocate the chunk array");
SET GLOBAL debug_dbug='+d,buf_pool_resize_chunk_null';
SET GLOBAL innodb_buffer_pool_size=@@innodb_buffer_pool_size + 1048576;
# restart

View File

@@ -1,4 +1,4 @@
call mtr.add_suppression("InnoDB: Cannot allocate memory for the buffer pool");
call mtr.add_suppression("InnoDB: Cannot map innodb_buffer_pool_size_max=");
call mtr.add_suppression("InnoDB: Plugin initialization aborted at srv0start.cc.*");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed.");
@@ -6,4 +6,4 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile
# MDEV-25019 memory allocation failures during startup cause server failure in different, confusing ways
#
# restart: --debug_dbug=+d,ib_buf_chunk_init_fails
FOUND 1 /\[ERROR\] InnoDB: Cannot allocate memory for the buffer pool/ in mysqld.1.err
FOUND 1 /\[ERROR\] InnoDB: Cannot map innodb_buffer_pool_size_max=16m/ in mysqld.1.err

View File

@@ -1,27 +1,28 @@
#
# MDEV-29445: Reorganize buffer pool (and remove chunks)
#
set global innodb_adaptive_hash_index=ON;
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
8388608
set global innodb_buffer_pool_size = 9437184;
set global innodb_buffer_pool_size = 10485760;
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
10485760
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;
set @`v_id` := 0;
set @`v_val` := 0;
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
set global innodb_buffer_pool_size = 64 * 1024 * 1024 + 512 * 1024;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '67633152'
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
68157440
create table t1 (id int primary key, val int not null)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
INSERT INTO t1 SELECT seq*4,seq*4 FROM seq_1_to_262144;
set global innodb_buffer_pool_size = 7340032;
select count(val) from t1;
count(val)
262144
set global innodb_adaptive_hash_index=OFF;
set global innodb_buffer_pool_size = 25165824;
set global innodb_buffer_pool_size = 24117248;
set global innodb_buffer_pool_size = 26214400;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '26214400'
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
25165824
@@ -29,4 +30,12 @@ select count(val) from t1;
count(val)
262144
drop table t1;
drop view view0;
SET GLOBAL innodb_max_purge_lag_wait = 0;
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
SET @save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = 0.0;
SET GLOBAL innodb_max_dirty_pages_pct = 0.0;
SET GLOBAL innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
SET GLOBAL innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
SET GLOBAL innodb_max_dirty_pages_pct = @save_pct;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = @save_pct_lwm;

View File

@@ -1,14 +0,0 @@
SET @save_size=@@innodb_buffer_pool_size;
#
# MDEV-27891: Delayed SIGSEGV in InnoDB buffer pool resize
# after or during DROP TABLE
#
select @@innodb_buffer_pool_chunk_size;
@@innodb_buffer_pool_chunk_size
1048576
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET GLOBAL innodb_buffer_pool_size=256*1024*1024;
DROP TABLE t1;
SET GLOBAL innodb_buffer_pool_size=@@innodb_buffer_pool_size + @@innodb_buffer_pool_chunk_size;
# End of 10.6 tests
SET GLOBAL innodb_buffer_pool_size=@save_size;

View File

@@ -4,7 +4,32 @@ SET GLOBAL innodb_limit_optimistic_insert_debug=2;
SET GLOBAL innodb_buffer_pool_size=16777216;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 SELECT seq FROM seq_1_to_200;
SET GLOBAL innodb_max_purge_lag_wait=0;
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
SET @save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = 0.0;
SET GLOBAL innodb_max_dirty_pages_pct = 0.0;
SHOW STATUS LIKE 'innodb_buffer_pool_resize_status';
Variable_name Value
Innodb_buffer_pool_resize_status
connect con1,localhost,root;
SET DEBUG_SYNC='buf_pool_shrink_before_wakeup SIGNAL blocked WAIT_FOR go';
SET GLOBAL innodb_buffer_pool_size=8388608;
connection default;
SET DEBUG_SYNC='now WAIT_FOR blocked';
SHOW STATUS LIKE 'innodb_buffer_pool_resize_status';
Variable_name Value
Innodb_buffer_pool_resize_status Withdrawing blocks. (505/505).
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
disconnect con1;
connection default;
SHOW STATUS LIKE 'innodb_buffer_pool_resize_status';
Variable_name Value
Innodb_buffer_pool_resize_status
SET DEBUG_SYNC=RESET;
SET GLOBAL innodb_max_dirty_pages_pct = @save_pct;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = @save_pct_lwm;
SELECT COUNT(*),MIN(a),MAX(a) FROM t1;
COUNT(*) MIN(a) MAX(a)
200 1 200

View File

@@ -1,26 +0,0 @@
select @@innodb_buffer_pool_chunk_size;
@@innodb_buffer_pool_chunk_size
4194304
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;
set @`v_id` := 0;
set @`v_val` := 0;
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
set global innodb_buffer_pool_size = 7340032;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
select count(val) from t1;
count(val)
262144
set global innodb_buffer_pool_size = 16777216;
select count(val) from t1;
count(val)
262144
drop table t1;
drop view view0;
set global innodb_buffer_pool_size = 2*1048576;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '2097152'
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
4194304

View File

@@ -5,7 +5,7 @@ call mtr.add_suppression("\\[Warning\\] InnoDB: Over 67 percent of the buffer po
CREATE TABLE t1 (col1 INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
SET STATEMENT debug_dbug='+d,innodb_skip_lock_bitmap' FOR
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e, t1 f, t1 g LIMIT 45000;
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e, t1 f, t1 g;
ERROR HY000: The total number of locks exceeds the lock table size
SELECT COUNT(*) FROM t1;
COUNT(*)

View File

@@ -1,7 +1,7 @@
call mtr.add_suppression("InnoDB: The change buffer is corrupted");
call mtr.add_suppression("InnoDB: Tablespace size stored in header is 768 pages, but the sum of data file sizes is 384 pages");
call mtr.add_suppression("InnoDB: adjusting FSP_SPACE_FLAGS of file");
# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_upgrade --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_upgrade --innodb-force-recovery=5 --innodb-log-file-size=4m --innodb_page_size=32k --innodb_buffer_pool_size=10M
# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/log_upgrade --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/log_upgrade --innodb-force-recovery=5 --innodb-log-file-size=4m --innodb_page_size=32k --innodb_buffer_pool_size=11M
SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');

View File

@@ -12,7 +12,7 @@ END LOOP
connect con1,localhost,root,,,;
CALL dorepeat();
connection default;
# restart: --innodb_buffer_pool_size=5242880
# restart: --innodb_buffer_pool_size=6m
DROP TABLE t1;
DROP PROCEDURE dorepeat;
#

View File

@@ -1,16 +0,0 @@
--- ./suite/innodb/r/restart.result
+++ suite/innodb/r/restart.reject
@@ -32,10 +32,10 @@
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
-ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of '5242879'
SHOW WARNINGS;
Level Code Message
-Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_size=PAGE_SIZE
-Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+Warning 1210 innodb_buffer_pool_size must be at least 5242880 for innodb_page_size=16384
+Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of '5242879'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;

View File

@@ -1,16 +0,0 @@
--- ./suite/innodb/r/restart.result
+++ suite/innodb/r/restart.reject
@@ -32,10 +32,10 @@
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
-ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of '10485759'
SHOW WARNINGS;
Level Code Message
-Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_size=PAGE_SIZE
-Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+Warning 1210 innodb_buffer_pool_size must be at least 10485760 for innodb_page_size=32768
+Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of '10485759'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;

View File

@@ -1,16 +0,0 @@
--- ./suite/innodb/r/restart.result
+++ suite/innodb/r/restart.reject
@@ -32,10 +32,10 @@
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
-ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of '2097151'
SHOW WARNINGS;
Level Code Message
-Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_size=PAGE_SIZE
-Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+Warning 1210 innodb_buffer_pool_size must be at least 2097152 for innodb_page_size=4096
+Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of '2097151'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;

View File

@@ -1,16 +0,0 @@
--- ./suite/innodb/r/restart.result
+++ suite/innodb/r/restart.reject
@@ -32,10 +32,10 @@
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
-ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of '20971519'
SHOW WARNINGS;
Level Code Message
-Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_size=PAGE_SIZE
-Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+Warning 1210 innodb_buffer_pool_size must be at least 20971520 for innodb_page_size=65536
+Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of '20971519'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;

View File

@@ -1,16 +0,0 @@
--- ./suite/innodb/r/restart.result
+++ suite/innodb/r/restart.reject
@@ -32,10 +32,10 @@
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
-ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of '3145727'
SHOW WARNINGS;
Level Code Message
-Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_size=PAGE_SIZE
-Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
+Warning 1210 innodb_buffer_pool_size must be at least 3145728 for innodb_page_size=8192
+Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of '3145727'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;

View File

@@ -30,19 +30,6 @@ SELECT * FROM td;
a
DROP TABLE tr,tc,td;
#
# MDEV-27467 innodb to enfore the minimum innodb_buffer_pool_size in SET (resize) the same as startup
#
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
ERROR 42000: Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
SHOW WARNINGS;
Level Code Message
Warning 1210 innodb_buffer_pool_size must be at least MIN_VAL for innodb_page_size=PAGE_SIZE
Error 1231 Variable 'innodb_buffer_pool_size' can't be set to the value of 'WRONG_VALUE'
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;
#
# MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
#
FOUND 1 /InnoDB: MySQL-8\.0 tablespace in \./ibdata1/ in attempted_start.err

View File

@@ -1 +0,0 @@
--innodb-buffer-pool-size=8m --innodb-buffer-pool-chunk-size=1m

View File

@@ -1,27 +0,0 @@
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/not_embedded.inc
--echo #
--echo # Bug #21348684 SIGABRT DURING RESIZING THE INNODB BUFFER POOL
--echo # ONLINE WITH MEMORY FULL CONDITION
--echo #
call mtr.add_suppression("InnoDB: failed to allocate the chunk array");
SET GLOBAL debug_dbug='+d,buf_pool_resize_chunk_null';
--disable_warnings
SET GLOBAL innodb_buffer_pool_size=@@innodb_buffer_pool_size + 1048576;
--enable_warnings
let $wait_timeout = 60;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 27) = 'Resizing buffer pool failed'
FROM information_schema.global_status
WHERE variable_name = 'INNODB_BUFFER_POOL_RESIZE_STATUS';
--source include/wait_condition.inc
# Restart the server, because the buffer pool would not necessarily be
# shrunk afterwards even if we request it.
--source include/restart_mysqld.inc

View File

@@ -1,5 +1,5 @@
--loose-innodb-sort-buffer-size=64k
--loose-innodb-online-alter-log-max-size=128k
--loose-innodb-buffer-pool-size=5M
--loose-innodb-buffer-pool-size=6M
--loose-innodb-sys-indexes
--loose-innodb-sys-fields

View File

@@ -1 +1 @@
--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=512k --innodb-buffer-pool-size=5M
--innodb-sort-buffer-size=64k --innodb-online-alter-log-max-size=512k --innodb-buffer-pool-size=6M

View File

@@ -0,0 +1 @@
--innodb-buffer-pool-size-max=16m

View File

@@ -1,6 +1,6 @@
--source include/have_innodb.inc
--source include/have_debug.inc
call mtr.add_suppression("InnoDB: Cannot allocate memory for the buffer pool");
call mtr.add_suppression("InnoDB: Cannot map innodb_buffer_pool_size_max=");
call mtr.add_suppression("InnoDB: Plugin initialization aborted at srv0start.cc.*");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed.");
@@ -10,5 +10,5 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile
let restart_parameters=--debug_dbug=+d,ib_buf_chunk_init_fails;
--source include/restart_mysqld.inc
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN=\[ERROR\] InnoDB: Cannot allocate memory for the buffer pool;
let SEARCH_PATTERN=\[ERROR\] InnoDB: Cannot map innodb_buffer_pool_size_max=16m;
--source include/search_pattern_in_file.inc

View File

@@ -1,2 +1,3 @@
--innodb-buffer-pool-size=8M
--innodb-buffer-pool-size-max=24M
--innodb-page-size=4k

View File

@@ -1,17 +1,13 @@
#
# WL6117 : Resize the InnoDB Buffer Pool Online
#
--source include/have_innodb.inc
--source include/big_test.inc
--source include/have_sequence.inc
let $wait_timeout = 180;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool'
FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
--echo #
--echo # MDEV-29445: Reorganize buffer pool (and remove chunks)
--echo #
--disable_query_log
call mtr.add_suppression("InnoDB: Over 67 percent of the buffer pool is occupied by lock heaps");
call mtr.add_suppression("innodb_buffer_pool_size change aborted");
set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
set @old_innodb_adaptive_hash_index = @@innodb_adaptive_hash_index;
--enable_query_log
@@ -21,10 +17,9 @@ set global innodb_adaptive_hash_index=ON;
select @@innodb_buffer_pool_size;
# Expand buffer pool
set global innodb_buffer_pool_size = 9437184;
set global innodb_buffer_pool_size = 10485760;
--source include/wait_condition.inc
select @@innodb_buffer_pool_size;
# fill buffer pool
@@ -32,41 +27,48 @@ select @@innodb_buffer_pool_size;
SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed;
SET GLOBAL innodb_read_only_compressed=OFF;
--enable_query_log
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;
create table t1 (id int primary key, val int not null)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
set @`v_id` := 0;
set @`v_val` := 0;
SET STATEMENT foreign_key_checks=0, unique_checks=0 FOR
INSERT INTO t1 SELECT seq*4,seq*4 FROM seq_1_to_262144;
# 2^18 == 262144 records
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
--disable_query_log
SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
--enable_query_log
# Shrink buffer pool
set global innodb_buffer_pool_size = 64 * 1024 * 1024 + 512 * 1024;
--source include/wait_condition.inc
select @@innodb_buffer_pool_size;
# Attempt to shrink the buffer pool. This may occasionally fail.
--error 0,ER_WRONG_USAGE
set global innodb_buffer_pool_size = 7340032;
select count(val) from t1;
set global innodb_adaptive_hash_index=OFF;
# Expand buffer pool to 24MB
set global innodb_buffer_pool_size = 25165824;
--source include/wait_condition.inc
# Expand buffer pool to 23 and then 24 MiB (requesting 25 MiB)
set global innodb_buffer_pool_size = 24117248;
set global innodb_buffer_pool_size = 26214400;
select @@innodb_buffer_pool_size;
select count(val) from t1;
drop table t1;
drop view view0;
--disable_query_log
set global innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
--enable_query_log
SET GLOBAL innodb_max_purge_lag_wait = 0;
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
SET @save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = 0.0;
SET GLOBAL innodb_max_dirty_pages_pct = 0.0;
let $wait_condition =
SELECT variable_value = 0
FROM information_schema.global_status
WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
--source include/wait_condition.inc
# this may occasionally be aborted on a heavily loaded builder
--error 0,ER_WRONG_USAGE
SET GLOBAL innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
SET GLOBAL innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
SET GLOBAL innodb_max_dirty_pages_pct = @save_pct;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = @save_pct_lwm;

View File

@@ -1,2 +0,0 @@
--innodb-buffer-pool-chunk-size=1M
--loose-skip-innodb-disable-resize_buffer_pool_debug

View File

@@ -1,28 +0,0 @@
--source include/have_innodb.inc
--source include/big_test.inc
SET @save_size=@@innodb_buffer_pool_size;
let $wait_timeout = 60;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool'
FROM information_schema.global_status
WHERE variable_name = 'INNODB_BUFFER_POOL_RESIZE_STATUS';
--echo #
--echo # MDEV-27891: Delayed SIGSEGV in InnoDB buffer pool resize
--echo # after or during DROP TABLE
--echo #
select @@innodb_buffer_pool_chunk_size;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET GLOBAL innodb_buffer_pool_size=256*1024*1024;
DROP TABLE t1;
--source include/wait_condition.inc
SET GLOBAL innodb_buffer_pool_size=@@innodb_buffer_pool_size + @@innodb_buffer_pool_chunk_size;
--source include/wait_condition.inc
--echo # End of 10.6 tests
SET GLOBAL innodb_buffer_pool_size=@save_size;
--source include/wait_condition.inc

View File

@@ -1 +0,0 @@
--innodb-buffer-pool-size=8M --innodb-buffer-pool-chunk-size=2M

View File

@@ -0,0 +1 @@
--innodb-buffer-pool-size-max=16m

View File

@@ -1,24 +1,43 @@
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
SET @save_limit=@@GLOBAL.innodb_limit_optimistic_insert_debug;
SET @save_size=@@GLOBAL.innodb_buffer_pool_size;
SET GLOBAL innodb_limit_optimistic_insert_debug=2;
SET GLOBAL innodb_buffer_pool_size=16777216;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 SELECT seq FROM seq_1_to_200;
SET GLOBAL innodb_buffer_pool_size=8388608;
# Flush the buffer pool to prevent
# "innodb_buffer_pool_size change aborted" error with ./mtr --repeat=3
SET GLOBAL innodb_max_purge_lag_wait=0;
SET @save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
SET @save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = 0.0;
SET GLOBAL innodb_max_dirty_pages_pct = 0.0;
let $wait_timeout = 60;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool'
FROM information_schema.global_status
WHERE variable_name = 'INNODB_BUFFER_POOL_RESIZE_STATUS';
--source include/wait_condition.inc
SHOW STATUS LIKE 'innodb_buffer_pool_resize_status';
connect con1,localhost,root;
SET DEBUG_SYNC='buf_pool_shrink_before_wakeup SIGNAL blocked WAIT_FOR go';
send SET GLOBAL innodb_buffer_pool_size=8388608;
connection default;
SET DEBUG_SYNC='now WAIT_FOR blocked';
# adjust for 32-bit
--replace_result 504/504 505/505
SHOW STATUS LIKE 'innodb_buffer_pool_resize_status';
SET DEBUG_SYNC='now SIGNAL go';
connection con1;
reap;
disconnect con1;
connection default;
SHOW STATUS LIKE 'innodb_buffer_pool_resize_status';
SET DEBUG_SYNC=RESET;
SET GLOBAL innodb_max_dirty_pages_pct = @save_pct;
SET GLOBAL innodb_max_dirty_pages_pct_lwm = @save_pct_lwm;
SELECT COUNT(*),MIN(a),MAX(a) FROM t1;
DROP TEMPORARY TABLE t1;

View File

@@ -1,3 +0,0 @@
--innodb-buffer-pool-size=16M
--innodb-buffer-pool-chunk-size=4M
--innodb-page-size=4k

View File

@@ -1,61 +0,0 @@
#
# WL6117 : Resize the InnoDB Buffer Pool Online
# (innodb_buffer_pool_chunk_size used case)
#
--source include/have_innodb.inc
--source include/big_test.inc
let $wait_timeout = 180;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool'
FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
--disable_query_log
set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
--enable_query_log
select @@innodb_buffer_pool_chunk_size;
# fill buffer pool
--disable_query_log
SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed;
SET GLOBAL innodb_read_only_compressed=OFF;
--enable_query_log
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;
set @`v_id` := 0;
set @`v_val` := 0;
# 2^18 == 262144 records
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
--disable_query_log
SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed;
--enable_query_log
# Shrink buffer pool to 7MB
set global innodb_buffer_pool_size = 7340032;
--source include/wait_condition.inc
select count(val) from t1;
# Expand buffer pool to 16MB
set global innodb_buffer_pool_size = 16777216;
--source include/wait_condition.inc
select count(val) from t1;
drop table t1;
drop view view0;
# Try to shrink buffer pool to smaller than chunk size
set global innodb_buffer_pool_size = 2*1048576;
--source include/wait_condition.inc
select @@innodb_buffer_pool_size;
--disable_query_log
set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
--enable_query_log
--source include/wait_condition.inc

View File

@@ -1 +1 @@
--innodb_buffer_pool_size=5M
--innodb_buffer_pool_size=6M

View File

@@ -15,7 +15,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
--error ER_LOCK_TABLE_FULL
SET STATEMENT debug_dbug='+d,innodb_skip_lock_bitmap' FOR
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e, t1 f, t1 g LIMIT 45000;
INSERT INTO t1 SELECT a.* FROM t1 a, t1 b, t1 c, t1 d, t1 e, t1 f, t1 g;
SELECT COUNT(*) FROM t1;

View File

@@ -73,7 +73,7 @@ print OUT chr(0);
close OUT or die;
EOF
--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --innodb_page_size=32k --innodb_buffer_pool_size=10M
--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m --innodb_page_size=32k --innodb_buffer_pool_size=11M
--source include/start_mysqld.inc
SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'

View File

@@ -0,0 +1,2 @@
--innodb-buffer-pool-size-max=17m
--innodb-buffer-pool-size=17m

View File

@@ -1,5 +1,4 @@
--source include/have_debug.inc
--source include/have_cgroupv2.inc
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_sequence.inc

View File

@@ -1,4 +1,4 @@
--innodb-sys-tablestats
--innodb_buffer_pool_size=5M
--innodb_buffer_pool_size=6M
--innodb_monitor_enable=module_buffer
--skip-innodb-stats-persistent

View File

@@ -22,7 +22,7 @@ send CALL dorepeat();
connection default;
sleep 10;
let $shutdown_timeout=0;
let $restart_parameters=--innodb_buffer_pool_size=5242880;
let $restart_parameters=--innodb_buffer_pool_size=6m;
--source include/restart_mysqld.inc
DROP TABLE t1;
DROP PROCEDURE dorepeat;
@@ -33,11 +33,11 @@ DROP PROCEDURE dorepeat;
--echo #
if ($have_debug) {
SET DEBUG_DBUG="+d,ib_log_checkpoint_avoid_hard";
let $restart_parameters=--innodb_buffer_pool_size=5242880 --debug_dbug=+d,ibuf_init_corrupt;
let $restart_parameters=--innodb_buffer_pool_size=6m --debug_dbug=+d,ibuf_init_corrupt;
}
if (!$have_debug) {
--echo SET DEBUG_DBUG="+d,ib_log_checkpoint_avoid_hard";
let $restart_parameters=--innodb_buffer_pool_size=5242880;
let $restart_parameters=--innodb_buffer_pool_size=6m;
}
CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
INSERT INTO t1 SELECT * FROM seq_1_to_65536;

View File

@@ -1,2 +0,0 @@
--loose-innodb_disable_resize_buffer_pool_debug=0
--innodb-buffer-pool-chunk-size=1M

View File

@@ -92,31 +92,6 @@ SELECT * FROM tc;
SELECT * FROM td;
DROP TABLE tr,tc,td;
--echo #
--echo # MDEV-27467 innodb to enfore the minimum innodb_buffer_pool_size in SET (resize) the same as startup
--echo #
let $wait_timeout = 180;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 30) = 'Completed resizing buffer pool'
FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
--disable_cursor_protocol
SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig;
SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size;
--enable_cursor_protocol
--error ER_WRONG_VALUE_FOR_VAR
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1);
SHOW WARNINGS;
EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size);
--source include/wait_condition.inc
SET GLOBAL innodb_buffer_pool_size = @innodb_buffer_pool_size_orig;
--echo #
--echo # MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
--echo #

View File

@@ -1 +0,0 @@
--innodb-buffer-pool-size=5M