MDEV-12353 preparation: Replace mtr_x_lock() and friends
Apart from page latches (buf_block_t::lock), mini-transactions are keeping track of at most one dict_index_t::lock and fil_space_t::latch at a time, and in a rare case, purge_sys.latch. Let us introduce interfaces for acquiring an index latch or a tablespace latch. In a later version, we may want to introduce mtr_t members for holding a latched dict_index_t* and fil_space_t*, and replace the remaining use of mtr_t::m_memo with std::set<buf_block_t*> or with a map<buf_block_t*,byte*> pointing to log records.
This commit is contained in:
parent
4ded5fb9ac
commit
3d4a801533
@ -4727,13 +4727,13 @@ btr_validate_level(
|
||||
ulint parent_right_page_no = FIL_NULL;
|
||||
bool rightmost_child = false;
|
||||
|
||||
mtr_start(&mtr);
|
||||
mtr.start();
|
||||
|
||||
if (!srv_read_only_mode) {
|
||||
if (lockout) {
|
||||
mtr_x_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_x_lock_index(index, &mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4822,9 +4822,9 @@ loop:
|
||||
offsets = offsets2 = NULL;
|
||||
if (!srv_read_only_mode) {
|
||||
if (lockout) {
|
||||
mtr_x_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_x_lock_index(index, &mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5122,13 +5122,13 @@ node_ptr_fails:
|
||||
/* Commit the mini-transaction to release the latch on 'page'.
|
||||
Re-acquire the latch on right_page, which will become 'page'
|
||||
on the next loop. The page has already been checked. */
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
if (trx_is_interrupted(trx)) {
|
||||
/* On interrupt, return the current status. */
|
||||
} else if (right_page_no != FIL_NULL) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
mtr.start();
|
||||
|
||||
if (!lockout) {
|
||||
if (rightmost_child) {
|
||||
@ -5178,9 +5178,9 @@ btr_validate_spatial_index(
|
||||
mtr_t mtr;
|
||||
bool ok = true;
|
||||
|
||||
mtr_start(&mtr);
|
||||
mtr.start();
|
||||
|
||||
mtr_x_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_x_lock_index(index, &mtr);
|
||||
|
||||
page_t* root = btr_root_get(index, &mtr);
|
||||
ulint n = btr_page_get_level(root);
|
||||
@ -5200,7 +5200,7 @@ btr_validate_spatial_index(
|
||||
}
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
return(ok);
|
||||
}
|
||||
@ -5236,9 +5236,9 @@ btr_validate_index(
|
||||
|
||||
if (!srv_read_only_mode) {
|
||||
if (lockout) {
|
||||
mtr_x_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_x_lock_index(index, &mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ BtrBulk::finish(dberr_t err)
|
||||
|
||||
mtr.start();
|
||||
m_index->set_modified(mtr);
|
||||
mtr_x_lock(&m_index->lock, &mtr);
|
||||
mtr_x_lock_index(m_index, &mtr);
|
||||
|
||||
ut_ad(last_page_no != FIL_NULL);
|
||||
last_block = btr_block_get(
|
||||
|
@ -1316,16 +1316,16 @@ btr_cur_search_to_nth_level_func(
|
||||
if (lock_intention == BTR_INTENTION_DELETE
|
||||
&& trx_sys.history_size() > BTR_CUR_FINE_HISTORY_LENGTH
|
||||
&& buf_get_n_pending_read_ios()) {
|
||||
mtr_x_lock(dict_index_get_lock(index), mtr);
|
||||
} else if (dict_index_is_spatial(index)
|
||||
x_latch_index:
|
||||
mtr_x_lock_index(index, mtr);
|
||||
} else if (index->is_spatial()
|
||||
&& lock_intention <= BTR_INTENTION_BOTH) {
|
||||
/* X lock the if there is possibility of
|
||||
pessimistic delete on spatial index. As we could
|
||||
lock upward for the tree */
|
||||
|
||||
mtr_x_lock(dict_index_get_lock(index), mtr);
|
||||
goto x_latch_index;
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_sx_lock_index(index, mtr);
|
||||
}
|
||||
upper_rw_latch = RW_X_LATCH;
|
||||
break;
|
||||
@ -1357,10 +1357,10 @@ btr_cur_search_to_nth_level_func(
|
||||
BTR_ALREADY_S_LATCHED */
|
||||
ut_ad(latch_mode != BTR_SEARCH_TREE);
|
||||
|
||||
mtr_s_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_s_lock_index(index, mtr);
|
||||
} else {
|
||||
/* BTR_MODIFY_EXTERNAL needs to be excluded */
|
||||
mtr_sx_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_sx_lock_index(index, mtr);
|
||||
}
|
||||
upper_rw_latch = RW_S_LATCH;
|
||||
} else {
|
||||
@ -2450,9 +2450,9 @@ btr_cur_open_at_index_side_func(
|
||||
if (lock_intention == BTR_INTENTION_DELETE
|
||||
&& trx_sys.history_size() > BTR_CUR_FINE_HISTORY_LENGTH
|
||||
&& buf_get_n_pending_read_ios()) {
|
||||
mtr_x_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_x_lock_index(index, mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_sx_lock_index(index, mtr);
|
||||
}
|
||||
upper_rw_latch = RW_X_LATCH;
|
||||
break;
|
||||
@ -2468,7 +2468,7 @@ btr_cur_open_at_index_side_func(
|
||||
BTR_ALREADY_S_LATCHED */
|
||||
ut_ad(latch_mode != BTR_SEARCH_TREE);
|
||||
|
||||
mtr_s_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_s_lock_index(index, mtr);
|
||||
}
|
||||
upper_rw_latch = RW_S_LATCH;
|
||||
} else {
|
||||
@ -2779,7 +2779,7 @@ btr_cur_open_at_rnd_pos_func(
|
||||
ulint* offsets = offsets_;
|
||||
rec_offs_init(offsets_);
|
||||
|
||||
ut_ad(!dict_index_is_spatial(index));
|
||||
ut_ad(!index->is_spatial());
|
||||
|
||||
lock_intention = btr_cur_get_and_clear_intention(&latch_mode);
|
||||
|
||||
@ -2795,9 +2795,9 @@ btr_cur_open_at_rnd_pos_func(
|
||||
if (lock_intention == BTR_INTENTION_DELETE
|
||||
&& trx_sys.history_size() > BTR_CUR_FINE_HISTORY_LENGTH
|
||||
&& buf_get_n_pending_read_ios()) {
|
||||
mtr_x_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_x_lock_index(index, mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_sx_lock_index(index, mtr);
|
||||
}
|
||||
upper_rw_latch = RW_X_LATCH;
|
||||
break;
|
||||
@ -2813,7 +2813,7 @@ btr_cur_open_at_rnd_pos_func(
|
||||
/* fall through */
|
||||
default:
|
||||
if (!srv_read_only_mode) {
|
||||
mtr_s_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_s_lock_index(index, mtr);
|
||||
upper_rw_latch = RW_S_LATCH;
|
||||
} else {
|
||||
upper_rw_latch = RW_NO_LATCH;
|
||||
@ -4892,7 +4892,7 @@ btr_cur_pessimistic_update(
|
||||
MTR_MEMO_X_LOCK |
|
||||
MTR_MEMO_SX_LOCK));
|
||||
|
||||
mtr_sx_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_sx_lock_index(index, mtr);
|
||||
}
|
||||
|
||||
/* Was the record to be updated positioned as the first user
|
||||
|
@ -751,7 +751,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
|
||||
index->set_modified(mtr);
|
||||
/* To follow the latching order defined in WL#6326, acquire index->lock X-latch.
|
||||
This entitles us to acquire page latches in any order for the index. */
|
||||
mtr_x_lock(&index->lock, &mtr);
|
||||
mtr_x_lock_index(index, &mtr);
|
||||
/* This will acquire index->lock SX-latch, which per WL#6363 is allowed
|
||||
when we are already holding the X-latch. */
|
||||
btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, &mtr);
|
||||
|
@ -742,7 +742,7 @@ btr_scrub_recheck_page(
|
||||
}
|
||||
|
||||
mtr_start(mtr);
|
||||
mtr_x_lock(dict_index_get_lock(scrub_data->current_index), mtr);
|
||||
mtr_x_lock_index(scrub_data->current_index, mtr);
|
||||
/** set savepoint for X-latch of block */
|
||||
scrub_data->savepoint = mtr_set_savepoint(mtr);
|
||||
return BTR_SCRUB_PAGE;
|
||||
|
@ -281,11 +281,11 @@ dict_stats_save_defrag_stats(
|
||||
mtr_t mtr;
|
||||
ulint n_leaf_pages;
|
||||
ulint n_leaf_reserved;
|
||||
mtr_start(&mtr);
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr.start();
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
n_leaf_reserved = btr_get_size_and_reserved(index, BTR_N_LEAF_PAGES,
|
||||
&n_leaf_pages, &mtr);
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
if (n_leaf_reserved == ULINT_UNDEFINED) {
|
||||
// The index name is different during fast index creation,
|
||||
|
@ -854,10 +854,8 @@ dict_stats_update_transient_for_index(
|
||||
mtr_t mtr;
|
||||
ulint size;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
|
||||
mtr.start();
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
size = btr_get_size(index, BTR_TOTAL_SIZE, &mtr);
|
||||
|
||||
if (size != ULINT_UNDEFINED) {
|
||||
@ -867,7 +865,7 @@ dict_stats_update_transient_for_index(
|
||||
index, BTR_N_LEAF_PAGES, &mtr);
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
switch (size) {
|
||||
case ULINT_UNDEFINED:
|
||||
@ -1929,10 +1927,8 @@ dict_stats_analyze_index(
|
||||
|
||||
dict_stats_empty_index(index, false);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
|
||||
mtr.start();
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
size = btr_get_size(index, BTR_TOTAL_SIZE, &mtr);
|
||||
|
||||
if (size != ULINT_UNDEFINED) {
|
||||
@ -1941,7 +1937,7 @@ dict_stats_analyze_index(
|
||||
}
|
||||
|
||||
/* Release the X locks on the root page taken by btr_get_size() */
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
switch (size) {
|
||||
case ULINT_UNDEFINED:
|
||||
@ -1954,10 +1950,8 @@ dict_stats_analyze_index(
|
||||
|
||||
index->stat_n_leaf_pages = size;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
|
||||
mtr.start();
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
root_level = btr_height_get(index, &mtr);
|
||||
|
||||
n_uniq = dict_index_get_n_unique(index);
|
||||
@ -1997,7 +1991,7 @@ dict_stats_analyze_index(
|
||||
index->stat_n_sample_sizes[i] = total_pages;
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
dict_stats_assert_initialized_index(index);
|
||||
DBUG_VOID_RETURN;
|
||||
@ -2043,9 +2037,9 @@ dict_stats_analyze_index(
|
||||
|
||||
/* Commit the mtr to release the tree S lock to allow
|
||||
other threads to do some work too. */
|
||||
mtr_commit(&mtr);
|
||||
mtr_start(&mtr);
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr.commit();
|
||||
mtr.start();
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
if (root_level != btr_height_get(index, &mtr)) {
|
||||
/* Just quit if the tree has changed beyond
|
||||
recognition here. The old stats from previous
|
||||
@ -2183,7 +2177,7 @@ found_level:
|
||||
data, &mtr);
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
UT_DELETE_ARRAY(n_diff_boundaries);
|
||||
|
||||
|
@ -657,7 +657,7 @@ void fsp_header_init(fil_space_t* space, ulint size, mtr_t* mtr)
|
||||
const page_id_t page_id(space->id, 0);
|
||||
const page_size_t page_size(space->flags);
|
||||
|
||||
mtr_x_lock(&space->latch, mtr);
|
||||
mtr_x_lock_space(space, mtr);
|
||||
buf_block_t* block = buf_page_create(page_id, page_size, mtr);
|
||||
buf_page_get(page_id, page_size, RW_SX_LATCH, mtr);
|
||||
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
||||
@ -1944,7 +1944,7 @@ fseg_create(
|
||||
ut_ad(byte_offset + FSEG_HEADER_SIZE
|
||||
<= srv_page_size - FIL_PAGE_DATA_END);
|
||||
|
||||
mtr_x_lock(&space->latch, mtr);
|
||||
mtr_x_lock_space(space, mtr);
|
||||
const page_size_t page_size(space->flags);
|
||||
ut_d(space->modify_check(*mtr));
|
||||
|
||||
@ -2649,7 +2649,7 @@ fsp_reserve_free_extents(
|
||||
ut_ad(mtr);
|
||||
*n_reserved = n_ext;
|
||||
|
||||
mtr_x_lock(&space->latch, mtr);
|
||||
mtr_x_lock_space(space, mtr);
|
||||
const page_size_t page_size(space->flags);
|
||||
|
||||
space_header = fsp_get_space_header(space, page_size, mtr);
|
||||
@ -2940,7 +2940,7 @@ fseg_free_page_func(
|
||||
DBUG_ENTER("fseg_free_page");
|
||||
fseg_inode_t* seg_inode;
|
||||
buf_block_t* iblock;
|
||||
mtr_x_lock(&space->latch, mtr);
|
||||
mtr_x_lock_space(space, mtr);
|
||||
const page_size_t page_size(space->flags);
|
||||
|
||||
DBUG_LOG("fseg_free_page", "space_id: " << space->id
|
||||
@ -2970,7 +2970,7 @@ fseg_page_is_free(fil_space_t* space, unsigned page)
|
||||
page_no_t dpage = xdes_calc_descriptor_page(page_size, page);
|
||||
|
||||
mtr.start();
|
||||
mtr_s_lock(&space->latch, &mtr);
|
||||
mtr_s_lock_space(space, &mtr);
|
||||
|
||||
if (page >= space->free_limit || page >= space->size_in_header) {
|
||||
is_free = true;
|
||||
|
@ -1846,7 +1846,7 @@ rtr_estimate_n_rows_in_range(
|
||||
|
||||
mtr.start();
|
||||
index->set_modified(mtr);
|
||||
mtr_s_lock(&index->lock, &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
|
||||
buf_block_t* block = btr_block_get(
|
||||
page_id_t(index->table->space_id, index->page),
|
||||
|
@ -137,7 +137,7 @@ rtr_pcur_getnext_from_path(
|
||||
if (!index_locked) {
|
||||
ut_ad(latch_mode & BTR_SEARCH_LEAF
|
||||
|| latch_mode & BTR_MODIFY_LEAF);
|
||||
mtr_s_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_s_lock_index(index, mtr);
|
||||
} else {
|
||||
ut_ad(mtr_memo_contains_flagged(mtr, &index->lock,
|
||||
MTR_MEMO_SX_LOCK
|
||||
|
@ -361,7 +361,7 @@ ibuf_tree_root_get(
|
||||
ut_ad(ibuf_inside(mtr));
|
||||
ut_ad(mutex_own(&ibuf_mutex));
|
||||
|
||||
mtr_sx_lock(dict_index_get_lock(ibuf->index), mtr);
|
||||
mtr_sx_lock_index(ibuf->index, mtr);
|
||||
|
||||
/* only segment list access is exclusive each other */
|
||||
block = buf_page_get(
|
||||
@ -459,7 +459,7 @@ ibuf_init_at_db_start(void)
|
||||
|
||||
compile_time_assert(IBUF_SPACE_ID == TRX_SYS_SPACE);
|
||||
compile_time_assert(IBUF_SPACE_ID == 0);
|
||||
mtr_x_lock(&fil_system.sys_space->latch, &mtr);
|
||||
mtr_x_lock_space(fil_system.sys_space, &mtr);
|
||||
|
||||
mutex_enter(&ibuf_mutex);
|
||||
|
||||
@ -1977,7 +1977,7 @@ ibuf_add_free_page(void)
|
||||
mtr_start(&mtr);
|
||||
/* Acquire the fsp latch before the ibuf header, obeying the latching
|
||||
order */
|
||||
mtr_x_lock(&fil_system.sys_space->latch, &mtr);
|
||||
mtr_x_lock_space(fil_system.sys_space, &mtr);
|
||||
header_page = ibuf_header_page_get(&mtr);
|
||||
|
||||
/* Allocate a new page: NOTE that if the page has been a part of a
|
||||
@ -2056,7 +2056,7 @@ ibuf_remove_free_page(void)
|
||||
/* Acquire the fsp latch before the ibuf header, obeying the latching
|
||||
order */
|
||||
|
||||
mtr_x_lock(&fil_system.sys_space->latch, &mtr);
|
||||
mtr_x_lock_space(fil_system.sys_space, &mtr);
|
||||
header_page = ibuf_header_page_get(&mtr);
|
||||
|
||||
/* Prevent pessimistic inserts to insert buffer trees for a while */
|
||||
|
@ -85,17 +85,12 @@ savepoint. */
|
||||
/** Push an object to an mtr memo stack. */
|
||||
#define mtr_memo_push(m, o, t) (m)->memo_push(o, t)
|
||||
|
||||
/** Lock an rw-lock in s-mode. */
|
||||
#define mtr_s_lock(l, m) (m)->s_lock((l), __FILE__, __LINE__)
|
||||
|
||||
/** Lock an rw-lock in x-mode. */
|
||||
#define mtr_x_lock(l, m) (m)->x_lock((l), __FILE__, __LINE__)
|
||||
|
||||
/** Lock a tablespace in x-mode. */
|
||||
#define mtr_s_lock_space(s, m) (m)->s_lock_space((s), __FILE__, __LINE__)
|
||||
#define mtr_x_lock_space(s, m) (m)->x_lock_space((s), __FILE__, __LINE__)
|
||||
|
||||
/** Lock an rw-lock in sx-mode. */
|
||||
#define mtr_sx_lock(l, m) (m)->sx_lock((l), __FILE__, __LINE__)
|
||||
#define mtr_s_lock_index(i, m) (m)->s_lock(&(i)->lock, __FILE__, __LINE__)
|
||||
#define mtr_x_lock_index(i, m) (m)->x_lock(&(i)->lock, __FILE__, __LINE__)
|
||||
#define mtr_sx_lock_index(i, m) (m)->sx_lock(&(i)->lock, __FILE__, __LINE__)
|
||||
|
||||
#define mtr_memo_contains_flagged(m, p, l) \
|
||||
(m)->memo_contains_flagged((p), (l))
|
||||
@ -251,29 +246,7 @@ struct mtr_t {
|
||||
inline ulint read_ulint(const byte* ptr, mlog_id_t type) const
|
||||
MY_ATTRIBUTE((warn_unused_result));
|
||||
|
||||
/** Locks a rw-latch in S mode.
|
||||
NOTE: use mtr_s_lock().
|
||||
@param lock rw-lock
|
||||
@param file file name from where called
|
||||
@param line line number in file */
|
||||
inline void s_lock(rw_lock_t* lock, const char* file, unsigned line);
|
||||
|
||||
/** Locks a rw-latch in X mode.
|
||||
NOTE: use mtr_x_lock().
|
||||
@param lock rw-lock
|
||||
@param file file name from where called
|
||||
@param line line number in file */
|
||||
inline void x_lock(rw_lock_t* lock, const char* file, unsigned line);
|
||||
|
||||
/** Locks a rw-latch in X mode.
|
||||
NOTE: use mtr_sx_lock().
|
||||
@param lock rw-lock
|
||||
@param file file name from where called
|
||||
@param line line number in file */
|
||||
inline void sx_lock(rw_lock_t* lock, const char* file, unsigned line);
|
||||
|
||||
/** Acquire a tablespace X-latch.
|
||||
NOTE: use mtr_x_lock_space().
|
||||
@param[in] space_id tablespace ID
|
||||
@param[in] file file name from where called
|
||||
@param[in] line line number in file
|
||||
@ -283,6 +256,60 @@ struct mtr_t {
|
||||
const char* file,
|
||||
unsigned line);
|
||||
|
||||
/** Acquire a shared rw-latch.
|
||||
@param[in] lock rw-latch
|
||||
@param[in] file file name from where called
|
||||
@param[in] line line number in file */
|
||||
void s_lock(rw_lock_t* lock, const char* file, unsigned line)
|
||||
{
|
||||
rw_lock_s_lock_inline(lock, 0, file, line);
|
||||
memo_push(lock, MTR_MEMO_S_LOCK);
|
||||
}
|
||||
|
||||
/** Acquire an exclusive rw-latch.
|
||||
@param[in] lock rw-latch
|
||||
@param[in] file file name from where called
|
||||
@param[in] line line number in file */
|
||||
void x_lock(rw_lock_t* lock, const char* file, unsigned line)
|
||||
{
|
||||
rw_lock_x_lock_inline(lock, 0, file, line);
|
||||
memo_push(lock, MTR_MEMO_X_LOCK);
|
||||
}
|
||||
|
||||
/** Acquire an shared/exclusive rw-latch.
|
||||
@param[in] lock rw-latch
|
||||
@param[in] file file name from where called
|
||||
@param[in] line line number in file */
|
||||
void sx_lock(rw_lock_t* lock, const char* file, unsigned line)
|
||||
{
|
||||
rw_lock_sx_lock_inline(lock, 0, file, line);
|
||||
memo_push(lock, MTR_MEMO_SX_LOCK);
|
||||
}
|
||||
|
||||
/** Acquire a tablespace S-latch.
|
||||
@param[in] space tablespace
|
||||
@param[in] file file name from where called
|
||||
@param[in] line line number in file */
|
||||
void s_lock_space(fil_space_t* space, const char* file, unsigned line)
|
||||
{
|
||||
ut_ad(space->purpose == FIL_TYPE_TEMPORARY
|
||||
|| space->purpose == FIL_TYPE_IMPORT
|
||||
|| space->purpose == FIL_TYPE_TABLESPACE);
|
||||
s_lock(&space->latch, file, line);
|
||||
}
|
||||
|
||||
/** Acquire a tablespace X-latch.
|
||||
@param[in] space tablespace
|
||||
@param[in] file file name from where called
|
||||
@param[in] line line number in file */
|
||||
void x_lock_space(fil_space_t* space, const char* file, unsigned line)
|
||||
{
|
||||
ut_ad(space->purpose == FIL_TYPE_TEMPORARY
|
||||
|| space->purpose == FIL_TYPE_IMPORT
|
||||
|| space->purpose == FIL_TYPE_TABLESPACE);
|
||||
x_lock(&space->latch, file, line);
|
||||
}
|
||||
|
||||
/** Release an object in the memo stack.
|
||||
@param object object
|
||||
@param type object type: MTR_MEMO_S_LOCK, ...
|
||||
|
@ -228,39 +228,6 @@ mtr_t::set_log_mode(mtr_log_t mode)
|
||||
return(old_mode);
|
||||
}
|
||||
|
||||
/**
|
||||
Locks a lock in s-mode. */
|
||||
|
||||
void
|
||||
mtr_t::s_lock(rw_lock_t* lock, const char* file, unsigned line)
|
||||
{
|
||||
rw_lock_s_lock_inline(lock, 0, file, line);
|
||||
|
||||
memo_push(lock, MTR_MEMO_S_LOCK);
|
||||
}
|
||||
|
||||
/**
|
||||
Locks a lock in x-mode. */
|
||||
|
||||
void
|
||||
mtr_t::x_lock(rw_lock_t* lock, const char* file, unsigned line)
|
||||
{
|
||||
rw_lock_x_lock_inline(lock, 0, file, line);
|
||||
|
||||
memo_push(lock, MTR_MEMO_X_LOCK);
|
||||
}
|
||||
|
||||
/**
|
||||
Locks a lock in sx-mode. */
|
||||
|
||||
void
|
||||
mtr_t::sx_lock(rw_lock_t* lock, const char* file, unsigned line)
|
||||
{
|
||||
rw_lock_sx_lock_inline(lock, 0, file, line);
|
||||
|
||||
memo_push(lock, MTR_MEMO_SX_LOCK);
|
||||
}
|
||||
|
||||
/**
|
||||
Reads 1 - 4 bytes from a file page buffered in the buffer pool.
|
||||
@return value read */
|
||||
|
@ -570,10 +570,7 @@ mtr_t::x_lock_space(ulint space_id, const char* file, unsigned line)
|
||||
|
||||
ut_ad(space);
|
||||
ut_ad(space->id == space_id);
|
||||
x_lock(&space->latch, file, line);
|
||||
ut_ad(space->purpose == FIL_TYPE_TEMPORARY
|
||||
|| space->purpose == FIL_TYPE_IMPORT
|
||||
|| space->purpose == FIL_TYPE_TABLESPACE);
|
||||
x_lock_space(space, file, line);
|
||||
return(space);
|
||||
}
|
||||
|
||||
|
@ -2633,7 +2633,7 @@ row_ins_clust_index_entry_low(
|
||||
if (mode == BTR_MODIFY_LEAF
|
||||
&& dict_index_is_online_ddl(index)) {
|
||||
mode = BTR_MODIFY_LEAF_ALREADY_S_LATCHED;
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
if (unsigned ai = index->table->persistent_autoinc) {
|
||||
@ -2866,9 +2866,9 @@ row_ins_sec_mtr_start_and_check_if_aborted(
|
||||
}
|
||||
|
||||
if (search_mode & BTR_ALREADY_S_LATCHED) {
|
||||
mtr_s_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_s_lock_index(index, mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), mtr);
|
||||
mtr_sx_lock_index(index, mtr);
|
||||
}
|
||||
|
||||
switch (index->online_status) {
|
||||
@ -2954,9 +2954,9 @@ row_ins_sec_index_entry_low(
|
||||
DEBUG_SYNC_C("row_ins_sec_index_enter");
|
||||
if (mode == BTR_MODIFY_LEAF) {
|
||||
search_mode |= BTR_ALREADY_S_LATCHED;
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
} else {
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
if (row_log_online_op_try(
|
||||
|
@ -385,14 +385,14 @@ row_purge_remove_sec_if_poss_tree(
|
||||
enum row_search_result search_result;
|
||||
|
||||
log_free_check();
|
||||
mtr_start(&mtr);
|
||||
mtr.start();
|
||||
index->set_modified(mtr);
|
||||
|
||||
if (!index->is_committed()) {
|
||||
/* The index->online_status may change if the index is
|
||||
or was being created online, but not committed yet. It
|
||||
is protected by index->lock. */
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
|
||||
if (dict_index_is_online_ddl(index)) {
|
||||
/* Online secondary index creation will not
|
||||
@ -487,9 +487,9 @@ row_purge_remove_sec_if_poss_tree(
|
||||
}
|
||||
|
||||
func_exit:
|
||||
btr_pcur_close(&pcur);
|
||||
btr_pcur_close(&pcur); // FIXME: need this?
|
||||
func_exit_no_pcur:
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
|
||||
return(success);
|
||||
}
|
||||
@ -516,7 +516,7 @@ row_purge_remove_sec_if_poss_leaf(
|
||||
log_free_check();
|
||||
ut_ad(index->table == node->table);
|
||||
ut_ad(!index->table->is_temporary());
|
||||
mtr_start(&mtr);
|
||||
mtr.start();
|
||||
index->set_modified(mtr);
|
||||
|
||||
if (!index->is_committed()) {
|
||||
@ -528,7 +528,7 @@ row_purge_remove_sec_if_poss_leaf(
|
||||
/* The index->online_status may change if the the
|
||||
index is or was being created online, but not
|
||||
committed yet. It is protected by index->lock. */
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
|
||||
if (dict_index_is_online_ddl(index)) {
|
||||
/* Online secondary index creation will not
|
||||
@ -632,7 +632,7 @@ row_purge_remove_sec_if_poss_leaf(
|
||||
->page.id);
|
||||
|
||||
btr_pcur_close(&pcur);
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
return(success);
|
||||
}
|
||||
}
|
||||
@ -658,9 +658,9 @@ row_purge_remove_sec_if_poss_leaf(
|
||||
/* The deletion was buffered. */
|
||||
case ROW_NOT_FOUND:
|
||||
/* The index entry does not exist, nothing to do. */
|
||||
btr_pcur_close(&pcur);
|
||||
btr_pcur_close(&pcur); // FIXME: do we need these? when is btr_cur->rtr_info set?
|
||||
func_exit_no_pcur:
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
return(success);
|
||||
}
|
||||
|
||||
@ -950,12 +950,12 @@ skip_secondaries:
|
||||
ut_ad(rseg->id == rseg_id);
|
||||
ut_ad(rseg->is_persistent());
|
||||
|
||||
mtr_start(&mtr);
|
||||
mtr.start();
|
||||
|
||||
/* We have to acquire an SX-latch to the clustered
|
||||
index tree (exclude other tree changes) */
|
||||
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
|
||||
index->set_modified(mtr);
|
||||
|
||||
@ -986,7 +986,7 @@ skip_secondaries:
|
||||
data_field + dfield_get_len(&ufield->new_val)
|
||||
- BTR_EXTERN_FIELD_REF_SIZE,
|
||||
NULL, NULL, NULL, 0, false, &mtr);
|
||||
mtr_commit(&mtr);
|
||||
mtr.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ row_undo_ins_remove_clust_rec(
|
||||
ut_ad(node->trx->dict_operation_lock_mode
|
||||
!= RW_X_LATCH);
|
||||
ut_ad(node->table->id != DICT_INDEXES_ID);
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
success = btr_pcur_restore_position(
|
||||
@ -275,10 +275,10 @@ row_undo_ins_remove_sec_low(
|
||||
|
||||
if (modify_leaf) {
|
||||
mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED;
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
} else {
|
||||
ut_ad(mode == (BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE));
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
if (row_log_online_op_try(index, entry, 0)) {
|
||||
|
@ -187,7 +187,7 @@ static bool row_undo_mod_must_purge(undo_node_t* node, mtr_t* mtr)
|
||||
btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&node->pcur);
|
||||
ut_ad(btr_cur->index->is_primary());
|
||||
|
||||
mtr_s_lock(&purge_sys.latch, mtr);
|
||||
mtr->s_lock(&purge_sys.latch, __FILE__, __LINE__);
|
||||
|
||||
if (!purge_sys.view.changes_visible(node->new_trx_id,
|
||||
node->table->name)) {
|
||||
@ -238,7 +238,7 @@ row_undo_mod_clust(
|
||||
online = dict_index_is_online_ddl(index);
|
||||
if (online) {
|
||||
ut_ad(node->trx->dict_operation_lock_mode != RW_X_LATCH);
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
mem_heap_t* heap = mem_heap_create(1024);
|
||||
@ -393,7 +393,7 @@ row_undo_mod_clust(
|
||||
goto mtr_commit_exit;
|
||||
}
|
||||
rec_t* rec = btr_pcur_get_rec(pcur);
|
||||
mtr_s_lock(&purge_sys.latch, &mtr);
|
||||
mtr.s_lock(&purge_sys.latch, __FILE__, __LINE__);
|
||||
if (!purge_sys.view.changes_visible(node->new_trx_id,
|
||||
node->table->name)) {
|
||||
goto mtr_commit_exit;
|
||||
@ -476,10 +476,10 @@ row_undo_mod_del_mark_or_remove_sec_low(
|
||||
is protected by index->lock. */
|
||||
if (modify_leaf) {
|
||||
mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED;
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
} else {
|
||||
ut_ad(mode == (BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE));
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
if (row_log_online_op_try(index, entry, 0)) {
|
||||
@ -672,10 +672,10 @@ try_again:
|
||||
is protected by index->lock. */
|
||||
if (mode == BTR_MODIFY_LEAF) {
|
||||
mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED;
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
} else {
|
||||
ut_ad(mode == BTR_MODIFY_TREE);
|
||||
mtr_sx_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_sx_lock_index(index, &mtr);
|
||||
}
|
||||
|
||||
if (row_log_online_op_try(index, entry, trx->id)) {
|
||||
|
@ -2341,7 +2341,7 @@ row_upd_sec_index_entry(
|
||||
or was being created online, but not committed yet. It
|
||||
is protected by index->lock. */
|
||||
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
|
||||
switch (dict_index_get_online_status(index)) {
|
||||
case ONLINE_INDEX_COMPLETE:
|
||||
@ -3109,7 +3109,7 @@ row_upd_clust_step(
|
||||
if (dict_index_is_online_ddl(index)) {
|
||||
ut_ad(node->table->id != DICT_INDEXES_ID);
|
||||
mode = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED;
|
||||
mtr_s_lock(dict_index_get_lock(index), &mtr);
|
||||
mtr_s_lock_index(index, &mtr);
|
||||
} else {
|
||||
mode = BTR_MODIFY_LEAF;
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ not_found:
|
||||
mtr_t mtr;
|
||||
const ulint size = SRV_UNDO_TABLESPACE_SIZE_IN_PAGES;
|
||||
mtr.start();
|
||||
mtr_x_lock(&space->latch, &mtr);
|
||||
mtr_x_lock_space(space, &mtr);
|
||||
fil_truncate_log(space, size, &mtr);
|
||||
fsp_header_init(space, size, &mtr);
|
||||
mutex_enter(&fil_system.mutex);
|
||||
|
@ -694,7 +694,7 @@ trx_temp_rseg_create()
|
||||
for (ulong i = 0; i < TRX_SYS_N_RSEGS; i++) {
|
||||
mtr.start();
|
||||
mtr.set_log_mode(MTR_LOG_NO_REDO);
|
||||
mtr_x_lock(&fil_system.temp_space->latch, &mtr);
|
||||
mtr_x_lock_space(fil_system.temp_space, &mtr);
|
||||
|
||||
buf_block_t* rblock = trx_rseg_header_create(
|
||||
fil_system.temp_space, i, NULL, &mtr);
|
||||
|
@ -156,7 +156,7 @@ trx_sysf_create(
|
||||
then enter the kernel: we must do it in this order to conform
|
||||
to the latching order rules. */
|
||||
|
||||
mtr_x_lock(&fil_system.sys_space->latch, mtr);
|
||||
mtr_x_lock_space(fil_system.sys_space, mtr);
|
||||
compile_time_assert(TRX_SYS_SPACE == 0);
|
||||
|
||||
/* Create the trx sys file block in a new allocated file segment */
|
||||
|
Loading…
x
Reference in New Issue
Block a user