From a876121d24a19340db508f74b1582955c2a168b0 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 30 Oct 2020 15:33:18 +0200 Subject: MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOCAL TABLE for Aria table Bugs fixed: - prepare_for_repair() didn't close all open files if table opened failed because of out-of-memory - If dd_recreate_table() failed, the data file was not properly restored from it's temporary name - Aria repair initializing code didn't properly clear all used structs before calling error, which caused crashed in memory-free calls. - maria_delete_table() didn't register if table open failed. This could calls my_error() to be called without returning 1 to the caller, which cased failures in my_ok() Note when merging to 10.5: - Remove the #if MYSQL_VERSION from sql_admin.cc --- storage/maria/ma_check.c | 34 ++++++++++++++++++++++++---------- storage/maria/ma_delete_table.c | 9 ++++++++- storage/maria/ma_open.c | 2 +- 3 files changed, 33 insertions(+), 12 deletions(-) (limited to 'storage') diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 20f8eca2828..0f4d79032f8 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2344,6 +2344,14 @@ static int initialize_variables_for_repair(HA_CHECK *param, { MARIA_SHARE *share= info->s; + /* + We have to clear these variables first, as the cleanup-in-case-of-error + handling may touch these. + */ + bzero((char*) sort_info, sizeof(*sort_info)); + bzero((char*) sort_param, sizeof(*sort_param)); + bzero(&info->rec_cache, sizeof(info->rec_cache)); + if (share->data_file_type == NO_RECORD) { _ma_check_print_error(param, @@ -2358,9 +2366,6 @@ static int initialize_variables_for_repair(HA_CHECK *param, if (share->lock.update_status) (*share->lock.update_status)(info); - bzero((char*) sort_info, sizeof(*sort_info)); - bzero((char*) sort_param, sizeof(*sort_param)); - param->testflag|= T_REP; /* for easy checking */ if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) param->testflag|= T_CALC_CHECKSUM; @@ -2388,7 +2393,6 @@ static int initialize_variables_for_repair(HA_CHECK *param, set_data_file_type(sort_info, info->s); sort_info->org_data_file_type= share->data_file_type; - bzero(&info->rec_cache, sizeof(info->rec_cache)); info->rec_cache.file= info->dfile.file; info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); @@ -2869,9 +2873,13 @@ err: _ma_reset_state(info); end_io_cache(¶m->read_cache); - end_io_cache(&sort_info.new_info->rec_cache); + if (sort_info.new_info) + { + end_io_cache(&sort_info.new_info->rec_cache); + sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + } info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); - sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + sort_param.sort_info->info->in_check_table= 0; /* this below could fail, shouldn't we detect error? */ if (got_error) @@ -4086,10 +4094,13 @@ err: maria_scan_end(sort_info.info); _ma_reset_state(info); - end_io_cache(&sort_info.new_info->rec_cache); + if (sort_info.new_info) + { + end_io_cache(&sort_info.new_info->rec_cache); + sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + } end_io_cache(¶m->read_cache); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); - sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); if (got_error) { if (! param->error_printed) @@ -4618,10 +4629,13 @@ err: the share by remove_io_thread() or it was not yet started (if the error happend before creating the thread). */ - end_io_cache(&sort_info.new_info->rec_cache); + if (sort_info.new_info) + { + end_io_cache(&sort_info.new_info->rec_cache); + sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + } end_io_cache(¶m->read_cache); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); - sort_info.new_info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); /* Destroy the new data cache in case of non-quick repair. All slave threads did either detach from the share by remove_io_thread() diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c index fee001df1e1..0c78476ad44 100644 --- a/storage/maria/ma_delete_table.c +++ b/storage/maria/ma_delete_table.c @@ -30,6 +30,7 @@ int maria_delete_table(const char *name) { MARIA_HA *info; myf sync_dir; + int got_error= 0, error; DBUG_ENTER("maria_delete_table"); #ifdef EXTRA_DEBUG @@ -41,9 +42,13 @@ int maria_delete_table(const char *name) Unfortunately it is necessary to open the table just to check this. We use 'open_for_repair' to be able to open even a crashed table. */ + my_errno= 0; if (!(info= maria_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR))) { sync_dir= 0; + /* Ignore not found errors and wrong symlink errors */ + if (my_errno != ENOENT && my_errno != HA_WRONG_CREATE_OPTION) + got_error= my_errno;; } else { @@ -78,7 +83,9 @@ int maria_delete_table(const char *name) DBUG_RETURN(1); } - DBUG_RETURN(maria_delete_table_files(name, 0, sync_dir)); + if (!(error= maria_delete_table_files(name, 0, sync_dir))) + error= got_error; + DBUG_RETURN(error); } diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 226ebe8c1dd..3fa0e4293a6 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -1334,7 +1334,7 @@ static void setup_key_functions(register MARIA_KEYDEF *keyinfo) /** - @brief Function to save and store the header in the index file (.MYI) + @brief Function to save and store the header in the index file (.MAI) Operates under MARIA_SHARE::intern_lock if requested. Sets MARIA_SHARE::MARIA_STATE_INFO::is_of_horizon if transactional table. -- cgit v1.2.1 From d01a034ac604a5f960b5f4d16e24e8951b74419f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 9 Nov 2020 15:50:37 +0200 Subject: MDEV-7620: Remove the data structures The instrumentation that was added in commit 90635c6fb5e51aa878b81b1285c758afc361c7dc (MDEV-7620) was effectively reverted in MariaDB Server 10.2.2, in commit 2e814d4702d71a04388386a9f591d14a35980bfe (which stopped reporting the statistics) and commit fec844aca88e1c6b9c36bb0b811e92d9d023ffb9 (which stopped updating the statistics). Let us remove the orphan data members to reduce the memory footprint. --- storage/innobase/include/trx0trx.h | 14 -------------- storage/innobase/trx/trx0trx.cc | 4 ---- 2 files changed, 18 deletions(-) (limited to 'storage') diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 4161d4d8563..048a050a28d 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1113,20 +1113,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/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 13b4efb973b..245758cecd5 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -464,10 +464,6 @@ inline 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 */ -- cgit v1.2.1 From 5171ab808ce7d42c51188d695608c849272a90dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Nov 2020 07:56:04 +0200 Subject: MDEV-24171 index_online_log is instrumented as rw-lock, not mutex The row_log_t::mutex is a mutex, yet it was instrumented as rw-lock in PERFORMANCE_SCHEMA. --- storage/innobase/handler/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage') diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0617005a213..04683a6843b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -614,6 +614,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), @@ -671,7 +672,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 */ -- cgit v1.2.1 From bd528b0c93409b81157314d9699af519fd9d52ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Nov 2020 09:47:29 +0200 Subject: MDEV-24182 ibuf_merge_or_delete_for_page() contains dead code The function ibuf_merge_or_delete_for_page() was always being invoked with update_ibuf_bitmap=true ever since commit cd623508dff53c210154392da6c0f65b7b6bcf4c fixed up something after MDEV-9566. Furthermore, the parameter page_size is never being passed as a null pointer, and therefore it should better be a reference to a constant object. --- storage/innobase/buf/buf0buf.cc | 6 +- storage/innobase/ibuf/ibuf0ibuf.cc | 123 +++++++++++++---------------------- storage/innobase/include/ibuf0ibuf.h | 8 +-- storage/innobase/log/log0recv.cc | 3 +- 4 files changed, 50 insertions(+), 90 deletions(-) (limited to 'storage') diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e2b68011077..a54d98adee0 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -4601,7 +4601,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); @@ -5678,7 +5678,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; @@ -6133,7 +6133,7 @@ database_corrupted: ibuf_merge_or_delete_for_page( (buf_block_t*) bpage, bpage->id, - &bpage->size, TRUE); + bpage->size); } fil_space_release_for_io(space); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 7068dab77a4..ee6fd235d5e 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -4384,16 +4384,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 @@ -4417,81 +4413,50 @@ 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. */ - - fil_space_release(space); - 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. */ + + fil_space_release(space); + 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); @@ -4541,7 +4506,7 @@ loop: if (block != NULL) { ibool success; - mtr.set_named_space(page_id.space()); + mtr.set_named_space(space); success = buf_page_get_known_nowait( RW_X_LATCH, block, @@ -4556,8 +4521,8 @@ 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) { - mtr.set_named_space(page_id.space()); + } else if (space) { + mtr.set_named_space(space); } if (!btr_pcur_is_on_user_rec(&pcur)) { @@ -4658,7 +4623,7 @@ loop: ibuf_btr_pcur_commit_specify_mtr(&pcur, &mtr); ibuf_mtr_start(&mtr); - mtr.set_named_space(page_id.space()); + mtr.set_named_space(space); success = buf_page_get_known_nowait( RW_X_LATCH, block, @@ -4714,26 +4679,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/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h index a69b63ee16b..1a5214085de 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -342,16 +342,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/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 446e0afe576..4c3886caeaf 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); -- cgit v1.2.1 From 7b7e5922afa38241e0ed54aad266c54225d3f861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Nov 2020 13:49:01 +0200 Subject: MDEV-24156 trx_undo_left() fails to prevent overflow trx_undo_left(): Return 0 in case of an overflow, instead of returning a negative number interpreted as a large positive number. Also, add debug assertions to check that the pointer is within the page area. This should allow us to catch bugs like MDEV-24096 easier in the future. --- storage/innobase/trx/trx0rec.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'storage') diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 4aecc8ae610..e3e1c33b305 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -128,20 +128,18 @@ trx_undo_parse_add_undo_rec( return(ptr + len); } -/**********************************************************************//** -Calculates the free space left for extending an undo log record. +/** Calculate the free space left for extending an undo log record. +@param page undo log page +@param ptr current end of the undo page @return bytes left */ -UNIV_INLINE -ulint -trx_undo_left( -/*==========*/ - const page_t* page, /*!< in: undo log page */ - const byte* ptr) /*!< in: pointer to page */ +static ulint trx_undo_left(const page_t *page, const byte *ptr) { - /* The '- 10' is a safety margin, in case we have some small - calculation error below */ - - return(UNIV_PAGE_SIZE - (ptr - page) - 10 - FIL_PAGE_DATA_END); + ut_ad(ptr >= &page[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 - page) - (10 + FIL_PAGE_DATA_END); + ut_ad(left >= 0); + return left < 0 ? 0 : static_cast(left); } /**********************************************************************//** -- cgit v1.2.1 From d6ee28582a177679c79272c6db6a6f204d8fd49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 11 Nov 2020 08:16:06 +0200 Subject: Cleanup: Remove dict_space_is_empty(), dict_space_get_id() As noted in commit 0b66d3f70d365bbb936aae4ca67892c17d68d241, MariaDB does not support CREATE TABLESPACE for InnoDB. Hence, some code that was added in commit fec844aca88e1c6b9c36bb0b811e92d9d023ffb9 and originally in mysql/mysql-server@c71dd213bd434c0579e454ab8880e6d3756b0fb0 is unused in MariaDB and should be removed. --- storage/innobase/dict/dict0dict.cc | 138 ----------------------------------- storage/innobase/include/dict0dict.h | 24 +----- 2 files changed, 1 insertion(+), 161 deletions(-) (limited to 'storage') diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index e3ce13b5b27..2124fc05faa 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -6707,144 +6707,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/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 7351b5fb682..6cfb92a94d3 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 @@ -989,14 +989,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. @param[in] table table @return compressed page size, or 0 if not compressed */ @@ -1905,20 +1897,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 -- cgit v1.2.1