From dbee7b7d7c4c3be84de76c8f48a85dd2c705e53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 28 May 2025 14:34:26 +0300 Subject: [PATCH] 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). --- storage/innobase/buf/buf0buf.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 806e995c901..21e763423ac 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -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_ad(b->state() == buf_page_t::NOT_USED); 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(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);