MDEV-36863 InnoDB: Failing assertion: !block->n_hash_helps after failing to shrink innodb_buffer_pool_size

buf_pool_t::resize(): After failing to shrink the buffer pool,
clear any adaptive hash index fields for blocks that were restored
from buf_pool.withdrawn to buf_pool.free, so that they will be in
the expected state when the blocks will be allocated later.
This fixes a logic conflict between
commit 4dcb1b575b6cc533f68b98ea1f83cec275534972 (MDEV-35049) and
commit b6923420f326ac030e4f3ef89a2acddb45eccb30 (MDEV-29445).
This commit is contained in:
Marko Mäkelä 2025-05-28 14:34:26 +03:00
parent d953f2c810
commit dbee7b7d7c

View File

@ -2078,6 +2078,19 @@ ATTRIBUTE_COLD void buf_pool_t::resize(size_t size, THD *thd) noexcept
ut_d(b->in_free_list= true); ut_d(b->in_free_list= true);
ut_ad(b->state() == buf_page_t::NOT_USED); ut_ad(b->state() == buf_page_t::NOT_USED);
b->lock.init(); b->lock.init();
#ifdef BTR_CUR_HASH_ADAPT
/* Clear the AHI fields, because buf_block_init_low() expects
these to be zeroed. These were not cleared when we relocated
the block to withdrawn. Had we successfully shrunk the buffer pool,
all this virtual memory would have been zeroed or made unaccessible,
and on a subsequent buffer pool extension it would be zero again. */
buf_block_t *block= reinterpret_cast<buf_block_t*>(b);
block->n_hash_helps= 0;
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
block->n_pointers= 0;
# endif
block->index= nullptr;
#endif
} }
mysql_mutex_unlock(&mutex); mysql_mutex_unlock(&mutex);