Skip to content

Commit

Permalink
Bug #32460315 ONLINE RESIZING BUFFER POOL CAN CRASH CONCURRENT BP LOOKUP
Browse files Browse the repository at this point in the history
This patch changes it so that we do not free old BP `page_hash`, but rather modify it's parameters, during resize.

RB: 26084
Reviewed-by: Marcin Babij <marcin.babij@oracle.com>
Reviewed-by: Yasufumi Kinoshita <yasufumi.kinoshita@oracle.com>
  • Loading branch information
Jakub Łopuszański committed Mar 18, 2021
1 parent b122b9f commit ea3adc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
18 changes: 6 additions & 12 deletions storage/innobase/buf/buf0buf.cc
Expand Up @@ -1817,8 +1817,6 @@ buf_pool_init_instance(
LATCH_ID_HASH_TABLE_RW_LOCK,
srv_n_page_hash_locks, MEM_HEAP_FOR_PAGE_HASH);

buf_pool->page_hash_old = NULL;

buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size);

buf_pool->last_printout_time = ut_time_monotonic();
Expand Down Expand Up @@ -2442,8 +2440,6 @@ buf_pool_resize_hash(
{
hash_table_t* new_hash_table;

ut_ad(buf_pool->page_hash_old == NULL);

/* recreate page_hash */
new_hash_table = ib_recreate(
buf_pool->page_hash, 2 * buf_pool->curr_size);
Expand Down Expand Up @@ -2474,9 +2470,12 @@ buf_pool_resize_hash(
prev_bpage);
}
}

buf_pool->page_hash_old = buf_pool->page_hash;
buf_pool->page_hash = new_hash_table;
/* Concurrent threads may be accessing buf_pool->page_hash->n_cells,
n_sync_obj and try to latch sync_obj[i] while we are resizing. Therefore we
never deallocate page_hash, instead we overwrite n_cells (and other fields)
with the new values. The n_sync_obj and sync_obj are actually same in both. */
std::swap(*buf_pool->page_hash, *new_hash_table);
hash_table_free(new_hash_table);

/* recreate zip_hash */
new_hash_table = hash_create(2 * buf_pool->curr_size);
Expand Down Expand Up @@ -2929,11 +2928,6 @@ buf_pool_resize()

hash_unlock_x_all(buf_pool->page_hash);
buf_pool_mutex_exit(buf_pool);

if (buf_pool->page_hash_old != NULL) {
hash_table_free(buf_pool->page_hash_old);
buf_pool->page_hash_old = NULL;
}
}

UT_DELETE(chunk_map_old);
Expand Down
2 changes: 0 additions & 2 deletions storage/innobase/include/buf0buf.h
Expand Up @@ -2094,8 +2094,6 @@ struct buf_pool_t{
page_hash mutex. Lookups can happen
while holding the buf_pool->mutex or
the relevant page_hash mutex. */
hash_table_t* page_hash_old; /*!< old pointer to page_hash to be
freed after resizing buffer pool */
hash_table_t* zip_hash; /*!< hash table of buf_block_t blocks
whose frames are allocated to the
zip buddy system,
Expand Down

0 comments on commit ea3adc6

Please sign in to comment.