mirror of
https://github.com/MariaDB/server.git
synced 2025-03-31 04:15:33 +02:00

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
148 lines
4.6 KiB
Text
148 lines
4.6 KiB
Text
--source include/innodb_page_size.inc
|
|
--source include/not_embedded.inc
|
|
--source include/have_symlink.inc
|
|
--source include/not_as_root.inc
|
|
|
|
let datadir= `select @@datadir`;
|
|
let page_size= `select @@innodb_page_size`;
|
|
let tmp_in_vardir=$MYSQLTEST_VARDIR/tmp;
|
|
|
|
--echo #
|
|
--echo # MDEV-15333 MariaDB (still) slow start
|
|
--echo #
|
|
|
|
# Ensure that on normal startup, no data files are read.
|
|
# Note: just like in MySQL, all .ibd files will still be
|
|
# opened at least once.
|
|
|
|
--echo # FIXME: Unlike MySQL, maybe MariaDB should not read the .ibd files
|
|
--echo # of tables with .isl file or DATA DIRECTORY attribute.
|
|
call mtr.add_suppression("\\[ERROR\\] InnoDB: MySQL-8\\.0 tablespace in ");
|
|
call mtr.add_suppression("\\[ERROR\\] InnoDB: Restart in MySQL for migration/recovery\\.");
|
|
|
|
--echo # FIXME: This is much more noisy than MariaDB 10.1!
|
|
call mtr.add_suppression("\\[ERROR\\] InnoDB: Tablespace flags are invalid in datafile: .*test.t[rcd]\\.ibd");
|
|
call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number .* in a file operation\\.");
|
|
call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot find the path specified\\.");
|
|
call mtr.add_suppression("\\[Warning\\] InnoDB: Ignoring tablespace for test/td because it could not be opened\\.");
|
|
|
|
CREATE TABLE tr(a INT)ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
|
|
CREATE TABLE tc(a INT)ENGINE=InnoDB ROW_FORMAT=COMPACT
|
|
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
|
|
--replace_result $tmp_in_vardir MYSQL_TMP_DIR
|
|
eval CREATE TABLE td(a INT)ENGINE=InnoDB ROW_FORMAT=DYNAMIC
|
|
STATS_PERSISTENT=0 DATA DIRECTORY='$tmp_in_vardir';
|
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
--move_file $datadir/test/tr.ibd $datadir/test/tr0.ibd
|
|
--move_file $datadir/test/tc.ibd $datadir/test/tc0.ibd
|
|
--move_file $tmp_in_vardir/test/td.ibd $datadir/test/td0.ibd
|
|
# TODO: test that MariaDB does not even attempt to open the files
|
|
#--mkdir $datadir/test/tr.ibd
|
|
#--mkdir $datadir/test/tc.ibd
|
|
#--mkdir $tmp_in_vardir/test/td.ibd
|
|
|
|
perl;
|
|
die unless open OUT, ">", "$ENV{datadir}/test/tr.ibd";
|
|
print OUT "foo " x $ENV{page_size};
|
|
close OUT or die;
|
|
die unless open OUT, ">", "$ENV{datadir}/test/tc.ibd";
|
|
print OUT "bar " x $ENV{page_size};
|
|
close OUT or die;
|
|
die unless open OUT, ">", "$ENV{tmp_in_vardir}/test/td.ibd";
|
|
print OUT "Xyz " x $ENV{page_size};
|
|
close OUT or die;
|
|
die unless open ISL, "+<", "$ENV{datadir}/test/td.isl";
|
|
$_=<ISL>;
|
|
if (m|^[a-zA-Z]:|)
|
|
{
|
|
tr|/|\\|;
|
|
seek(ISL, 0, SEEK_SET) or die;
|
|
print ISL or die;
|
|
}
|
|
close ISL or die;
|
|
EOF
|
|
|
|
--let $restart_parameters= --skip-innodb-buffer-pool-load-at-startup
|
|
--source include/start_mysqld.inc
|
|
--let $restart_parameters=
|
|
|
|
SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES
|
|
WHERE engine = 'innodb'
|
|
AND support IN ('YES', 'DEFAULT', 'ENABLED');
|
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
# TODO: test that MariaDB does not even attempt to open the files
|
|
#--rmdir $datadir/test/tr.ibd
|
|
#--rmdir $datadir/test/tc.ibd
|
|
#--rmdir $tmp_in_vardir/test/td.ibd
|
|
--remove_file $datadir/test/tr.ibd
|
|
--remove_file $datadir/test/tc.ibd
|
|
--remove_file $tmp_in_vardir/test/td.ibd
|
|
|
|
--move_file $datadir/test/tr0.ibd $datadir/test/tr.ibd
|
|
--move_file $datadir/test/tc0.ibd $datadir/test/tc.ibd
|
|
--move_file $datadir/test/td0.ibd $tmp_in_vardir/test/td.ibd
|
|
|
|
--source include/start_mysqld.inc
|
|
SELECT * FROM tr;
|
|
SELECT * FROM tc;
|
|
SELECT * FROM td;
|
|
DROP TABLE tr,tc,td;
|
|
|
|
--echo #
|
|
--echo # MDEV-27882 Innodb - recognise MySQL-8.0 innodb flags and give a specific error message
|
|
--echo #
|
|
|
|
--let MYSQLD_DATADIR= `SELECT @@datadir`
|
|
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
--move_file $MYSQLD_DATADIR/ibdata1 $MYSQLD_DATADIR/ibdata1.bak
|
|
--copy_file std_data/mysql80/ibdata1_$page_size $MYSQLD_DATADIR/ibdata1
|
|
|
|
perl;
|
|
use IO::Handle;
|
|
my $size = 9 * 1048576;
|
|
if ($ENV{MTR_COMBINATION_32K}) {
|
|
$size *= 2;
|
|
}
|
|
if ($ENV{MTR_COMBINATION_64K}) {
|
|
$size *= 4;
|
|
}
|
|
$size -= $ENV{page_size};
|
|
die unless open(FILE, ">>", "$ENV{MYSQLD_DATADIR}/ibdata1");
|
|
binmode FILE;
|
|
|
|
print FILE chr(0) x $size;
|
|
close(FILE);
|
|
EOF
|
|
|
|
--let ibdata_size='9M'
|
|
if ($MTR_COMBINATION_32K)
|
|
{
|
|
--let ibdata_size='18M'
|
|
}
|
|
if ($MTR_COMBINATION_64K)
|
|
{
|
|
--let ibdata_size='36M'
|
|
}
|
|
|
|
--error 1
|
|
exec $MYSQLD --no-defaults --skip-networking --innodb_data_file_path=ibdata1:$ibdata_size --innodb-page-size=$page_size --datadir=$MYSQLD_DATADIR --log-error=$tmp_in_vardir/attempted_start.err;
|
|
|
|
let SEARCH_FILE= $tmp_in_vardir/attempted_start.err;
|
|
let SEARCH_PATTERN= InnoDB: MySQL-8\.0 tablespace in \./ibdata1;
|
|
source include/search_pattern_in_file.inc;
|
|
|
|
--remove_file $tmp_in_vardir/attempted_start.err
|
|
--remove_file $MYSQLD_DATADIR/ibdata1
|
|
--move_file $MYSQLD_DATADIR/ibdata1.bak $MYSQLD_DATADIR/ibdata1
|
|
|
|
--source include/start_mysqld.inc
|
|
|
|
--echo #
|
|
--echo # End of 10.3 tests
|
|
--echo #
|