diff options
author | Michael Widenius <monty@askmonty.org> | 2012-08-01 17:27:34 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-08-01 17:27:34 +0300 |
commit | 1d0f70c2f894b27e98773a282871d32802f67964 (patch) | |
tree | 833e683e0ced29c4323c29a9d845703d4dfcd81b /storage/innobase/mtr | |
parent | 5a86a61219826aadf8d08cbc447fe438f2bf50c3 (diff) | |
download | mariadb-git-1d0f70c2f894b27e98773a282871d32802f67964.tar.gz |
Temporary commit of merge of MariaDB 10.0-base and MySQL 5.6
Diffstat (limited to 'storage/innobase/mtr')
-rw-r--r-- | storage/innobase/mtr/mtr0log.cc (renamed from storage/innobase/mtr/mtr0log.c) | 22 | ||||
-rw-r--r-- | storage/innobase/mtr/mtr0mtr.cc (renamed from storage/innobase/mtr/mtr0mtr.c) | 66 |
2 files changed, 61 insertions, 27 deletions
diff --git a/storage/innobase/mtr/mtr0log.c b/storage/innobase/mtr/mtr0log.cc index 864970cef40..d549de8802e 100644 --- a/storage/innobase/mtr/mtr0log.c +++ b/storage/innobase/mtr/mtr0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2011, 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 @@ -11,13 +11,13 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ /**************************************************//** -@file mtr/mtr0log.c +@file mtr/mtr0log.cc Mini-transaction log routines Created 12/7/1995 Heikki Tuuri @@ -175,7 +175,7 @@ mlog_parse_nbytes( } if (page) { - if (UNIV_LIKELY_NULL(page_zip)) { + if (page_zip) { mach_write_to_8 (((page_zip_des_t*) page_zip)->data + offset, dval); @@ -199,7 +199,7 @@ mlog_parse_nbytes( goto corrupt; } if (page) { - if (UNIV_LIKELY_NULL(page_zip)) { + if (page_zip) { mach_write_to_1 (((page_zip_des_t*) page_zip)->data + offset, val); @@ -212,7 +212,7 @@ mlog_parse_nbytes( goto corrupt; } if (page) { - if (UNIV_LIKELY_NULL(page_zip)) { + if (page_zip) { mach_write_to_2 (((page_zip_des_t*) page_zip)->data + offset, val); @@ -222,7 +222,7 @@ mlog_parse_nbytes( break; case MLOG_4BYTES: if (page) { - if (UNIV_LIKELY_NULL(page_zip)) { + if (page_zip) { mach_write_to_4 (((page_zip_des_t*) page_zip)->data + offset, val); @@ -420,7 +420,7 @@ mlog_parse_string( } if (page) { - if (UNIV_LIKELY_NULL(page_zip)) { + if (page_zip) { memcpy(((page_zip_des_t*) page_zip)->data + offset, ptr, len); } @@ -538,7 +538,7 @@ mlog_parse_index( /*=============*/ byte* ptr, /*!< in: buffer */ const byte* end_ptr,/*!< in: buffer end */ - ibool comp, /*!< in: TRUE=compact record format */ + ibool comp, /*!< in: TRUE=compact row format */ dict_index_t** index) /*!< out, own: dummy index */ { ulint i, n, n_uniq; @@ -563,7 +563,7 @@ mlog_parse_index( n = n_uniq = 1; } table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n, - comp ? DICT_TF_COMPACT : 0); + comp ? DICT_TF_COMPACT : 0, 0); ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY", DICT_HDR_SPACE, 0, n); ind->table = table; diff --git a/storage/innobase/mtr/mtr0mtr.c b/storage/innobase/mtr/mtr0mtr.cc index d852ed6f496..4832e8c7710 100644 --- a/storage/innobase/mtr/mtr0mtr.c +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -17,7 +17,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ /**************************************************//** -@file mtr/mtr0mtr.c +@file mtr/mtr0mtr.cc Mini-transaction buffer Created 11/26/1995 Heikki Tuuri @@ -37,6 +37,25 @@ Created 11/26/1995 Heikki Tuuri #ifndef UNIV_HOTBACKUP # include "log0recv.h" + +/***************************************************//** +Checks if a mini-transaction is dirtying a clean page. +@return TRUE if the mtr is dirtying a clean page. */ +UNIV_INTERN +ibool +mtr_block_dirtied( +/*==============*/ + const buf_block_t* block) /*!< in: block being x-fixed */ +{ + ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); + ut_ad(block->page.buf_fix_count > 0); + + /* It is OK to read oldest_modification because no + other thread can be performing a write of it and it + is only during write that the value is reset to 0. */ + return(block->page.oldest_modification == 0); +} + /*****************************************************************//** Releases the item in the slot given. */ static @@ -52,6 +71,10 @@ mtr_memo_slot_release( ut_ad(mtr); ut_ad(slot); + /* slot release is a local operation for the current mtr. + We must not be holding the flush_order mutex while + doing this. */ + ut_ad(!log_flush_order_mutex_own()); #ifndef UNIV_DEBUG UT_NOT_USED(mtr); #endif /* UNIV_DEBUG */ @@ -61,9 +84,9 @@ mtr_memo_slot_release( if (UNIV_LIKELY(object != NULL)) { if (type <= MTR_MEMO_BUF_FIX) { - buf_page_release((buf_block_t*)object, type); + buf_page_release((buf_block_t*) object, type); } else if (type == MTR_MEMO_S_LOCK) { - rw_lock_s_unlock((rw_lock_t*)object); + rw_lock_s_unlock((rw_lock_t*) object); #ifdef UNIV_DEBUG } else if (type != MTR_MEMO_X_LOCK) { ut_ad(type == MTR_MEMO_MODIFY); @@ -71,7 +94,7 @@ mtr_memo_slot_release( MTR_MEMO_PAGE_X_FIX)); #endif /* UNIV_DEBUG */ } else { - rw_lock_x_unlock((rw_lock_t*)object); + rw_lock_x_unlock((rw_lock_t*) object); } } @@ -102,7 +125,9 @@ mtr_memo_pop_all( while (offset > 0) { offset -= sizeof(mtr_memo_slot_t); - slot = dyn_array_get_element(memo, offset); + + slot = static_cast<mtr_memo_slot_t*>( + dyn_array_get_element(memo, offset)); mtr_memo_slot_release(mtr, slot); } @@ -124,9 +149,7 @@ mtr_memo_slot_note_modification( if (slot->object != NULL && slot->type == MTR_MEMO_PAGE_X_FIX) { buf_block_t* block = (buf_block_t*) slot->object; -#ifdef UNIV_DEBUG - ut_ad(log_flush_order_mutex_own()); -#endif /* UNIV_DEBUG */ + ut_ad(!mtr->made_dirty || log_flush_order_mutex_own()); buf_flush_note_modification(block, mtr); } } @@ -159,7 +182,9 @@ mtr_memo_note_modifications( mtr_memo_slot_t* slot; offset -= sizeof(mtr_memo_slot_t); - slot = dyn_array_get_element(memo, offset); + + slot = static_cast<mtr_memo_slot_t*>( + dyn_array_get_element(memo, offset)); mtr_memo_slot_note_modification(mtr, slot); } @@ -225,7 +250,15 @@ mtr_log_reserve_and_write( mtr->end_lsn = log_close(); func_exit: - log_flush_order_mutex_enter(); + + /* No need to acquire log_flush_order_mutex if this mtr has + not dirtied a clean page. log_flush_order_mutex is used to + ensure ordered insertions in the flush_list. We need to + insert in the flush_list iff the page in question was clean + before modifications. */ + if (mtr->made_dirty) { + log_flush_order_mutex_enter(); + } /* It is now safe to release the log mutex because the flush_order mutex will ensure that we are the first one @@ -236,7 +269,9 @@ func_exit: mtr_memo_note_modifications(mtr); } - log_flush_order_mutex_exit(); + if (mtr->made_dirty) { + log_flush_order_mutex_exit(); + } } #endif /* !UNIV_HOTBACKUP */ @@ -271,8 +306,8 @@ mtr_commit( /* Declare everything uninitialized except mtr->start_lsn, mtr->end_lsn and mtr->state. */ { - ib_uint64_t start_lsn = mtr->start_lsn; - ib_uint64_t end_lsn = mtr->end_lsn; + lsn_t start_lsn = mtr->start_lsn; + lsn_t end_lsn = mtr->end_lsn; UNIV_MEM_INVALID(mtr, sizeof *mtr); mtr->start_lsn = start_lsn; mtr->end_lsn = end_lsn; @@ -304,11 +339,11 @@ mtr_memo_release( offset = dyn_array_get_data_size(memo); - log_flush_order_mutex_enter(); while (offset > 0) { offset -= sizeof(mtr_memo_slot_t); - slot = dyn_array_get_element(memo, offset); + slot = static_cast<mtr_memo_slot_t*>( + dyn_array_get_element(memo, offset)); if (object == slot->object && type == slot->type) { @@ -323,7 +358,6 @@ mtr_memo_release( break; } } - log_flush_order_mutex_exit(); } #endif /* !UNIV_HOTBACKUP */ |