MDEV-22901 Accessing btr_search_sys->hash_tables when buffer pool resize happens

- btr_get_search_table() is accessing btr_search_sys->hash_tables,
which is not safe if the buffer pool resize happens concurrently.
parent 32b34cb9
......@@ -1485,20 +1485,12 @@ btr_search_build_page_hash_index(
btr_search_check_free_space_in_heap(index);
hash_table_t* table = btr_get_search_table(index);
rw_lock_x_lock(ahi_latch);
if (!btr_search_enabled) {
goto exit_func;
}
table = btr_get_search_table(index);
if (block->index && ((block->curr_n_fields != n_fields)
|| (block->curr_n_bytes != n_bytes)
|| (block->curr_left_side != left_side))) {
goto exit_func;
}
/* This counter is decremented every time we drop page
hash index entries and is incremented here. Since we can
rebuild hash index for a page that is already hashed, we
......@@ -1507,6 +1499,10 @@ btr_search_build_page_hash_index(
if (!block->index) {
assert_block_ahi_empty(block);
index->search_info->ref_count++;
} else if (block->curr_n_fields != n_fields
|| block->curr_n_bytes != n_bytes
|| block->curr_left_side != left_side) {
goto exit_func;
}
block->n_hash_helps = 0;
......@@ -1516,10 +1512,12 @@ btr_search_build_page_hash_index(
block->curr_left_side = unsigned(left_side);
block->index = index;
{
hash_table_t* table = btr_get_search_table(index);
for (i = 0; i < n_cached; i++) {
ha_insert_for_fold(table, folds[i], block, recs[i]);
}
}
MONITOR_INC(MONITOR_ADAPTIVE_HASH_PAGE_ADDED);
MONITOR_INC_VALUE(MONITOR_ADAPTIVE_HASH_ROW_ADDED, n_cached);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment