diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-12 11:18:04 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-11-12 11:18:04 +0200 |
commit | 972dc6ee98b6447363ccbc5dcb921d3542d7d238 (patch) | |
tree | 2b2317a9e8a61a6ac385e7c1592eb921a4be36c8 /storage | |
parent | 2fbcddbeafb558720f4b74b0a8f68c18b48d9f2e (diff) | |
parent | 150f447af1d9ffff168372505e5c9b4297bdd9d4 (diff) | |
download | mariadb-git-972dc6ee98b6447363ccbc5dcb921d3542d7d238.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/buf/buf0buf.cc | 6 | ||||
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 85 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 2 | ||||
-rw-r--r-- | storage/innobase/ibuf/ibuf0ibuf.cc | 105 | ||||
-rw-r--r-- | storage/innobase/include/dict0dict.h | 27 | ||||
-rw-r--r-- | storage/innobase/include/ibuf0ibuf.h | 18 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 14 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 2 | ||||
-rw-r--r-- | storage/innobase/trx/trx0rec.cc | 8 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 4 | ||||
-rw-r--r-- | storage/maria/ma_check.c | 34 | ||||
-rw-r--r-- | storage/maria/ma_delete_table.c | 9 | ||||
-rw-r--r-- | storage/maria/ma_open.c | 2 |
13 files changed, 87 insertions, 229 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 6095f71f839..967747c4a38 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -4637,7 +4637,7 @@ evict_from_pool: if (!access_time && !recv_no_ibuf_operations) { ibuf_merge_or_delete_for_page( - block, block->page.id, zip_size, true); + block, block->page.id, zip_size); } buf_pool_mutex_enter(buf_pool); @@ -5691,7 +5691,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, zip_size, true); + ibuf_merge_or_delete_for_page(NULL, page_id, zip_size); } frame = block->frame; @@ -6188,7 +6188,7 @@ release_page: && page_is_leaf(frame)) { ibuf_merge_or_delete_for_page( reinterpret_cast<buf_block_t*>(bpage), - bpage->id, bpage->zip_size(), true); + bpage->id, bpage->zip_size()); } space->release_for_io(); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 2697afc2802..980f4c12e66 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -6307,88 +6307,3 @@ 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; - - dict_sys_lock(); - 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); - dict_sys_unlock(); - - 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; - - dict_sys_lock(); - 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); - dict_sys_unlock(); - - return(id); -} diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 057b233a5fc..a9206df377c 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -621,6 +621,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), @@ -676,7 +677,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 63fc94d8650..469836f0955 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -4332,19 +4332,11 @@ insert buffer. If the page is not read, but created in the buffer pool, this function deletes its buffered entries from the insert buffer; there can 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] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] update_ibuf_bitmap normally this is set, but -if we have deleted or are deleting the tablespace, then we naturally do not -want to update a non-existent bitmap page */ -void -ibuf_merge_or_delete_for_page( - buf_block_t* block, - const page_id_t page_id, - ulint zip_size, - bool update_ibuf_bitmap) +@param block X-latched page to try to apply changes to, or NULL to discard +@param page_id page identifier +@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 */ +void ibuf_merge_or_delete_for_page(buf_block_t *block, const page_id_t page_id, + ulint zip_size) { btr_pcur_t pcur; #ifdef UNIV_IBUF_DEBUG @@ -4375,58 +4367,43 @@ ibuf_merge_or_delete_for_page( return; } - fil_space_t* space; - - if (update_ibuf_bitmap) { - space = fil_space_acquire_silent(page_id.space()); + fil_space_t* 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 { + ulint bitmap_bits = 0; - ibuf_mtr_start(&mtr); + ibuf_mtr_start(&mtr); - bitmap_page = ibuf_bitmap_get_map_page( - page_id, zip_size, &mtr); + page_t* bitmap_page = ibuf_bitmap_get_map_page( + page_id, zip_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, zip_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, zip_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, physical_size) - || fsp_descr_page(page_id, physical_size))) { - - return; - } else { - space = NULL; } mem_heap_t* heap = mem_heap_create(512); @@ -4473,12 +4450,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); @@ -4491,7 +4464,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); } @@ -4652,7 +4627,7 @@ loop: } reset_bit: - if (update_ibuf_bitmap) { + if (space) { page_t* bitmap_page; bitmap_page = ibuf_bitmap_get_map_page(page_id, zip_size, diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 6bb86269856..a3f4baa4c31 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -893,19 +893,6 @@ inline ulint dict_tf_get_zip_size(ulint flags) : 0; } -/** 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) */ -inline ulint dict_table_extent_size(const dict_table_t* table) -{ - if (ulint zip_size = table->space->zip_size()) { - return (1ULL << 20) / zip_size; - } - - return FSP_EXTENT_SIZE; -} - /********************************************************************//** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. @@ -1788,20 +1775,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 02d38069d94..45d674f2c02 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -331,19 +331,11 @@ insert buffer. If the page is not read, but created in the buffer pool, this function deletes its buffered entries from the insert buffer; there can 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] zip_size ROW_FORMAT=COMPRESSED page size, or 0 -@param[in] update_ibuf_bitmap normally this is set, but -if we have deleted or are deleting the tablespace, then we naturally do not -want to update a non-existent bitmap page */ -void -ibuf_merge_or_delete_for_page( - buf_block_t* block, - const page_id_t page_id, - ulint zip_size, - bool update_ibuf_bitmap); +@param block X-latched page to try to apply changes to, or NULL to discard +@param page_id page identifier +@param zip_size ROW_FORMAT=COMPRESSED page size, or 0 */ +void ibuf_merge_or_delete_for_page(buf_block_t *block, const page_id_t page_id, + ulint zip_size); /** Delete all change buffer entries for a tablespace, in DISCARD TABLESPACE, IMPORT TABLESPACE, or crash recovery. diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index eb504d81b5c..c32234d923d 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1012,20 +1012,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 6e58994dff2..d7fef4e9675 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -320,7 +320,7 @@ public: mutex_exit(&recv_sys.mutex); ibuf_merge_or_delete_for_page( block, i.first, - block->zip_size(), true); + block->zip_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 bf85121d947..fee96c44479 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -148,13 +148,13 @@ trx_undo_parse_add_undo_rec( @return bytes left */ static ulint trx_undo_left(const buf_block_t *undo_block, const byte *ptr) { - ut_ad(ptr >= &undo_block->frame[TRX_UNDO_PAGE_HDR]); - ut_ad(ptr <= &undo_block->frame[srv_page_size - 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) */ - return srv_page_size - ulint(ptr - undo_block->frame) - + 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 e159d7f1dd3..01cb842cc0b 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -471,10 +471,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 */ diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 9670daa9104..26a9241c205 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2350,6 +2350,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, @@ -2364,9 +2372,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; @@ -2394,7 +2399,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); @@ -2878,9 +2882,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) @@ -4095,10 +4103,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) @@ -4627,10 +4638,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 05aca8f37e1..89848fae03e 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -1345,7 +1345,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. |