summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-11-12 10:37:21 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-11-12 10:37:21 +0200
commit150f447af1d9ffff168372505e5c9b4297bdd9d4 (patch)
tree48ed122f85b110fdc7a0e403d77de8b42f490562 /storage/innobase
parent340feb01e407343d4e6258d8965d14c219822b27 (diff)
parentdd33a70dad2b32aa6fcdbd1f8161d5351f6dbebd (diff)
downloadmariadb-git-150f447af1d9ffff168372505e5c9b4297bdd9d4.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/buf/buf0buf.cc6
-rw-r--r--storage/innobase/dict/dict0dict.cc138
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc125
-rw-r--r--storage/innobase/include/dict0dict.h24
-rw-r--r--storage/innobase/include/ibuf0ibuf.h8
-rw-r--r--storage/innobase/include/trx0trx.h14
-rw-r--r--storage/innobase/log/log0recv.cc3
-rw-r--r--storage/innobase/trx/trx0rec.cc17
-rw-r--r--storage/innobase/trx/trx0trx.cc4
10 files changed, 62 insertions, 279 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 6867d15ee57..748ca4ed404 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4669,7 +4669,7 @@ evict_from_pool:
if (!access_time && !recv_no_ibuf_operations) {
ibuf_merge_or_delete_for_page(
- block, page_id, &page_size, TRUE);
+ block, page_id, page_size);
}
buf_pool_mutex_enter(buf_pool);
@@ -5740,7 +5740,7 @@ loop:
/* Delete possible entries for the page from the insert buffer:
such can exist if the page belonged to an index which was dropped */
if (!recv_recovery_is_on()) {
- ibuf_merge_or_delete_for_page(NULL, page_id, &page_size, TRUE);
+ ibuf_merge_or_delete_for_page(NULL, page_id, page_size);
}
frame = block->frame;
@@ -6196,7 +6196,7 @@ database_corrupted:
ibuf_merge_or_delete_for_page(
(buf_block_t*) bpage, bpage->id,
- &bpage->size, TRUE);
+ bpage->size);
}
space->release_for_io();
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 848b377586c..d6320e44dd8 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -6611,144 +6611,6 @@ dict_sys_get_size()
return size;
}
-/** Look for any dictionary objects that are found in the given tablespace.
-@param[in] space_id Tablespace ID to search for.
-@return true if tablespace is empty. */
-bool
-dict_space_is_empty(
- ulint space_id)
-{
- btr_pcur_t pcur;
- const rec_t* rec;
- mtr_t mtr;
- bool found = false;
-
- rw_lock_x_lock(&dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
- mtr_start(&mtr);
-
- for (rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
- rec != NULL;
- rec = dict_getnext_system(&pcur, &mtr)) {
- const byte* field;
- ulint len;
- ulint space_id_for_table;
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_TABLES__SPACE, &len);
- ut_ad(len == 4);
- space_id_for_table = mach_read_from_4(field);
-
- if (space_id_for_table == space_id) {
- found = true;
- }
- }
-
- mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
- rw_lock_x_unlock(&dict_operation_lock);
-
- return(!found);
-}
-
-/** Find the space_id for the given name in sys_tablespaces.
-@param[in] name Tablespace name to search for.
-@return the tablespace ID. */
-ulint
-dict_space_get_id(
- const char* name)
-{
- btr_pcur_t pcur;
- const rec_t* rec;
- mtr_t mtr;
- ulint name_len = strlen(name);
- ulint id = ULINT_UNDEFINED;
-
- rw_lock_x_lock(&dict_operation_lock);
- mutex_enter(&dict_sys->mutex);
- mtr_start(&mtr);
-
- for (rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES);
- rec != NULL;
- rec = dict_getnext_system(&pcur, &mtr)) {
- const byte* field;
- ulint len;
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_TABLESPACES__NAME, &len);
- ut_ad(len > 0);
- ut_ad(len < OS_FILE_MAX_PATH);
-
- if (len == name_len && ut_memcmp(name, field, len) == 0) {
-
- field = rec_get_nth_field_old(
- rec, DICT_FLD__SYS_TABLESPACES__SPACE, &len);
- ut_ad(len == 4);
- id = mach_read_from_4(field);
-
- /* This is normally called by dict_getnext_system()
- at the end of the index. */
- btr_pcur_close(&pcur);
- break;
- }
- }
-
- mtr_commit(&mtr);
- mutex_exit(&dict_sys->mutex);
- rw_lock_x_unlock(&dict_operation_lock);
-
- return(id);
-}
-
-/** Determine the extent size (in pages) for the given table
-@param[in] table the table whose extent size is being
- calculated.
-@return extent size in pages (256, 128 or 64) */
-ulint
-dict_table_extent_size(
- const dict_table_t* table)
-{
- const ulint mb_1 = 1024 * 1024;
- const ulint mb_2 = 2 * mb_1;
- const ulint mb_4 = 4 * mb_1;
-
- page_size_t page_size = dict_table_page_size(table);
- ulint pages_in_extent = FSP_EXTENT_SIZE;
-
- if (page_size.is_compressed()) {
-
- ulint disk_page_size = page_size.physical();
-
- switch (disk_page_size) {
- case 1024:
- pages_in_extent = mb_1/1024;
- break;
- case 2048:
- pages_in_extent = mb_1/2048;
- break;
- case 4096:
- pages_in_extent = mb_1/4096;
- break;
- case 8192:
- pages_in_extent = mb_1/8192;
- break;
- case 16384:
- pages_in_extent = mb_1/16384;
- break;
- case 32768:
- pages_in_extent = mb_2/32768;
- break;
- case 65536:
- pages_in_extent = mb_4/65536;
- break;
- default:
- ut_ad(0);
- }
- }
-
- return(pages_in_extent);
-}
-
size_t
dict_table_t::get_overflow_field_local_len() const
{
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 9db02a5b9a7..d1f155eecff 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -638,6 +638,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(ibuf_bitmap_mutex),
PSI_KEY(ibuf_mutex),
PSI_KEY(ibuf_pessimistic_insert_mutex),
+ PSI_KEY(index_online_log),
PSI_KEY(log_sys_mutex),
PSI_KEY(log_sys_write_mutex),
PSI_KEY(mutex_list_mutex),
@@ -694,7 +695,6 @@ static PSI_rwlock_info all_innodb_rwlocks[] = {
PSI_RWLOCK_KEY(trx_i_s_cache_lock),
PSI_RWLOCK_KEY(trx_purge_latch),
PSI_RWLOCK_KEY(index_tree_rw_lock),
- PSI_RWLOCK_KEY(index_online_log),
PSI_RWLOCK_KEY(hash_table_locks)
};
# endif /* UNIV_PFS_RWLOCK */
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index c6c934c76c4..bb9f0f086f5 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -4370,16 +4370,12 @@ exist entries for such a page if the page belonged to an index which
subsequently was dropped.
@param[in,out] block if page has been read from disk,
pointer to the page x-latched, else NULL
-@param[in] page_id page id of the index page
-@param[in] update_ibuf_bitmap normally this is set to TRUE, but
-if we have deleted or are deleting the tablespace, then we naturally do not
-want to update a non-existent bitmap page */
+@param[in] page_id page id of the index page */
void
ibuf_merge_or_delete_for_page(
buf_block_t* block,
const page_id_t page_id,
- const page_size_t* page_size,
- ibool update_ibuf_bitmap)
+ const page_size_t& page_size)
{
btr_pcur_t pcur;
#ifdef UNIV_IBUF_DEBUG
@@ -4403,80 +4399,49 @@ ibuf_merge_or_delete_for_page(
return;
}
- /* We cannot refer to page_size in the following, because it is passed
- as NULL (it is unknown) when buf_read_ibuf_merge_pages() is merging
- (discarding) changes for a dropped tablespace. When block != NULL or
- update_ibuf_bitmap is specified, then page_size must be known.
- That is why we will repeat the check below, with page_size in
- place of univ_page_size. Passing univ_page_size assumes that the
- uncompressed page size always is a power-of-2 multiple of the
- compressed page size. */
-
- if (ibuf_fixed_addr_page(page_id, univ_page_size)
- || fsp_descr_page(page_id, univ_page_size)) {
+ if (ibuf_fixed_addr_page(page_id, page_size)
+ || fsp_descr_page(page_id, page_size)) {
return;
}
- fil_space_t* space;
-
- if (update_ibuf_bitmap) {
-
- ut_ad(page_size != NULL);
-
- if (ibuf_fixed_addr_page(page_id, *page_size)
- || fsp_descr_page(page_id, *page_size)) {
- return;
- }
+ fil_space_t* space = fil_space_acquire_silent(page_id.space());
- space = fil_space_acquire_silent(page_id.space());
-
- if (UNIV_UNLIKELY(!space)) {
- /* Do not try to read the bitmap page from the
- non-existent tablespace, delete the ibuf records */
- block = NULL;
- update_ibuf_bitmap = FALSE;
- } else {
- page_t* bitmap_page = NULL;
- ulint bitmap_bits = 0;
+ if (UNIV_UNLIKELY(!space)) {
+ block = NULL;
+ } else {
+ page_t* bitmap_page = NULL;
+ ulint bitmap_bits = 0;
- ibuf_mtr_start(&mtr);
+ ibuf_mtr_start(&mtr);
- bitmap_page = ibuf_bitmap_get_map_page(
- page_id, *page_size, &mtr);
+ bitmap_page = ibuf_bitmap_get_map_page(
+ page_id, page_size, &mtr);
- if (bitmap_page &&
- fil_page_get_type(bitmap_page) != FIL_PAGE_TYPE_ALLOCATED) {
- bitmap_bits = ibuf_bitmap_page_get_bits(
- bitmap_page, page_id, *page_size,
- IBUF_BITMAP_BUFFERED, &mtr);
- }
+ if (bitmap_page &&
+ fil_page_get_type(bitmap_page) != FIL_PAGE_TYPE_ALLOCATED) {
+ bitmap_bits = ibuf_bitmap_page_get_bits(
+ bitmap_page, page_id, page_size,
+ IBUF_BITMAP_BUFFERED, &mtr);
+ }
- ibuf_mtr_commit(&mtr);
+ ibuf_mtr_commit(&mtr);
- if (!bitmap_bits) {
- /* No changes are buffered for this page. */
- space->release();
- if (UNIV_UNLIKELY(srv_shutdown_state)
- && !srv_fast_shutdown
- && (!block
- || btr_page_get_index_id(block->frame)
- != DICT_IBUF_ID_MIN + IBUF_SPACE_ID)) {
- /* Prevent an infinite loop on slow
- shutdown, in case the bitmap bits are
- wrongly clear even though buffered
- changes exist. */
- ibuf_delete_recs(page_id);
- }
- return;
+ if (!bitmap_bits) {
+ /* No changes are buffered for this page. */
+ space->release();
+ if (UNIV_UNLIKELY(srv_shutdown_state)
+ && !srv_fast_shutdown
+ && (!block
+ || btr_page_get_index_id(block->frame)
+ != DICT_IBUF_ID_MIN + IBUF_SPACE_ID)) {
+ /* Prevent an infinite loop on slow
+ shutdown, in case the bitmap bits are
+ wrongly clear even though buffered
+ changes exist. */
+ ibuf_delete_recs(page_id);
}
+ return;
}
- } else if (block != NULL
- && (ibuf_fixed_addr_page(page_id, *page_size)
- || fsp_descr_page(page_id, *page_size))) {
-
- return;
- } else {
- space = NULL;
}
mem_heap_t* heap = mem_heap_create(512);
@@ -4523,12 +4488,8 @@ loop:
ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF,
&pcur, &mtr);
- if (block != NULL) {
- ibool success;
-
- mtr.set_named_space(space);
-
- success = buf_page_get_known_nowait(
+ if (block) {
+ ibool success = buf_page_get_known_nowait(
RW_X_LATCH, block,
BUF_KEEP_OLD, __FILE__, __LINE__, &mtr);
@@ -4541,7 +4502,9 @@ loop:
the block is io-fixed. Other threads must not try to
latch an io-fixed block. */
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
- } else if (update_ibuf_bitmap) {
+ }
+
+ if (space) {
mtr.set_named_space(space);
}
@@ -4702,26 +4665,26 @@ loop:
}
reset_bit:
- if (update_ibuf_bitmap) {
+ if (space) {
page_t* bitmap_page;
- bitmap_page = ibuf_bitmap_get_map_page(page_id, *page_size,
+ bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size,
&mtr);
ibuf_bitmap_page_set_bits(
- bitmap_page, page_id, *page_size,
+ bitmap_page, page_id, page_size,
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
if (block != NULL) {
ulint old_bits = ibuf_bitmap_page_get_bits(
- bitmap_page, page_id, *page_size,
+ bitmap_page, page_id, page_size,
IBUF_BITMAP_FREE, &mtr);
ulint new_bits = ibuf_index_page_calc_free(block);
if (old_bits != new_bits) {
ibuf_bitmap_page_set_bits(
- bitmap_page, page_id, *page_size,
+ bitmap_page, page_id, page_size,
IBUF_BITMAP_FREE, new_bits, &mtr);
}
}
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 3da365503cc..1c6dbcd3580 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -2,7 +2,7 @@
Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2019, MariaDB Corporation.
+Copyright (c) 2013, 2020, 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
@@ -971,14 +971,6 @@ dict_tf_get_page_size(
ulint flags)
MY_ATTRIBUTE((const));
-/** Determine the extent size (in pages) for the given table
-@param[in] table the table whose extent size is being
- calculated.
-@return extent size in pages (256, 128 or 64) */
-ulint
-dict_table_extent_size(
- const dict_table_t* table);
-
/** Get the table page size. */
#define dict_table_page_size(table) page_size_t(table->space->flags)
@@ -1827,20 +1819,6 @@ UNIV_INTERN
ulint
dict_sys_get_size();
-/** Look for any dictionary objects that are found in the given tablespace.
-@param[in] space_id Tablespace ID to search for.
-@return true if tablespace is empty. */
-bool
-dict_space_is_empty(
- ulint space_id);
-
-/** Find the space_id for the given name in sys_tablespaces.
-@param[in] name Tablespace name to search for.
-@return the tablespace ID. */
-ulint
-dict_space_get_id(
- const char* name);
-
/** Free the virtual column template
@param[in,out] vc_templ virtual column template */
UNIV_INLINE
diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h
index 00fe1d3b02a..e5892057209 100644
--- a/storage/innobase/include/ibuf0ibuf.h
+++ b/storage/innobase/include/ibuf0ibuf.h
@@ -339,16 +339,12 @@ exist entries for such a page if the page belonged to an index which
subsequently was dropped.
@param[in,out] block if page has been read from disk,
pointer to the page x-latched, else NULL
-@param[in] page_id page id of the index page
-@param[in] update_ibuf_bitmap normally this is set to TRUE, but
-if we have deleted or are deleting the tablespace, then we naturally do not
-want to update a non-existent bitmap page */
+@param[in] page_id page id of the index page */
void
ibuf_merge_or_delete_for_page(
buf_block_t* block,
const page_id_t page_id,
- const page_size_t* page_size,
- ibool update_ibuf_bitmap);
+ const page_size_t& page_size);
/*********************************************************************//**
Deletes all entries in the insert buffer for a given space id. This is used
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index cf2ab651a5d..ef7623e1db5 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -1032,20 +1032,6 @@ private:
during bulk create index */
FlushObserver* flush_observer;
public:
- /* Lock wait statistics */
- ulint n_rec_lock_waits;
- /*!< Number of record lock waits,
- might not be exactly correct. */
- ulint n_table_lock_waits;
- /*!< Number of table lock waits,
- might not be exactly correct. */
- ulint total_rec_lock_wait_time;
- /*!< Total rec lock wait time up
- to this moment. */
- ulint total_table_lock_wait_time;
- /*!< Total table lock wait time
- up to this moment. */
-
#ifdef WITH_WSREP
os_event_t wsrep_event; /* event waited for in srv_conc_slot */
#endif /* WITH_WSREP */
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 8de2f344e39..c62381217a4 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -320,8 +320,7 @@ public:
&mtr, NULL)) {
mutex_exit(&recv_sys->mutex);
ibuf_merge_or_delete_for_page(
- block, i->first,
- &block->page.size, true);
+ block, i->first, block->page.size);
mtr.commit();
mtr.start();
mutex_enter(&recv_sys->mutex);
diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc
index aaab2e1b5ec..09e6ad79685 100644
--- a/storage/innobase/trx/trx0rec.cc
+++ b/storage/innobase/trx/trx0rec.cc
@@ -141,15 +141,18 @@ trx_undo_parse_add_undo_rec(
}
/** Calculate the free space left for extending an undo log record.
-@param[in] undo_block undo log page
-@param[in] ptr current end of the undo page
+@param block undo log page
+@param ptr current end of the undo page
@return bytes left */
-static ulint trx_undo_left(const buf_block_t* undo_block, const byte* ptr)
+static ulint trx_undo_left(const buf_block_t *undo_block, const byte *ptr)
{
- /* The 10 is a safety margin, in case we have some small
- calculation error below */
- return srv_page_size - ulint(ptr - undo_block->frame)
- - (10 + FIL_PAGE_DATA_END);
+ ut_ad(ptr >= &undo_block->frame[TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE]);
+ /* The 10 is supposed to be an extra safety margin (and needed for
+ compatibility with older versions) */
+ lint left= srv_page_size - (ptr - undo_block->frame) -
+ (10 + FIL_PAGE_DATA_END);
+ ut_ad(left >= 0);
+ return left < 0 ? 0 : static_cast<ulint>(left);
}
/**********************************************************************//**
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 6628c5b9e56..c92af8c2b84 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -469,10 +469,6 @@ void trx_t::free()
MEM_NOACCESS(&mod_tables, sizeof mod_tables);
MEM_NOACCESS(&detailed_error, sizeof detailed_error);
MEM_NOACCESS(&flush_observer, sizeof flush_observer);
- MEM_NOACCESS(&n_rec_lock_waits, sizeof n_rec_lock_waits);
- MEM_NOACCESS(&n_table_lock_waits, sizeof n_table_lock_waits);
- MEM_NOACCESS(&total_rec_lock_wait_time, sizeof total_rec_lock_wait_time);
- MEM_NOACCESS(&total_table_lock_wait_time, sizeof total_table_lock_wait_time);
#ifdef WITH_WSREP
MEM_NOACCESS(&wsrep_event, sizeof wsrep_event);
#endif /* WITH_WSREP */