MDEV-36868: Inconsistency when shrinking innodb_buffer_pool_size

buf_pool_t::resize(): After successfully shrinking the buffer pool,
announce the success. The size had already been updated in shrunk().
After failing to shrink the buffer pool, re-enable the adaptive
hash index if it had been enabled.

Reviewed by: Debarun Banerjee
This commit is contained in:
Marko Mäkelä 2025-05-28 13:33:06 +03:00
commit 7b4b759f13
5 changed files with 48 additions and 15 deletions

View file

@ -1606,6 +1606,7 @@ ATTRIBUTE_COLD buf_pool_t::shrink_status buf_pool_t::shrink(size_t size)
noexcept
{
mysql_mutex_assert_owner(&mutex);
DBUG_EXECUTE_IF("buf_shrink_fail", return SHRINK_ABORT;);
buf_load_abort();
if (!n_blocks_to_withdraw)
@ -2011,25 +2012,12 @@ ATTRIBUTE_COLD void buf_pool_t::resize(size_t size, THD *thd) noexcept
if (ahi_disabled)
btr_search_enable(true);
#endif
mysql_mutex_lock(&LOCK_global_system_variables);
bool resized= n_blocks_removed < 0;
if (n_blocks_removed > 0)
{
mysql_mutex_lock(&mutex);
resized= size_in_bytes == old_size;
if (resized)
{
size_in_bytes_requested= size;
size_in_bytes= size;
}
mysql_mutex_unlock(&mutex);
}
if (resized)
if (n_blocks_removed)
sql_print_information("InnoDB: innodb_buffer_pool_size=%zum (%zu pages)"
" resized from %zum (%zu pages)",
size >> 20, n_blocks_new, old_size >> 20,
old_blocks);
mysql_mutex_lock(&LOCK_global_system_variables);
}
else
{
@ -2092,6 +2080,10 @@ ATTRIBUTE_COLD void buf_pool_t::resize(size_t size, THD *thd) noexcept
mysql_mutex_unlock(&mutex);
my_printf_error(ER_WRONG_USAGE, "innodb_buffer_pool_size change aborted",
MYF(ME_ERROR_LOG));
#ifdef BTR_CUR_HASH_ADAPT
if (ahi_disabled)
btr_search_enable(true);
#endif
mysql_mutex_lock(&LOCK_global_system_variables);
}