diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/btr/btr0btr.cc | 4 | ||||
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 104 | ||||
-rw-r--r-- | storage/innobase/buf/buf0dblwr.cc | 2 | ||||
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 4 | ||||
-rw-r--r-- | storage/innobase/dict/dict0load.cc | 3 | ||||
-rw-r--r-- | storage/innobase/dict/dict0mem.cc | 2 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 23 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 3 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 6 | ||||
-rw-r--r-- | storage/innobase/include/fts0fts.h | 8 | ||||
-rw-r--r-- | storage/innobase/include/row0ins.h | 1 | ||||
-rw-r--r-- | storage/innobase/page/page0zip.cc | 3 | ||||
-rw-r--r-- | storage/innobase/que/que0que.cc | 13 | ||||
-rw-r--r-- | storage/innobase/row/row0merge.cc | 3 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.cc | 6 | ||||
-rw-r--r-- | storage/perfschema/table_replication_applier_status_by_worker.cc | 49 |
16 files changed, 140 insertions, 94 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index f28d3929569..4d576ff7a8b 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -3318,7 +3318,7 @@ insert_empty: ut_a(!insert_page_zip || page_zip_validate(insert_page_zip, insert_page, - cursor->index)); + cursor->index())); } #endif /* UNIV_ZIP_DEBUG */ @@ -4380,7 +4380,7 @@ btr_discard_page( #ifdef UNIV_ZIP_DEBUG if (page_zip_des_t* merge_page_zip - = buf_block_get_page_zip(merge_block)); + = buf_block_get_page_zip(merge_block)) ut_a(page_zip_validate(merge_page_zip, merge_block->page.frame, index)); #endif /* UNIV_ZIP_DEBUG */ diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 71177e228ec..dda6a95da16 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1674,7 +1674,7 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple, mtr->upgrade_buffer_fix(block_savepoint, RW_X_LATCH); #ifdef UNIV_ZIP_DEBUG const page_zip_des_t *page_zip= buf_block_get_page_zip(block); - ut_a(!page_zip || page_zip_validate(page_zip, page, index())); + ut_a(!page_zip || page_zip_validate(page_zip, block->page.frame, index())); #endif /* UNIV_ZIP_DEBUG */ if (page_has_next(block->page.frame) && !btr_block_get(*index(), btr_page_get_next(block->page.frame), @@ -3115,9 +3115,84 @@ void btr_cur_upd_rec_in_place(rec_t *rec, const dict_index_t *index, } } - if (UNIV_LIKELY_NULL(block->page.zip.data)) { - page_zip_write_rec(block, rec, index, offsets, 0, mtr); + if (UNIV_LIKELY(!block->page.zip.data)) { + return; } + + switch (update->n_fields) { + case 0: + /* We only changed the delete-mark flag. */ + return; + case 1: + if (!index->is_clust() + || update->fields[0].field_no != index->db_roll_ptr()) { + break; + } + goto update_sys; + case 2: + if (!index->is_clust() + || update->fields[0].field_no != index->db_trx_id() + || update->fields[1].field_no != index->db_roll_ptr()) { + break; + } + update_sys: + ulint len; + const byte* sys = rec_get_nth_field(rec, offsets, + index->db_trx_id(), &len); + ut_ad(len == DATA_TRX_ID_LEN); + page_zip_write_trx_id_and_roll_ptr( + block, rec, offsets, index->db_trx_id(), + trx_read_trx_id(sys), + trx_read_roll_ptr(sys + DATA_TRX_ID_LEN), mtr); + return; + } + + page_zip_write_rec(block, rec, index, offsets, 0, mtr); +} + +/** Check if a ROW_FORMAT=COMPRESSED page can be updated in place +@param cur cursor pointing to ROW_FORMAT=COMPRESSED page +@param offsets rec_get_offsets(btr_cur_get_rec(cur)) +@param update index fields being updated +@param mtr mini-transaction +@return the record in the ROW_FORMAT=COMPRESSED page +@retval nullptr if the page cannot be updated in place */ +ATTRIBUTE_COLD static +rec_t *btr_cur_update_in_place_zip_check(btr_cur_t *cur, rec_offs *offsets, + const upd_t& update, mtr_t *mtr) +{ + dict_index_t *index= cur->index(); + ut_ad(!index->table->is_temporary()); + + switch (update.n_fields) { + case 0: + /* We are only changing the delete-mark flag. */ + break; + case 1: + if (!index->is_clust() || + update.fields[0].field_no != index->db_roll_ptr()) + goto check_for_overflow; + /* We are only changing the delete-mark flag and DB_ROLL_PTR. */ + break; + case 2: + if (!index->is_clust() || + update.fields[0].field_no != index->db_trx_id() || + update.fields[1].field_no != index->db_roll_ptr()) + goto check_for_overflow; + /* We are only changing DB_TRX_ID, DB_ROLL_PTR, and the delete-mark. + They can be updated in place in the uncompressed part of the + ROW_FORMAT=COMPRESSED page. */ + break; + check_for_overflow: + default: + if (!btr_cur_update_alloc_zip(btr_cur_get_page_zip(cur), + btr_cur_get_page_cur(cur), + offsets, rec_offs_size(offsets), + false, mtr)) + return nullptr; + } + + return btr_cur_get_rec(cur); } /*************************************************************//** @@ -3180,17 +3255,10 @@ btr_cur_update_in_place( page_zip_des_t* page_zip = buf_block_get_page_zip(block); /* Check that enough space is available on the compressed page. */ - if (UNIV_LIKELY_NULL(page_zip)) { - ut_ad(!index->table->is_temporary()); - - if (!btr_cur_update_alloc_zip( - page_zip, btr_cur_get_page_cur(cursor), - offsets, rec_offs_size(offsets), - false, mtr)) { - return(DB_ZIP_OVERFLOW); - } - - rec = btr_cur_get_rec(cursor); + if (UNIV_LIKELY_NULL(page_zip) + && !(rec = btr_cur_update_in_place_zip_check( + cursor, offsets, *update, mtr))) { + return DB_ZIP_OVERFLOW; } /* Do lock checking and undo logging */ @@ -3961,7 +4029,13 @@ btr_cur_pessimistic_update( ut_ad(page_is_leaf(block->page.frame)); ut_ad(dict_index_is_clust(index)); - ut_ad(flags & BTR_KEEP_POS_FLAG); + if (UNIV_UNLIKELY(!(flags & BTR_KEEP_POS_FLAG))) { + ut_ad(page_zip != NULL); + dtuple_convert_back_big_rec(index, new_entry, + big_rec_vec); + big_rec_vec = NULL; + n_ext = dtuple_get_n_ext(new_entry); + } } /* Do lock checking and undo logging */ diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 2ea72eb4c5f..8d8b92ae560 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -53,6 +53,7 @@ void buf_dblwr_t::init() active_slot= &slots[0]; mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr); pthread_cond_init(&cond, nullptr); + pthread_cond_init(&write_cond, nullptr); } } @@ -466,6 +467,7 @@ void buf_dblwr_t::close() ut_ad(!batch_running); pthread_cond_destroy(&cond); + pthread_cond_destroy(&write_cond); for (int i= 0; i < 2; i++) { aligned_free(slots[i].write_buf); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index d2fa8555e43..32aba4bad85 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1932,8 +1932,8 @@ void dict_sys_t::remove(dict_table_t* table, bool lru, bool keep) #ifdef BTR_CUR_HASH_ADAPT if (table->fts) { fts_optimize_remove_table(table); - fts_free(table); - table->fts = NULL; + table->fts->~fts_t(); + table->fts = nullptr; } table->autoinc_mutex.wr_lock(); diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index bd3bd71544a..f769839db14 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2525,7 +2525,8 @@ corrupted: /* the table->fts could be created in dict_load_column when a user defined FTS_DOC_ID is present, but no FTS */ - fts_free(table); + table->fts->~fts_t(); + table->fts = nullptr; } else if (fts_optimize_wq) { fts_optimize_add_table(table); } else if (table->can_be_evicted) { diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index 3d8b40830b0..b8b2d583c24 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -212,7 +212,7 @@ dict_mem_table_free( || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID) || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_ADD_DOC_ID)) { if (table->fts) { - fts_free(table); + table->fts->~fts_t(); } } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 5acdff90fc0..6fdb0e11182 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -826,7 +826,8 @@ void fts_clear_all(dict_table_t *table) fts_optimize_remove_table(table); - fts_free(table); + table->fts->~fts_t(); + table->fts= nullptr; DICT_TF2_FLAG_UNSET(table, DICT_TF2_FTS); } @@ -5154,14 +5155,14 @@ fts_t::~fts_t() { ut_ad(add_wq == NULL); - if (cache != NULL) { + if (cache) { fts_cache_clear(cache); fts_cache_destroy(cache); - cache = NULL; } /* There is no need to call ib_vector_free() on this->indexes because it is stored in this->fts_heap. */ + mem_heap_free(fts_heap); } /*********************************************************************//** @@ -5185,22 +5186,6 @@ fts_create( } /*********************************************************************//** -Free the FTS resources. */ -void -fts_free( -/*=====*/ - dict_table_t* table) /*!< in/out: table with FTS indexes */ -{ - fts_t* fts = table->fts; - - fts->~fts_t(); - - mem_heap_free(fts->fts_heap); - - table->fts = NULL; -} - -/*********************************************************************//** Take a FTS savepoint. */ UNIV_INLINE void diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8a1bb32c973..9ae04c6e794 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12759,7 +12759,8 @@ int create_table_info_t::create_table(bool create_fk) m_table->name.m_name); if (m_table->fts) { - fts_free(m_table); + m_table->fts->~fts_t(); + m_table->fts = nullptr; } my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 59a8b005557..5825b4ae78a 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1180,7 +1180,8 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx old_v_cols[i].~dict_v_col_t(); } if (instant_table->fts) { - fts_free(instant_table); + instant_table->fts->~fts_t(); + instant_table->fts = nullptr; } dict_mem_table_free(instant_table); } @@ -8910,7 +8911,8 @@ innobase_rollback_sec_index( && !DICT_TF2_FLAG_IS_SET(user_table, DICT_TF2_FTS_HAS_DOC_ID) && !innobase_fulltext_exist(table)) { - fts_free(user_table); + user_table->fts->~fts_t(); + user_table->fts = nullptr; } } diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 0a821647dab..720fe7f25b9 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -610,14 +610,6 @@ fts_create( dict_table_t* table); /*!< out: table with FTS indexes */ -/**********************************************************************//** -Free the FTS resources. */ -void -fts_free( -/*=====*/ - dict_table_t* table); /*!< in/out: table with - FTS indexes */ - /*********************************************************************//** Run OPTIMIZE on the given table. @return DB_SUCCESS if all OK */ diff --git a/storage/innobase/include/row0ins.h b/storage/innobase/include/row0ins.h index 517319e5b13..ac2479c4863 100644 --- a/storage/innobase/include/row0ins.h +++ b/storage/innobase/include/row0ins.h @@ -177,6 +177,7 @@ struct ins_node_t trx_id(0), entry_sys_heap(mem_heap_create(128)) { } + ~ins_node_t() { mem_heap_free(entry_sys_heap); } que_common_t common; /*!< node type: QUE_NODE_INSERT */ ulint ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */ dtuple_t* row; /*!< row to insert */ diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 56b58dd87d0..ba1bb24b43b 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -3974,9 +3974,6 @@ page_zip_write_trx_id_and_roll_ptr( ut_ad(field + DATA_TRX_ID_LEN == rec_get_nth_field(rec, offsets, trx_id_col + 1, &len)); ut_ad(len == DATA_ROLL_PTR_LEN); -#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG - ut_a(!memcmp(storage, field, sys_len)); -#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ compile_time_assert(DATA_TRX_ID_LEN == 6); mach_write_to_6(field, trx_id); compile_time_assert(DATA_ROLL_PTR_LEN == 7); diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index 5f5f527e06b..d910ee2a881 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -236,9 +236,9 @@ que_graph_free_stat_list( que_node_t* node) /*!< in: first query graph node in the list */ { while (node) { + que_node_t* next = que_node_get_next(node); que_graph_free_recursive(node); - - node = que_node_get_next(node); + node = next; } } @@ -297,19 +297,10 @@ que_graph_free_recursive( break; case QUE_NODE_INSERT: - ins = static_cast<ins_node_t*>(node); que_graph_free_recursive(ins->select); - ins->select = NULL; - ins->~ins_node_t(); - - if (ins->entry_sys_heap != NULL) { - mem_heap_free(ins->entry_sys_heap); - ins->entry_sys_heap = NULL; - } - break; case QUE_NODE_PURGE: purge = static_cast<purge_node_t*>(node); diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 5601a786555..cfeac48ac52 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -4037,7 +4037,8 @@ static void row_merge_drop_fulltext_indexes(trx_t *trx, dict_table_t *table) fts_optimize_remove_table(table); fts_drop_tables(trx, *table); - fts_free(table); + table->fts->~fts_t(); + table->fts= nullptr; DICT_TF2_FLAG_UNSET(table, DICT_TF2_FTS); } diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 716e5351446..e5db6a777d9 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -4891,7 +4891,11 @@ page_corrupted: if (trx->isolation_level == TRX_ISO_READ_UNCOMMITTED || !trx->read_view.is_open()) { } else if (trx_id_t bulk_trx_id = index->table->bulk_trx_id) { - if (!trx->read_view.changes_visible(bulk_trx_id)) { + /* InnoDB should allow the transaction to read all + the rows when InnoDB intends to do any locking + on the record */ + if (prebuilt->select_lock_type == LOCK_NONE + && !trx->read_view.changes_visible(bulk_trx_id)) { trx->op_info = ""; err = DB_END_OF_INDEX; goto normal_return; diff --git a/storage/perfschema/table_replication_applier_status_by_worker.cc b/storage/perfschema/table_replication_applier_status_by_worker.cc index 1ccf75e5d25..e982b5203ec 100644 --- a/storage/perfschema/table_replication_applier_status_by_worker.cc +++ b/storage/perfschema/table_replication_applier_status_by_worker.cc @@ -100,72 +100,67 @@ ha_rows table_replication_applier_status_by_worker::get_row_count() int table_replication_applier_status_by_worker::rnd_next(void) { rpl_parallel_thread_pool *pool= &global_rpl_thread_pool; - if (pool->inited && pool->count) + struct pool_bkp_for_pfs *bkp_pool= &pool->pfs_bkp; + mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); + if (bkp_pool->inited && bkp_pool->count && bkp_pool->is_valid) { - mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); - uint worker_count= pool->count; for (m_pos.set_at(&m_next_pos); - m_pos.has_more_workers(worker_count); + m_pos.has_more_workers(bkp_pool->count); m_pos.next_worker()) { - rpl_parallel_thread *rpt= pool->threads[m_pos.m_index]; + rpl_parallel_thread *rpt= bkp_pool->rpl_thread_arr[m_pos.m_index]; make_row(rpt); m_next_pos.set_after(&m_pos); mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); return 0; } - mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); } else { - mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); - struct pool_bkp_for_pfs *bkp_pool= &pool->pfs_bkp; - if (bkp_pool->inited && bkp_pool->count) + if (pool->inited && pool->count) { + uint worker_count= pool->count; for (m_pos.set_at(&m_next_pos); - m_pos.has_more_workers(bkp_pool->count); - m_pos.next_worker()) + m_pos.has_more_workers(worker_count); + m_pos.next_worker()) { - rpl_parallel_thread *rpt= bkp_pool->rpl_thread_arr[m_pos.m_index]; + rpl_parallel_thread *rpt= pool->threads[m_pos.m_index]; make_row(rpt); m_next_pos.set_after(&m_pos); mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); return 0; } } - mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); } + mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); return HA_ERR_END_OF_FILE; } int table_replication_applier_status_by_worker::rnd_pos(const void *pos) { int res= HA_ERR_RECORD_DELETED; + rpl_parallel_thread_pool *pool= &global_rpl_thread_pool; + struct pool_bkp_for_pfs *bkp_pool= &pool->pfs_bkp; set_position(pos); - - if (global_rpl_thread_pool.inited && global_rpl_thread_pool.count) + mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); + if (bkp_pool->inited && bkp_pool->count && bkp_pool->is_valid + && m_pos.m_index < bkp_pool->count) { - rpl_parallel_thread_pool *pool= &global_rpl_thread_pool; - mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); - if(m_pos.m_index < pool->count) - { - rpl_parallel_thread *rpt= pool->threads[m_pos.m_index]; - make_row(rpt); - mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); - res= 0; - } + rpl_parallel_thread *rpt= bkp_pool->rpl_thread_arr[m_pos.m_index]; + make_row(rpt); + res= 0; } else { - struct pool_bkp_for_pfs *bkp_pool= &global_rpl_thread_pool.pfs_bkp; - if (bkp_pool->inited && bkp_pool->count && m_pos.m_index < bkp_pool->count) + if (pool->inited && pool->count && m_pos.m_index < pool->count) { - rpl_parallel_thread *rpt= bkp_pool->rpl_thread_arr[m_pos.m_index]; + rpl_parallel_thread *rpt= pool->threads[m_pos.m_index]; make_row(rpt); res= 0; } } + mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); return res; } |