From c942b3134008bbb3759fe2c704b636fb0cf45e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 10 Jan 2025 16:40:32 +0200 Subject: [PATCH] MDEV-35049: Fix bogus rebuild on BTR_CUR_HASH_FAIL btr_search_info_update_hash(): Do nothing if the record is positioned on the page supremum or infimum pseudo-record. The adaptive hash index can only include user records. This deficiency would cause the adaptive hash index parameters to change between hashing a prefix of 1 field or a prefix of 1 byte. Reviewed by: Vladislav Lesin --- storage/innobase/btr/btr0sea.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index 8fdc581e438..d9639a92a52 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -506,18 +506,27 @@ static uint32_t btr_search_info_update_hash(const btr_cur_t &cursor) noexcept cursor.flag == BTR_CUR_BINARY); dict_index_t *const index= cursor.index(); - const uint16_t n_uniq{dict_index_get_n_unique_in_tree(index)}; - dict_index_t::ahi &info= index->search_info; - - uint32_t left_bytes_fields{info.left_bytes_fields}; - uint8_t n_hash_potential= info.n_hash_potential; buf_block_t *const block= cursor.page_cur.block; ut_ad(block->page.lock.have_any()); ut_d(const uint32_t state= block->page.state()); ut_ad(state >= buf_page_t::UNFIXED); ut_ad(!block->page.is_read_fixed(state)); + + switch (uintptr_t(btr_cur_get_rec(&cursor) - block->page.frame)) { + case PAGE_OLD_INFIMUM: + case PAGE_OLD_SUPREMUM: + case PAGE_NEW_INFIMUM: + case PAGE_NEW_SUPREMUM: + /* The adaptive hash index only includes user records. */ + return 0; + } + const dict_index_t *const block_index= block->index; uint16_t n_hash_helps{block->n_hash_helps}; + const uint16_t n_uniq{dict_index_get_n_unique_in_tree(index)}; + dict_index_t::ahi &info= index->search_info; + uint32_t left_bytes_fields{info.left_bytes_fields}; + uint8_t n_hash_potential= info.n_hash_potential; uint32_t ret; if (!n_hash_potential)