From 706ed8552dbfd147c72d34b63e7de79a9fbedad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 29 Jan 2018 11:01:02 +0200 Subject: Revert "MDEV-6928: Add trx pointer to struct mtr_t" This reverts commit 3486135bb5c9e21fd678821dee35484a81351cfb. The commit comment ended in the words: "This is needed later." Apparently the "later" never arrived. --- storage/xtradb/api/api0api.cc | 2 +- storage/xtradb/btr/btr0cur.cc | 41 ++++++++++++++----------------------- storage/xtradb/btr/btr0pcur.cc | 2 +- storage/xtradb/fts/fts0fts.cc | 6 ++---- storage/xtradb/fts/fts0que.cc | 3 +-- storage/xtradb/handler/ha_innodb.cc | 2 +- storage/xtradb/include/btr0cur.h | 12 ++++------- storage/xtradb/include/mtr0mtr.h | 16 +-------------- storage/xtradb/include/mtr0mtr.ic | 6 ++---- storage/xtradb/include/trx0undo.h | 13 ++++++++++-- storage/xtradb/row/row0ext.cc | 3 +-- storage/xtradb/row/row0ftsort.cc | 3 +-- storage/xtradb/row/row0ins.cc | 24 ++++++++++------------ storage/xtradb/row/row0log.cc | 4 ++-- storage/xtradb/row/row0merge.cc | 4 ++-- storage/xtradb/row/row0mysql.cc | 8 ++++---- storage/xtradb/row/row0sel.cc | 17 ++++++++------- storage/xtradb/row/row0umod.cc | 14 ++++++------- storage/xtradb/row/row0upd.cc | 12 +++++------ storage/xtradb/trx/trx0rec.cc | 8 ++++---- storage/xtradb/trx/trx0undo.cc | 10 +++++---- 21 files changed, 91 insertions(+), 119 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/api/api0api.cc b/storage/xtradb/api/api0api.cc index 95962abc867..1da25d4bbf7 100644 --- a/storage/xtradb/api/api0api.cc +++ b/storage/xtradb/api/api0api.cc @@ -398,7 +398,7 @@ ib_read_tuple( data = btr_rec_copy_externally_stored_field( copy, offsets, zip_size, i, &len, - tuple->heap, NULL); + tuple->heap); ut_a(len != UNIV_SQL_NULL); } diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc index 829de6a1526..e57a9b77a68 100644 --- a/storage/xtradb/btr/btr0cur.cc +++ b/storage/xtradb/btr/btr0cur.cc @@ -3886,7 +3886,6 @@ static const ib_int64_t rows_in_range_arbitrary_ret_val = 10; @param[in] mode1 search mode for range start @param[in] tuple2 range end, may also be empty tuple @param[in] mode2 search mode for range end -@param[in] trx trx @param[in] nth_attempt if the tree gets modified too much while we are trying to analyze it, then we will retry (this function will call itself, incrementing this parameter) @@ -3903,7 +3902,6 @@ btr_estimate_n_rows_in_range_low( ulint mode1, const dtuple_t* tuple2, ulint mode2, - trx_t* trx, unsigned nth_attempt) { btr_path_t path1[BTR_PATH_ARRAY_N_SLOTS]; @@ -3922,7 +3920,7 @@ btr_estimate_n_rows_in_range_low( table_n_rows = dict_table_get_n_rows(index->table); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); cursor.path_arr = path1; @@ -3940,7 +3938,7 @@ btr_estimate_n_rows_in_range_low( mtr_commit(&mtr); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); #ifdef UNIV_DEBUG if (!strcmp(index->name, "iC")) { @@ -4035,7 +4033,7 @@ btr_estimate_n_rows_in_range_low( const ib_int64_t ret = btr_estimate_n_rows_in_range_low( index, tuple1, mode1, - tuple2, mode2, trx, + tuple2, mode2, nth_attempt + 1); return(ret); @@ -4096,7 +4094,6 @@ btr_estimate_n_rows_in_range_low( @param[in] mode1 search mode for range start @param[in] tuple2 range end, may also be empty tuple @param[in] mode2 search mode for range end -@param[in] trx trx @return estimated number of rows */ ib_int64_t btr_estimate_n_rows_in_range( @@ -4104,11 +4101,10 @@ btr_estimate_n_rows_in_range( const dtuple_t* tuple1, ulint mode1, const dtuple_t* tuple2, - ulint mode2, - trx_t* trx) + ulint mode2) { const ib_int64_t ret = btr_estimate_n_rows_in_range_low( - index, tuple1, mode1, tuple2, mode2, trx, + index, tuple1, mode1, tuple2, mode2, 1 /* first attempt */); return(ret); @@ -5627,8 +5623,7 @@ btr_copy_blob_prefix( ulint len, /*!< in: length of buf, in bytes */ ulint space_id,/*!< in: space id of the BLOB pages */ ulint page_no,/*!< in: page number of the first BLOB page */ - ulint offset, /*!< in: offset on the first BLOB page */ - trx_t* trx) /*!< in: transaction handle */ + ulint offset) /*!< in: offset on the first BLOB page */ { ulint copied_len = 0; @@ -5640,7 +5635,7 @@ btr_copy_blob_prefix( ulint part_len; ulint copy_len; - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); block = buf_page_get(space_id, 0, page_no, RW_S_LATCH, &mtr); buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE); @@ -5843,8 +5838,7 @@ btr_copy_externally_stored_field_prefix_low( zero for uncompressed BLOBs */ ulint space_id,/*!< in: space id of the first BLOB page */ ulint page_no,/*!< in: page number of the first BLOB page */ - ulint offset, /*!< in: offset on the first BLOB page */ - trx_t* trx) /*!< in: transaction handle */ + ulint offset) /*!< in: offset on the first BLOB page */ { if (UNIV_UNLIKELY(len == 0)) { return(0); @@ -5855,7 +5849,7 @@ btr_copy_externally_stored_field_prefix_low( space_id, page_no, offset)); } else { return(btr_copy_blob_prefix(buf, len, space_id, - page_no, offset, trx)); + page_no, offset)); } } @@ -5876,8 +5870,7 @@ btr_copy_externally_stored_field_prefix( field containing also the reference to the external part; must be protected by a lock or a page latch */ - ulint local_len,/*!< in: length of data, in bytes */ - trx_t* trx) /*!< in: transaction handle */ + ulint local_len)/*!< in: length of data, in bytes */ { ulint space_id; ulint page_no; @@ -5916,7 +5909,7 @@ btr_copy_externally_stored_field_prefix( len - local_len, zip_size, space_id, page_no, - offset, trx)); + offset)); } /*******************************************************************//** @@ -5935,8 +5928,7 @@ btr_copy_externally_stored_field( ulint zip_size,/*!< in: nonzero=compressed BLOB page size, zero for uncompressed BLOBs */ ulint local_len,/*!< in: length of data */ - mem_heap_t* heap, /*!< in: mem heap */ - trx_t* trx) /*!< in: transaction handle */ + mem_heap_t* heap) /*!< in: mem heap */ { ulint space_id; ulint page_no; @@ -5967,8 +5959,7 @@ btr_copy_externally_stored_field( extern_len, zip_size, space_id, - page_no, offset, - trx); + page_no, offset); return(buf); } @@ -5987,8 +5978,7 @@ btr_rec_copy_externally_stored_field( zero for uncompressed BLOBs */ ulint no, /*!< in: field number */ ulint* len, /*!< out: length of the field */ - mem_heap_t* heap, /*!< in: mem heap */ - trx_t* trx) /*!< in: transaction handle */ + mem_heap_t* heap) /*!< in: mem heap */ { ulint local_len; const byte* data; @@ -6019,7 +6009,6 @@ btr_rec_copy_externally_stored_field( } return(btr_copy_externally_stored_field(len, data, - zip_size, local_len, heap, - trx)); + zip_size, local_len, heap)); } #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/btr/btr0pcur.cc b/storage/xtradb/btr/btr0pcur.cc index 695960efdf3..964119fb822 100644 --- a/storage/xtradb/btr/btr0pcur.cc +++ b/storage/xtradb/btr/btr0pcur.cc @@ -502,7 +502,7 @@ btr_pcur_move_backward_from_page( mtr_commit(mtr); - mtr_start_trx(mtr, mtr->trx); + mtr_start(mtr); btr_pcur_restore_position(latch_mode2, cursor, mtr); diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index bad62ba974d..8838404460f 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -3361,8 +3361,7 @@ fts_fetch_doc_from_rec( dict_table_zip_size(table), clust_pos, &doc->text.f_len, static_cast( - doc->self_heap->arg), - NULL); + doc->self_heap->arg)); } else { doc->text.f_str = (byte*) rec_get_nth_field( clust_rec, offsets, clust_pos, @@ -7591,8 +7590,7 @@ fts_init_recover_doc( &doc.text.f_len, static_cast(dfield_get_data(dfield)), zip_size, len, - static_cast(doc.self_heap->arg), - NULL); + static_cast(doc.self_heap->arg)); } else { doc.text.f_str = static_cast( dfield_get_data(dfield)); diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index d63c1f4d054..0b0aecaeaa2 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -1937,8 +1937,7 @@ fts_query_fetch_document( if (dfield_is_ext(dfield)) { data = btr_copy_externally_stored_field( &cur_len, data, phrase->zip_size, - dfield_get_len(dfield), phrase->heap, - NULL); + dfield_get_len(dfield), phrase->heap); } else { cur_len = dfield_get_len(dfield); } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 524596fb3c0..b34dbe6776f 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -11978,7 +11978,7 @@ ha_innobase::records_in_range( n_rows = btr_estimate_n_rows_in_range(index, range_start, mode1, range_end, - mode2, prebuilt->trx); + mode2); } else { n_rows = HA_POS_ERROR; diff --git a/storage/xtradb/include/btr0cur.h b/storage/xtradb/include/btr0cur.h index d973eb80c59..6e2fb5acd02 100644 --- a/storage/xtradb/include/btr0cur.h +++ b/storage/xtradb/include/btr0cur.h @@ -568,8 +568,7 @@ btr_estimate_n_rows_in_range( const dtuple_t* tuple1, /*!< in: range start, may also be empty tuple */ ulint mode1, /*!< in: search mode for range start */ const dtuple_t* tuple2, /*!< in: range end, may also be empty tuple */ - ulint mode2, /*!< in: search mode for range end */ - trx_t* trx); /*!< in: trx */ + ulint mode2); /*!< in: search mode for range end */ /*******************************************************************//** Estimates the number of different key values in a given index, for each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index). @@ -704,8 +703,7 @@ btr_copy_externally_stored_field_prefix( field containing also the reference to the external part; must be protected by a lock or a page latch */ - ulint local_len,/*!< in: length of data, in bytes */ - trx_t* trx); /*!< in: transaction handle */ + ulint local_len);/*!< in: length of data, in bytes */ /*******************************************************************//** Copies an externally stored field of a record to mem heap. The clustered index record must be protected by a lock or a page latch. @@ -722,8 +720,7 @@ btr_copy_externally_stored_field( ulint zip_size,/*!< in: nonzero=compressed BLOB page size, zero for uncompressed BLOBs */ ulint local_len,/*!< in: length of data */ - mem_heap_t* heap, /*!< in: mem heap */ - trx_t* trx); /*!< in: transaction handle */ + mem_heap_t* heap); /*!< in: mem heap */ /*******************************************************************//** Copies an externally stored field of a record to mem heap. @return the field copied to heap, or NULL if the field is incomplete */ @@ -738,8 +735,7 @@ btr_rec_copy_externally_stored_field( zero for uncompressed BLOBs */ ulint no, /*!< in: field number */ ulint* len, /*!< out: length of the field */ - mem_heap_t* heap, /*!< in: mem heap */ - trx_t* trx); /*!< in: transaction handle */ + mem_heap_t* heap); /*!< in: mem heap */ /*******************************************************************//** Flags the data tuple fields that are marked as extern storage in the update vector. We use this function to remember which fields we must diff --git a/storage/xtradb/include/mtr0mtr.h b/storage/xtradb/include/mtr0mtr.h index f939918a90d..3f2b88362f2 100644 --- a/storage/xtradb/include/mtr0mtr.h +++ b/storage/xtradb/include/mtr0mtr.h @@ -35,7 +35,6 @@ Created 11/26/1995 Heikki Tuuri #include "ut0byte.h" #include "mtr0types.h" #include "page0types.h" -#include "trx0types.h" /* Logging modes for a mini-transaction */ #define MTR_LOG_ALL 21 /* default mode: log all operations @@ -201,15 +200,6 @@ functions). The page number parameter was originally written as 0. @{ */ /* included here because it needs MLOG_LSN defined */ #include "log0log.h" -/***************************************************************//** -Starts a mini-transaction. */ -UNIV_INLINE -void -mtr_start_trx( -/*======*/ - mtr_t* mtr, /*!< out: mini-transaction */ - trx_t* trx) /*!< in: transaction */ - __attribute__((nonnull (1))); /***************************************************************//** Starts a mini-transaction. */ UNIV_INLINE @@ -217,10 +207,7 @@ void mtr_start( /*======*/ mtr_t* mtr) /*!< out: mini-transaction */ -{ - mtr_start_trx(mtr, NULL); -} - MY_ATTRIBUTE((nonnull)) + MY_ATTRIBUTE((nonnull)); /***************************************************************//** Commits a mini-transaction. */ UNIV_INTERN @@ -415,7 +402,6 @@ struct mtr_t{ #ifdef UNIV_DEBUG ulint magic_n; #endif /* UNIV_DEBUG */ - trx_t* trx; /*!< transaction */ }; #ifdef UNIV_DEBUG diff --git a/storage/xtradb/include/mtr0mtr.ic b/storage/xtradb/include/mtr0mtr.ic index a6d9df09925..04c39cf7f7e 100644 --- a/storage/xtradb/include/mtr0mtr.ic +++ b/storage/xtradb/include/mtr0mtr.ic @@ -43,10 +43,9 @@ mtr_block_dirtied( Starts a mini-transaction. */ UNIV_INLINE void -mtr_start_trx( +mtr_start( /*======*/ - mtr_t* mtr, /*!< out: mini-transaction */ - trx_t* trx) /*!< in: transaction */ + mtr_t* mtr) /*!< out: mini-transaction */ { UNIV_MEM_INVALID(mtr, sizeof *mtr); @@ -59,7 +58,6 @@ mtr_start_trx( mtr->made_dirty = FALSE; mtr->n_log_recs = 0; mtr->n_freed_pages = 0; - mtr->trx = trx; ut_d(mtr->state = MTR_ACTIVE); ut_d(mtr->magic_n = MTR_MAGIC_N); diff --git a/storage/xtradb/include/trx0undo.h b/storage/xtradb/include/trx0undo.h index 190308112ba..0148cc61579 100644 --- a/storage/xtradb/include/trx0undo.h +++ b/storage/xtradb/include/trx0undo.h @@ -243,13 +243,22 @@ Truncates an undo log from the end. This function is used during a rollback to free space from an undo log. */ UNIV_INTERN void -trx_undo_truncate_end( +trx_undo_truncate_end_func( /*=======================*/ - trx_t* trx, /*!< in: transaction whose undo log it is */ +#ifdef UNIV_DEBUG + const trx_t* trx, /*!< in: transaction whose undo log it is */ +#endif /* UNIV_DEBUG */ trx_undo_t* undo, /*!< in/out: undo log */ undo_no_t limit) /*!< in: all undo records with undo number >= this value should be truncated */ MY_ATTRIBUTE((nonnull)); +#ifdef UNIV_DEBUG +# define trx_undo_truncate_end(trx,undo,limit) \ + trx_undo_truncate_end_func(trx,undo,limit) +#else /* UNIV_DEBUG */ +# define trx_undo_truncate_end(trx,undo,limit) \ + trx_undo_truncate_end_func(undo,limit) +#endif /* UNIV_DEBUG */ /***********************************************************************//** Truncates an undo log from the start. This function is used during a purge diff --git a/storage/xtradb/row/row0ext.cc b/storage/xtradb/row/row0ext.cc index ad852577ad2..32b78391d6a 100644 --- a/storage/xtradb/row/row0ext.cc +++ b/storage/xtradb/row/row0ext.cc @@ -78,8 +78,7 @@ row_ext_cache_fill( crashed during the execution of btr_free_externally_stored_field(). */ ext->len[i] = btr_copy_externally_stored_field_prefix( - buf, ext->max_len, zip_size, field, f_len, - NULL); + buf, ext->max_len, zip_size, field, f_len); } } } diff --git a/storage/xtradb/row/row0ftsort.cc b/storage/xtradb/row/row0ftsort.cc index 5cd76fca025..2292083689c 100644 --- a/storage/xtradb/row/row0ftsort.cc +++ b/storage/xtradb/row/row0ftsort.cc @@ -678,8 +678,7 @@ loop: doc.text.f_str = btr_copy_externally_stored_field( &doc.text.f_len, data, - zip_size, data_len, blob_heap, - NULL); + zip_size, data_len, blob_heap); } else { doc.text.f_str = data; doc.text.f_len = data_len; diff --git a/storage/xtradb/row/row0ins.cc b/storage/xtradb/row/row0ins.cc index ae22557bf81..27dbddec067 100644 --- a/storage/xtradb/row/row0ins.cc +++ b/storage/xtradb/row/row0ins.cc @@ -1311,7 +1311,7 @@ row_ins_foreign_check_on_constraint( row_mysql_freeze_data_dictionary(thr_get_trx(thr)); - mtr_start_trx(mtr, trx); + mtr_start(mtr); /* Restore pcur position */ @@ -1339,7 +1339,7 @@ nonstandard_exit_func: btr_pcur_store_position(pcur, mtr); mtr_commit(mtr); - mtr_start_trx(mtr, trx); + mtr_start(mtr); btr_pcur_restore_position(BTR_SEARCH_LEAF, pcur, mtr); @@ -1549,7 +1549,7 @@ run_again: } } - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); /* Store old value on n_fields_cmp */ @@ -2360,7 +2360,7 @@ row_ins_clust_index_entry_low( search_mode = mode; } - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); if (mode == BTR_MODIFY_LEAF && dict_index_is_online_ddl(index)) { @@ -2592,10 +2592,9 @@ Starts a mini-transaction and checks if the index will be dropped. @return true if the index is to be dropped */ static MY_ATTRIBUTE((nonnull, warn_unused_result)) bool -row_ins_sec_mtr_start_trx_and_check_if_aborted( +row_ins_sec_mtr_start_and_check_if_aborted( /*=======================================*/ mtr_t* mtr, /*!< out: mini-transaction */ - trx_t* trx, /*!< in: transaction handle */ dict_index_t* index, /*!< in/out: secondary index */ bool check, /*!< in: whether to check */ ulint search_mode) @@ -2603,7 +2602,7 @@ row_ins_sec_mtr_start_trx_and_check_if_aborted( { ut_ad(!dict_index_is_clust(index)); - mtr_start_trx(mtr, trx); + mtr_start(mtr); if (!check) { return(false); @@ -2661,14 +2660,13 @@ row_ins_sec_index_entry_low( ulint n_unique; mtr_t mtr; ulint* offsets = NULL; - trx_t* trx = thr_get_trx(thr); ut_ad(!dict_index_is_clust(index)); ut_ad(mode == BTR_MODIFY_LEAF || mode == BTR_MODIFY_TREE); cursor.thr = thr; ut_ad(thr_get_trx(thr)->id); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); /* If running with fake_changes mode on then avoid using insert buffer and also switch from modify to search so that code takes only s-latch @@ -2753,8 +2751,8 @@ row_ins_sec_index_entry_low( DEBUG_SYNC_C("row_ins_sec_index_unique"); - if (row_ins_sec_mtr_start_trx_and_check_if_aborted( - &mtr, trx, index, check, search_mode)) { + if (row_ins_sec_mtr_start_and_check_if_aborted( + &mtr, index, check, search_mode)) { goto func_exit; } @@ -2788,8 +2786,8 @@ row_ins_sec_index_entry_low( return(err); } - if (row_ins_sec_mtr_start_trx_and_check_if_aborted( - &mtr, trx, index, check, search_mode)) { + if (row_ins_sec_mtr_start_and_check_if_aborted( + &mtr, index, check, search_mode)) { goto func_exit; } diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index 8c4a1d5ad37..52f6a963ec6 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -1011,7 +1011,7 @@ row_log_table_get_pk_col( mem_heap_alloc(heap, field_len)); len = btr_copy_externally_stored_field_prefix( - blob_field, field_len, zip_size, field, len, NULL); + blob_field, field_len, zip_size, field, len); if (len >= max_len + 1) { return(DB_TOO_BIG_INDEX_COL); } @@ -1404,7 +1404,7 @@ row_log_table_apply_convert_mrec( data = btr_rec_copy_externally_stored_field( mrec, offsets, dict_table_zip_size(index->table), - i, &len, heap, NULL); + i, &len, heap); ut_a(data); dfield_set_data(dfield, data, len); blob_done: diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index 07e66f97b58..00da85a19dd 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -274,7 +274,7 @@ row_merge_buf_redundant_convert( field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE)); byte* data = btr_copy_externally_stored_field( - &ext_len, field_data, zip_size, field_len, heap, trx); + &ext_len, field_data, zip_size, field_len, heap); ut_ad(ext_len < len); @@ -2449,7 +2449,7 @@ row_merge_copy_blobs( BLOB pointers are read (row_merge_read_clustered_index()) and dereferenced (below). */ data = btr_rec_copy_externally_stored_field( - mrec, offsets, zip_size, i, &len, heap, NULL); + mrec, offsets, zip_size, i, &len, heap); /* Because we have locked the table, any records written by incomplete transactions must have been rolled back already. There must not be any incomplete diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 56eeb1a83f3..7a4c5e114c1 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -1950,7 +1950,7 @@ row_unlock_for_mysql( trx_id_t rec_trx_id; mtr_t mtr; - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); /* Restore the cursor position and find the record */ @@ -3495,7 +3495,7 @@ row_truncate_table_for_mysql( index = dict_table_get_next_index(index); } while (index); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); fsp_header_init(space, FIL_IBD_FILE_INITIAL_SIZE, &mtr); mtr_commit(&mtr); @@ -3524,7 +3524,7 @@ row_truncate_table_for_mysql( sys_index = dict_table_get_first_index(dict_sys->sys_indexes); dict_index_copy_types(tuple, sys_index, 1); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, &pcur, &mtr); for (;;) { @@ -3571,7 +3571,7 @@ row_truncate_table_for_mysql( a page in this mini-transaction, and the rest of this loop could latch another index page. */ mtr_commit(&mtr); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); btr_pcur_restore_position(BTR_MODIFY_LEAF, &pcur, &mtr); } diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc index b477adbec89..daef291248b 100644 --- a/storage/xtradb/row/row0sel.cc +++ b/storage/xtradb/row/row0sel.cc @@ -138,8 +138,7 @@ row_sel_sec_rec_is_for_blob( len = btr_copy_externally_stored_field_prefix(buf, prefix_len, zip_size, - clust_field, clust_len, - NULL); + clust_field, clust_len); if (UNIV_UNLIKELY(len == 0)) { /* The BLOB was being deleted as the server crashed. @@ -458,7 +457,7 @@ row_sel_fetch_columns( data = btr_rec_copy_externally_stored_field( rec, offsets, dict_table_zip_size(index->table), - field_no, &len, heap, NULL); + field_no, &len, heap); /* data == NULL means that the externally stored field was not @@ -1406,7 +1405,7 @@ table_loop: /* Open a cursor to index, or restore an open cursor position */ - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); if (consistent_read && plan->unique_search && !plan->pcur_is_open && !plan->must_get_clust @@ -1447,7 +1446,7 @@ table_loop: plan_reset_cursor(plan); mtr_commit(&mtr); - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); } if (search_latch_locked) { @@ -2828,7 +2827,7 @@ row_sel_store_mysql_field_func( data = btr_rec_copy_externally_stored_field( rec, offsets, dict_table_zip_size(prebuilt->table), - field_no, &len, heap, NULL); + field_no, &len, heap); if (UNIV_UNLIKELY(!data)) { /* The externally stored field was not written @@ -3926,7 +3925,7 @@ row_search_for_mysql( } } - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); /*-------------------------------------------------------------*/ /* PHASE 2: Try fast adaptive hash index search if possible */ @@ -5141,7 +5140,7 @@ next_rec: mtr_commit(&mtr); mtr_has_extra_clust_latch = FALSE; - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); if (sel_restore_position_for_mysql(&same_user_rec, BTR_SEARCH_LEAF, pcur, moves_up, &mtr)) { @@ -5206,7 +5205,7 @@ lock_table_wait: /* It was a lock wait, and it ended */ thr->lock_state = QUE_THR_LOCK_NOLOCK; - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); /* Table lock waited, go try to obtain table lock again */ diff --git a/storage/xtradb/row/row0umod.cc b/storage/xtradb/row/row0umod.cc index eeb48b42621..416c27be98f 100644 --- a/storage/xtradb/row/row0umod.cc +++ b/storage/xtradb/row/row0umod.cc @@ -269,7 +269,7 @@ row_undo_mod_clust( pcur = &node->pcur; index = btr_cur_get_index(btr_pcur_get_btr_cur(pcur)); - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); online = dict_index_is_online_ddl(index); if (online) { @@ -298,7 +298,7 @@ row_undo_mod_clust( /* We may have to modify tree structure: do a pessimistic descent down the index tree */ - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); err = row_undo_mod_clust_low( node, &offsets, &offsets_heap, @@ -343,7 +343,7 @@ row_undo_mod_clust( if (err == DB_SUCCESS && node->rec_type == TRX_UNDO_UPD_DEL_REC) { - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); /* It is not necessary to call row_log_table, because the record is delete-marked and would thus @@ -356,7 +356,7 @@ row_undo_mod_clust( /* We may have to modify tree structure: do a pessimistic descent down the index tree */ - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); err = row_undo_mod_remove_clust_low(node, thr, &mtr, BTR_MODIFY_TREE); @@ -403,7 +403,7 @@ row_undo_mod_del_mark_or_remove_sec_low( enum row_search_result search_result; log_free_check(); - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); if (mode == BTR_MODIFY_TREE && index->space == IBUF_SPACE_ID && !dict_index_is_unique(index)) { @@ -464,7 +464,7 @@ row_undo_mod_del_mark_or_remove_sec_low( which cannot be purged yet, requires its existence. If some requires, we should delete mark the record. */ - mtr_start_trx(&mtr_vers, thr_get_trx(thr)); + mtr_start(&mtr_vers); success = btr_pcur_restore_position(BTR_SEARCH_LEAF, &(node->pcur), &mtr_vers); @@ -580,7 +580,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( ut_ad(trx->id); log_free_check(); - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); if (mode == BTR_MODIFY_TREE && index->space == IBUF_SPACE_ID && !dict_index_is_unique(index)) { diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 0b44163e861..4d42e370166 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -213,7 +213,7 @@ row_upd_check_references_constraints( DEBUG_SYNC_C("foreign_constraint_check_for_update"); - mtr_start_trx(mtr, trx); + mtr_start(mtr); if (trx->dict_operation_lock_mode == 0) { got_s_lock = TRUE; @@ -987,7 +987,7 @@ row_upd_ext_fetch( byte* buf = static_cast(mem_heap_alloc(heap, *len)); *len = btr_copy_externally_stored_field_prefix( - buf, *len, zip_size, data, local_len, NULL); + buf, *len, zip_size, data, local_len); /* We should never update records containing a half-deleted BLOB. */ ut_a(*len); @@ -1684,7 +1684,7 @@ row_upd_sec_index_entry( } #endif /* UNIV_DEBUG */ - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); if (*index->name == TEMP_INDEX_PREFIX) { /* The index->online_status may change if the @@ -2157,7 +2157,7 @@ row_upd_clust_rec( /* We may have to modify the tree structure: do a pessimistic descent down the index tree */ - mtr_start_trx(mtr, thr_get_trx(thr)); + mtr_start(mtr); /* NOTE: this transaction has an s-lock or x-lock on the record and therefore other transactions cannot modify the record when we have no @@ -2327,7 +2327,7 @@ row_upd_clust_step( /* We have to restore the cursor to its position */ - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); /* If the restoration does not succeed, then the same transaction has deleted the record on which the cursor was, @@ -2400,7 +2400,7 @@ row_upd_clust_step( mtr_commit(&mtr); - mtr_start_trx(&mtr, thr_get_trx(thr)); + mtr_start(&mtr); success = btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, &mtr); diff --git a/storage/xtradb/trx/trx0rec.cc b/storage/xtradb/trx/trx0rec.cc index e295e7e05ca..dc9b0829925 100644 --- a/storage/xtradb/trx/trx0rec.cc +++ b/storage/xtradb/trx/trx0rec.cc @@ -467,7 +467,7 @@ trx_undo_page_fetch_ext( { /* Fetch the BLOB. */ ulint ext_len = btr_copy_externally_stored_field_prefix( - ext_buf, prefix_len, zip_size, field, *len, NULL); + ext_buf, prefix_len, zip_size, field, *len); /* BLOBs should always be nonempty. */ ut_a(ext_len); /* Append the BLOB pointer to the prefix. */ @@ -1268,7 +1268,7 @@ trx_undo_report_row_operation( rseg = trx->rseg; - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); mutex_enter(&trx->undo_mutex); /* If the undo log is not assigned yet, assign one */ @@ -1345,7 +1345,7 @@ trx_undo_report_row_operation( latches, such as SYNC_FSP and SYNC_FSP_PAGE. */ mtr_commit(&mtr); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); mutex_enter(&rseg->mutex); trx_undo_free_last_page(trx, undo, &mtr); @@ -1382,7 +1382,7 @@ trx_undo_report_row_operation( /* We have to extend the undo log by one page */ ut_ad(++loop_count < 2); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); /* When we add a page to an undo log, this is analogous to a pessimistic insert in a B-tree, and we must reserve the diff --git a/storage/xtradb/trx/trx0undo.cc b/storage/xtradb/trx/trx0undo.cc index 5638ccd17a6..d6bcd131a4f 100644 --- a/storage/xtradb/trx/trx0undo.cc +++ b/storage/xtradb/trx/trx0undo.cc @@ -1070,9 +1070,11 @@ Truncates an undo log from the end. This function is used during a rollback to free space from an undo log. */ UNIV_INTERN void -trx_undo_truncate_end( +trx_undo_truncate_end_func( /*=======================*/ - trx_t* trx, /*!< in: transaction whose undo log it is */ +#ifdef UNIV_DEBUG + const trx_t* trx, /*!< in: transaction whose undo log it is */ +#endif /* UNIV_DEBUG */ trx_undo_t* undo, /*!< in: undo log */ undo_no_t limit) /*!< in: all undo records with undo number >= this value should be truncated */ @@ -1087,7 +1089,7 @@ trx_undo_truncate_end( ut_ad(mutex_own(&(trx->rseg->mutex))); for (;;) { - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); trunc_here = NULL; @@ -1774,7 +1776,7 @@ trx_undo_assign_undo( ut_ad(mutex_own(&(trx->undo_mutex))); - mtr_start_trx(&mtr, trx); + mtr_start(&mtr); mutex_enter(&rseg->mutex); -- cgit v1.2.1 From 5421e3aee7b44c3c400c5dc82b8af00436790ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 8 Feb 2018 12:51:19 +0200 Subject: MDEV-15249 Crash in MVCC read after IMPORT TABLESPACE PageConverter::adjust_cluster_record(): Instead of writing the invalid value DB_ROLL_PTR=0, write a value that indicates a fresh insert, that is, prevents the DB_ROLL_PTR from being dereferenced in any circumstances. It can be argued that IMPORT TABLESPACE should actually update the dict_index_t::trx_id to prevent older transactions from accessing the table, similar to what I did on table rebuild in MySQL 5.6.6 in https://github.com/mysql/mysql-server/commit/03f81a55f221095d397c375afe8a10c8038da339 --- storage/xtradb/include/row0upd.h | 4 ++-- storage/xtradb/include/row0upd.ic | 4 ++-- storage/xtradb/row/row0import.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/include/row0upd.h b/storage/xtradb/include/row0upd.h index 4312fcf7339..9efaaa41cf0 100644 --- a/storage/xtradb/include/row0upd.h +++ b/storage/xtradb/include/row0upd.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, 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 @@ -119,8 +120,7 @@ row_upd_rec_sys_fields( dict_index_t* index, /*!< in: clustered index */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ const trx_t* trx, /*!< in: transaction */ - roll_ptr_t roll_ptr);/*!< in: roll ptr of the undo log record, - can be 0 during IMPORT */ + roll_ptr_t roll_ptr);/*!< in: DB_ROLL_PTR to the undo log */ /*********************************************************************//** Sets the trx id or roll ptr field of a clustered index entry. */ UNIV_INTERN diff --git a/storage/xtradb/include/row0upd.ic b/storage/xtradb/include/row0upd.ic index 618a77fa4bf..efc6c1be4b5 100644 --- a/storage/xtradb/include/row0upd.ic +++ b/storage/xtradb/include/row0upd.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, 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 @@ -153,8 +154,7 @@ row_upd_rec_sys_fields( dict_index_t* index, /*!< in: clustered index */ const ulint* offsets,/*!< in: rec_get_offsets(rec, index) */ const trx_t* trx, /*!< in: transaction */ - roll_ptr_t roll_ptr)/*!< in: roll ptr of the undo log record, - can be 0 during IMPORT */ + roll_ptr_t roll_ptr)/*!< in: DB_ROLL_PTR to the undo log */ { ut_ad(dict_index_is_clust(index)); ut_ad(rec_offs_validate(rec, index, offsets)); diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc index c381b941a8d..26ed99a483c 100644 --- a/storage/xtradb/row/row0import.cc +++ b/storage/xtradb/row/row0import.cc @@ -1798,7 +1798,7 @@ PageConverter::adjust_cluster_record( row_upd_rec_sys_fields( rec, m_page_zip_ptr, m_cluster_index, m_offsets, - m_trx, 0); + m_trx, roll_ptr_t(1) << 55); } return(err); -- cgit v1.2.1 From 6f0b316fbe83d2cf555f867dda262896d18fbbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Thu, 8 Feb 2018 21:12:11 +0200 Subject: Update wrong xtradb version The update was lost during merge. --- storage/xtradb/include/univ.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 96e67f88c8a..c9e5aa62d22 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 36 +#define INNODB_VERSION_BUGFIX 38 #ifndef PERCONA_INNODB_VERSION #define PERCONA_INNODB_VERSION 83.0 -- cgit v1.2.1 From c051eaba46f2a9570bba3f3a64708502ff0aa03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 13 Feb 2018 13:01:14 +0200 Subject: MDEV-14988 innodb_read_only tries to modify files if transactions were recovered in COMMITTED state lock_trx_release_locks(): Relax a debug assertion to allow recovered TRX_STATE_COMMITTED_IN_MEMORY transactions. trx_commit_in_memory(): Add DEBUG_SYNC instrumentation. trx_undo_insert_cleanup(): Skip persistent changes if innodb_read_only is set. This should only happen when a recovered committed transaction would be cleaned up at shutdown. --- storage/xtradb/lock/lock0lock.cc | 5 ++++- storage/xtradb/trx/trx0trx.cc | 4 +++- storage/xtradb/trx/trx0undo.cc | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 2a918158612..9dc82daecf8 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -7099,7 +7099,10 @@ lock_trx_release_locks( } mutex_exit(&trx_sys->mutex); } else { - ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); + ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) + || (trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY) + && trx->is_recovered + && !UT_LIST_GET_LEN(trx->lock.trx_locks))); } /* The transition of trx->state to TRX_STATE_COMMITTED_IN_MEMORY diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 45578283235..701ac3ed72d 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -1442,6 +1442,8 @@ trx_commit_in_memory( if (lsn) { ulint flush_log_at_trx_commit; + DEBUG_SYNC_C("after_trx_committed_in_memory"); + if (trx->insert_undo != NULL) { trx_undo_insert_cleanup(trx); diff --git a/storage/xtradb/trx/trx0undo.cc b/storage/xtradb/trx/trx0undo.cc index d6bcd131a4f..370b3f181a1 100644 --- a/storage/xtradb/trx/trx0undo.cc +++ b/storage/xtradb/trx/trx0undo.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2017, MariaDB Corporation. +Copyright (c) 2014, 2018, 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 @@ -1989,7 +1989,9 @@ trx_undo_insert_cleanup( mutex_exit(&(rseg->mutex)); - trx_undo_seg_free(undo); + if (!srv_read_only_mode) { + trx_undo_seg_free(undo); + } mutex_enter(&(rseg->mutex)); -- cgit v1.2.1 From 4a35e76f645d0e5e8554f810e16aafa734584ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 12 Mar 2018 13:06:21 +0200 Subject: MDEV-14773 DROP TABLE hangs for InnoDB table with FULLTEXT index fts_sync(): If the dict_table_t::to_be_dropped flag is set, do not "goto begin_sync". Also, clean up the way how dict_index_t::index_fts_syncing is cleared. It looks like this regression was introduced by merging Oracle Bug #24938374 MYSQL CRASHED AFTER LONG WAIT ON DICT OPERATION LOCK WHILE SYNCING FTS INDEX https://github.com/mysql/mysql-server/commit/068f8261d4c1e134965383ff974ddf30c0758f51 from MySQL 5.6.38 into MariaDB 10.0.33, 10.1.29, 10.2.10. The same hang is present in MySQL 5.7.20. --- storage/xtradb/fts/fts0fts.cc | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 8838404460f..49b1028bb5e 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2017, MariaDB Corporation. +Copyright (c) 2016, 2018, 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 @@ -4627,6 +4627,7 @@ begin_sync: ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped + || index_cache->index->table->to_be_dropped || fts_sync_index_check(index_cache)) { continue; } @@ -4637,17 +4638,6 @@ begin_sync: end_sync: if (error == DB_SUCCESS && !sync->interrupted) { error = fts_sync_commit(sync); - if (error == DB_SUCCESS) { - for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing) { - index_cache->index->index_fts_syncing - = false; - } - } - } } else { fts_sync_rollback(sync); } @@ -4656,12 +4646,9 @@ end_sync: /* Clear fts syncing flags of any indexes incase sync is interrupeted */ for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - fts_index_cache_t* index_cache; - index_cache = static_cast( - ib_vector_get(cache->indexes, i)); - if (index_cache->index->index_fts_syncing == true) { - index_cache->index->index_fts_syncing = false; - } + static_cast( + ib_vector_get(cache->indexes, i)) + ->index->index_fts_syncing = false; } sync->interrupted = false; -- cgit v1.2.1 From 86718fda4e5363b05aa2beaac596ec614aaa7a0f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 20 Apr 2018 09:40:29 +0200 Subject: compiler warning bad merge --- storage/xtradb/log/log0online.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/log/log0online.cc b/storage/xtradb/log/log0online.cc index 1a30501f266..1e373c8345f 100644 --- a/storage/xtradb/log/log0online.cc +++ b/storage/xtradb/log/log0online.cc @@ -486,9 +486,6 @@ log_online_make_bitmap_name( bmp_file_name_stem, log_bmp_sys->out_seq_num, start_lsn); } -/*********************************************************************//** -} - /*********************************************************************//** Check if an old file that has the name of a new bitmap file we are about to create should be overwritten. */ -- cgit v1.2.1 From 01b2e773ef7a19dbd28a345021cd3a9aa6b10603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 10:35:22 +0300 Subject: MDEV-15937 Assertion failure 'key->flags & 1' on ALTER TABLE While the test case crashes a MariaDB 10.2 debug build only, let us apply the fix to the earliest applicable MariaDB series (10.0) to avoid any data corruption on a table-rebuilding ALTER TABLE using ALGORITHM=INPLACE. innobase_create_key_defs(): Use altered_table->s->primary_key when a new primary key is being created. --- storage/xtradb/handler/handler0alter.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index e5be3aea44a..4a50b324e22 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -1595,6 +1595,7 @@ innobase_create_index_def( if (key_clustered) { DBUG_ASSERT(!(key->flags & HA_FULLTEXT)); + DBUG_ASSERT(key->flags & HA_NOSAME); index->ind_type |= DICT_CLUSTERED; } else if (key->flags & HA_FULLTEXT) { DBUG_ASSERT(!(key->flags & HA_KEYFLAG_MASK @@ -1910,14 +1911,9 @@ innobase_create_key_defs( ulint primary_key_number; if (new_primary) { - if (n_add == 0) { - DBUG_ASSERT(got_default_clust); - DBUG_ASSERT(altered_table->s->primary_key - == 0); - primary_key_number = 0; - } else { - primary_key_number = *add; - } + DBUG_ASSERT(n_add || got_default_clust); + DBUG_ASSERT(n_add || !altered_table->s->primary_key); + primary_key_number = altered_table->s->primary_key; } else if (got_default_clust) { /* Create the GEN_CLUST_INDEX */ index_def_t* index = indexdef++; -- cgit v1.2.1 From 88b1905eda23226515a9ff59999c9a5a9ddf4958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 22:05:19 +0300 Subject: Fix -Wimplicit-fallthrough --- storage/xtradb/include/data0type.ic | 2 ++ 1 file changed, 2 insertions(+) (limited to 'storage/xtradb') diff --git a/storage/xtradb/include/data0type.ic b/storage/xtradb/include/data0type.ic index 96b001e197e..a7e2eb0682c 100644 --- a/storage/xtradb/include/data0type.ic +++ b/storage/xtradb/include/data0type.ic @@ -525,6 +525,7 @@ dtype_get_fixed_size_low( return(0); } #endif /* UNIV_DEBUG */ + /* fall through */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: @@ -602,6 +603,7 @@ dtype_get_min_size_low( return(0); } #endif /* UNIV_DEBUG */ + /* fall through */ case DATA_CHAR: case DATA_FIXBINARY: case DATA_INT: -- cgit v1.2.1 From fcaf6194002b6949e1e806fe2f9f5f5997aa7577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 21 Apr 2018 12:11:04 +0300 Subject: Remove the "register" keyword --- storage/xtradb/page/page0page.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/page/page0page.cc b/storage/xtradb/page/page0page.cc index 7c525c78909..518400a9bf0 100644 --- a/storage/xtradb/page/page0page.cc +++ b/storage/xtradb/page/page0page.cc @@ -2,6 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2018, 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 @@ -98,17 +99,13 @@ page_dir_find_owner_slot( /*=====================*/ const rec_t* rec) /*!< in: the physical record */ { - const page_t* page; - register uint16 rec_offs_bytes; - register const page_dir_slot_t* slot; - register const page_dir_slot_t* first_slot; - register const rec_t* r = rec; - ut_ad(page_rec_check(rec)); - page = page_align(rec); - first_slot = page_dir_get_nth_slot(page, 0); - slot = page_dir_get_nth_slot(page, page_dir_get_n_slots(page) - 1); + const page_t* page = page_align(rec); + const page_dir_slot_t* first_slot = page_dir_get_nth_slot(page, 0); + const page_dir_slot_t* slot = page_dir_get_nth_slot( + page, page_dir_get_n_slots(page) - 1); + const rec_t* r = rec; if (page_is_comp(page)) { while (rec_get_n_owned_new(r) == 0) { @@ -124,7 +121,7 @@ page_dir_find_owner_slot( } } - rec_offs_bytes = mach_encode_2(r - page); + uint16 rec_offs_bytes = mach_encode_2(r - page); while (UNIV_LIKELY(*(uint16*) slot != rec_offs_bytes)) { -- cgit v1.2.1 From c7bb33724826dab53831b74bc0cf7ec311eb13f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Apr 2018 16:19:50 +0300 Subject: MDEV-15723 Crash in INFORMATION_SCHEMA.INNODB_SYS_TABLES when accessing corrupted record dict_load_table_low(): When flagging an error, assign *table = NULL. Failure to do so could cause a crash if an error was flagged when accessing INFORMATION_SCHEMA.INNODB_SYS_TABLES. --- storage/xtradb/dict/dict0load.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc index 6cbd0a3d488..e7a072d6d55 100644 --- a/storage/xtradb/dict/dict0load.cc +++ b/storage/xtradb/dict/dict0load.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, 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 @@ -2059,10 +2059,12 @@ dict_load_table_low( ulint flags2; if (rec_get_deleted_flag(rec, 0)) { + *table = NULL; return("delete-marked record in SYS_TABLES"); } if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_TABLES) { + *table = NULL; return("wrong number of columns in SYS_TABLES record"); } @@ -2070,6 +2072,7 @@ dict_load_table_low( rec, DICT_FLD__SYS_TABLES__NAME, &len); if (len == 0 || len == UNIV_SQL_NULL) { err_len: + *table = NULL; return("incorrect column length in SYS_TABLES"); } rec_get_nth_field_offs_old( @@ -2149,6 +2152,7 @@ err_len: "InnoDB: in InnoDB data dictionary" " has unknown type %lx.\n", (ulong) flags); + *table = NULL; return("incorrect flags in SYS_TABLES"); } -- cgit v1.2.1 From 6b84fdb2f32e52299809c0bb771dfeefdb17be03 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 24 Apr 2018 16:17:43 +0200 Subject: 5.6.39-83.1 --- storage/xtradb/CMakeLists.txt | 4 ++- storage/xtradb/dict/dict0dict.cc | 66 ++++++++++++++++++++----------------- storage/xtradb/dict/dict0mem.cc | 13 ++++++-- storage/xtradb/fts/fts0fts.cc | 14 ++++++-- storage/xtradb/fts/fts0que.cc | 17 +++++++--- storage/xtradb/handler/ha_innodb.cc | 8 +++++ storage/xtradb/include/univ.i | 2 +- storage/xtradb/include/ut0ut.h | 11 ++++++- storage/xtradb/row/row0sel.cc | 2 +- storage/xtradb/trx/trx0purge.cc | 15 ++++++--- storage/xtradb/ut/ut0ut.cc | 30 +++++++++++++++-- 11 files changed, 131 insertions(+), 51 deletions(-) (limited to 'storage/xtradb') diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index 927d060d6c3..4284c3a0753 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -452,3 +452,5 @@ MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE DEFAULT MODULE_OUTPUT_NAME ha_innodb LINK_LIBRARIES ${ZLIB_LIBRARY}) + +ADD_DEPENDENCIES(innobase GenError) diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc index eec681c4005..816c6f913a4 100644 --- a/storage/xtradb/dict/dict0dict.cc +++ b/storage/xtradb/dict/dict0dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -556,6 +556,8 @@ dict_table_close( indexes after an aborted online index creation */ { + + ibool drop_aborted; if (!dict_locked) { mutex_enter(&dict_sys->mutex); } @@ -563,6 +565,11 @@ dict_table_close( ut_ad(mutex_own(&dict_sys->mutex)); ut_a(table->n_ref_count > 0); + drop_aborted = try_drop + && table->drop_aborted + && table->n_ref_count == 1 + && dict_table_get_first_index(table); + --table->n_ref_count; /* Force persistent stats re-read upon next open of the table @@ -591,12 +598,6 @@ dict_table_close( if (!dict_locked) { table_id_t table_id = table->id; - ibool drop_aborted; - - drop_aborted = try_drop - && table->drop_aborted - && table->n_ref_count == 1 - && dict_table_get_first_index(table); mutex_exit(&dict_sys->mutex); @@ -2063,6 +2064,33 @@ dict_table_remove_from_cache_low( foreign->referenced_index = NULL; } + /* The check for dropped index should happen before we release + all the indexes */ + + if (lru_evict && table->drop_aborted) { + /* Do as dict_table_try_drop_aborted() does. */ + + trx_t* trx = trx_allocate_for_background(); + + ut_ad(mutex_own(&dict_sys->mutex)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); +#endif /* UNIV_SYNC_DEBUG */ + /* Mimic row_mysql_lock_data_dictionary(). */ + trx->dict_operation_lock_mode = RW_X_LATCH; + + trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); + + /* Silence a debug assertion in row_merge_drop_indexes(). */ + ut_d(table->n_ref_count++); + row_merge_drop_indexes(trx, table, TRUE); + ut_d(table->n_ref_count--); + ut_ad(table->n_ref_count == 0); + trx_commit_for_mysql(trx); + trx->dict_operation_lock_mode = 0; + trx_free_for_background(trx); + } + /* Remove the indexes from the cache */ for (index = UT_LIST_GET_LAST(table->indexes); @@ -2095,30 +2123,6 @@ dict_table_remove_from_cache_low( dict_table_autoinc_store(table); } - if (lru_evict && table->drop_aborted) { - /* Do as dict_table_try_drop_aborted() does. */ - - trx_t* trx = trx_allocate_for_background(); - - ut_ad(mutex_own(&dict_sys->mutex)); -#ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); -#endif /* UNIV_SYNC_DEBUG */ - /* Mimic row_mysql_lock_data_dictionary(). */ - trx->dict_operation_lock_mode = RW_X_LATCH; - - trx_set_dict_operation(trx, TRX_DICT_OP_INDEX); - - /* Silence a debug assertion in row_merge_drop_indexes(). */ - ut_d(table->n_ref_count++); - row_merge_drop_indexes(trx, table, TRUE); - ut_d(table->n_ref_count--); - ut_ad(table->n_ref_count == 0); - trx_commit_for_mysql(trx); - trx->dict_operation_lock_mode = 0; - trx_free_for_background(trx); - } - size = mem_heap_get_size(table->heap) + strlen(table->name) + 1; ut_ad(dict_sys->size >= size); diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index 24a9e00412a..79d493ed65b 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -303,11 +303,20 @@ dict_mem_table_col_rename_low( char* col_names; if (to_len > from_len) { + ulint table_size_before_rename_col + = mem_heap_get_size(table->heap); col_names = static_cast( mem_heap_alloc( table->heap, full_len + to_len - from_len)); - + ulint table_size_after_rename_col + = mem_heap_get_size(table->heap); + if (table_size_before_rename_col + != table_size_after_rename_col) { + dict_sys->size += + table_size_after_rename_col + - table_size_before_rename_col; + } memcpy(col_names, table->col_names, prefix_len); } else { col_names = const_cast(table->col_names); diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index a29e046eb84..f3fa6e52d0d 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -4804,9 +4804,17 @@ fts_process_token( t_str.f_str = static_cast( mem_heap_alloc(heap, t_str.f_len)); - newlen = innobase_fts_casedn_str( - doc->charset, (char*) str.f_str, str.f_len, - (char*) t_str.f_str, t_str.f_len); + /* For binary collations, a case sensitive search is + performed. Hence don't convert to lower case. */ + if (my_binary_compare(result_doc->charset)) { + memcpy(t_str.f_str, str.f_str, str.f_len); + t_str.f_str[str.f_len]= 0; + newlen= str.f_len; + } else { + newlen = innobase_fts_casedn_str( + doc->charset, (char*) str.f_str, str.f_len, + (char*) t_str.f_str, t_str.f_len); + } t_str.f_len = newlen; t_str.f_str[newlen] = 0; diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index 84f616b7800..18cf41d4a48 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -3784,10 +3784,19 @@ fts_query_str_preprocess( str_len = query_len * charset->casedn_multiply + 1; str_ptr = static_cast(ut_malloc(str_len)); - *result_len = innobase_fts_casedn_str( - charset, const_cast(reinterpret_cast( - query_str)), query_len, - reinterpret_cast(str_ptr), str_len); + /* For binary collations, a case sensitive search is + performed. Hence don't convert to lower case. */ + if (my_binary_compare(charset)) { + memcpy(str_ptr, query_str, query_len); + str_ptr[query_len]= 0; + *result_len= query_len; + } else { + *result_len = innobase_fts_casedn_str( + charset, const_cast + (reinterpret_cast( query_str)), + query_len, + reinterpret_cast(str_ptr), str_len); + } ut_ad(*result_len < str_len); diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 7b695fd4c5a..7b6d4243ba8 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -4071,6 +4071,14 @@ innobase_change_buffering_inited_ok: /* Turn on monitor counters that are default on */ srv_mon_default_on(); +#ifndef UNIV_HOTBACKUP +#ifdef _WIN32 + if (ut_win_init_time()) { + goto mem_free_and_error; + } +#endif /* _WIN32 */ +#endif /* !UNIV_HOTBACKUP */ + DBUG_RETURN(FALSE); error: DBUG_RETURN(TRUE); diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index ce2de004dd4..8eb3e6ef9bc 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -47,7 +47,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_BUGFIX MYSQL_VERSION_PATCH #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 83.0 +#define PERCONA_INNODB_VERSION 83.1 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h index ef887ed5e58..7c28081dd70 100644 --- a/storage/xtradb/include/ut0ut.h +++ b/storage/xtradb/include/ut0ut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -266,6 +266,15 @@ UNIV_INTERN ulint ut_time_ms(void); /*============*/ +#ifdef _WIN32 +/**********************************************************//** +Initialise highest available time resolution API on Windows +@return 0 if all OK else -1 */ +int +ut_win_init_time(); + +#endif /* _WIN32 */ + #endif /* !UNIV_HOTBACKUP */ /**********************************************************//** diff --git a/storage/xtradb/row/row0sel.cc b/storage/xtradb/row/row0sel.cc index 060c12e7e2e..3e79d00b07c 100644 --- a/storage/xtradb/row/row0sel.cc +++ b/storage/xtradb/row/row0sel.cc @@ -2821,7 +2821,7 @@ row_sel_store_mysql_field_func( { const byte* data; ulint len; - ulint clust_field_no; + ulint clust_field_no = 0; bool clust_templ_for_sec = (sec_field_no != ULINT_UNDEFINED); ut_ad(prebuilt->default_rec); diff --git a/storage/xtradb/trx/trx0purge.cc b/storage/xtradb/trx/trx0purge.cc index d0d7ef2432e..9073bb02d4c 100644 --- a/storage/xtradb/trx/trx0purge.cc +++ b/storage/xtradb/trx/trx0purge.cc @@ -583,6 +583,7 @@ trx_purge_rseg_get_next_history_log( mutex_exit(&(rseg->mutex)); mtr_commit(&mtr); +#ifdef UNIV_DEBUG mutex_enter(&trx_sys->mutex); /* Add debug code to track history list corruption reported @@ -599,15 +600,19 @@ trx_purge_rseg_get_next_history_log( " InnoDB: Warning: purge reached the" " head of the history list,\n" "InnoDB: but its length is still" - " reported as %lu! Make a detailed bug\n" - "InnoDB: report, and submit it" - " to http://bugs.mysql.com\n", + " reported as %lu!.\n" + "This can happen for multiple reasons\n" + "1. A long running transaction is" + " withholding purging of undo logs or a read" + " view is open. Please try to commit the long" + " running transaction.\n" + "2. Try increasing the number of purge" + " threads to expedite purging of undo logs.", (ulong) trx_sys->rseg_history_len); - ut_ad(0); } mutex_exit(&trx_sys->mutex); - +#endif return; } diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc index 597cbdf42c6..f9f39cb1269 100644 --- a/storage/xtradb/ut/ut0ut.cc +++ b/storage/xtradb/ut/ut0ut.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. 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 @@ -49,6 +49,10 @@ Created 5/11/1994 Heikki Tuuri UNIV_INTERN ibool ut_always_false = FALSE; #ifdef __WIN__ +#include /* For sql_print_error */ +typedef VOID(WINAPI *time_fn)(LPFILETIME); +static time_fn ut_get_system_time_as_file_time = GetSystemTimeAsFileTime; + /*****************************************************************//** NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix epoch starts from 1970/1/1. For selection of constant see: @@ -56,6 +60,28 @@ http://support.microsoft.com/kb/167296/ */ #define WIN_TO_UNIX_DELTA_USEC ((ib_int64_t) 11644473600000000ULL) +/** +Initialise highest available time resolution API on Windows +@return 0 if all OK else -1 */ +int +ut_win_init_time() +{ + HMODULE h = LoadLibrary("kernel32.dll"); + if (h != NULL) + { + time_fn pfn = (time_fn)GetProcAddress(h, "GetSystemTimePreciseAsFileTime"); + if (pfn != NULL) + { + ut_get_system_time_as_file_time = pfn; + } + return false; + } + DWORD error = GetLastError(); + sql_print_error( + "LoadLibrary(\"kernel32.dll\") failed: GetLastError returns %lu", error); + return(-1); +} + /*****************************************************************//** This is the Windows version of gettimeofday(2). @return 0 if all OK else -1 */ @@ -74,7 +100,7 @@ ut_gettimeofday( return(-1); } - GetSystemTimeAsFileTime(&ft); + ut_get_system_time_as_file_time(&ft); tm = (ib_int64_t) ft.dwHighDateTime << 32; tm |= ft.dwLowDateTime; -- cgit v1.2.1