summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Łopuszański <jakub.lopuszanski@oracle.com>2021-03-18 15:56:36 +0100
committerMarko Mäkelä <marko.makela@mariadb.com>2021-07-22 18:05:23 +0300
commitc4295b9be90df2dd8f9056fec187f3e991f498c4 (patch)
tree1656360b3e9377a805a14605fdf42bc2e866c210
parentefae374efa88ba7c1b2e970e4ef025272b09f2dd (diff)
downloadmariadb-git-c4295b9be90df2dd8f9056fec187f3e991f498c4.tar.gz
Bug #32460315 ONLINE RESIZING BUFFER POOL CAN CRASH CONCURRENT BP LOOKUP
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> mysql/mysql-server@ea3adc6a1192e1bca4b4894fd7037e29fbcf0bd0
-rw-r--r--storage/innobase/buf/buf0buf.cc21
-rw-r--r--storage/innobase/include/buf0buf.h6
2 files changed, 11 insertions, 16 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index fdd78d19b55..3f399024b13 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2021, Oracle and/or its affiliates.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2021, MariaDB Corporation.
@@ -1896,8 +1896,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 = time(NULL);
@@ -2556,8 +2554,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);
@@ -2589,8 +2585,14 @@ buf_pool_resize_hash(
}
}
- 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);
@@ -3031,11 +3033,6 @@ calc_buf_pool_size:
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);
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 40d2e6b2023..468e6be4def 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1,7 +1,7 @@
/*****************************************************************************
-Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2020, MariaDB Corporation.
+Copyright (c) 1995, 2021, Oracle and/or its affiliates.
+Copyright (c) 2013, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -2037,8 +2037,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,