summaryrefslogtreecommitdiff
path: root/storage/innobase/row
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-11-14 11:40:33 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-11-14 11:40:33 +0200
commit3d4a80153345209bad736235d4f66dcaa51a9d51 (patch)
treed9b6b5e1fcbe8e1e96b7c02880ee25bf84a7437b /storage/innobase/row
parent4ded5fb9ac0cf94ec0d16b69acebdecc4066c5f2 (diff)
downloadmariadb-git-3d4a80153345209bad736235d4f66dcaa51a9d51.tar.gz
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.
Diffstat (limited to 'storage/innobase/row')
-rw-r--r--storage/innobase/row/row0ins.cc10
-rw-r--r--storage/innobase/row/row0purge.cc24
-rw-r--r--storage/innobase/row/row0uins.cc6
-rw-r--r--storage/innobase/row/row0umod.cc14
-rw-r--r--storage/innobase/row/row0upd.cc4
5 files changed, 29 insertions, 29 deletions
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 4760960a441..0fb994b547a 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -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(
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index 8c83482f53e..b71f8491787 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -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();
}
}
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc
index 47b4a956a29..db7bf9bdcb5 100644
--- a/storage/innobase/row/row0uins.cc
+++ b/storage/innobase/row/row0uins.cc
@@ -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)) {
diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc
index 2a0779a03ea..0172d47b8e2 100644
--- a/storage/innobase/row/row0umod.cc
+++ b/storage/innobase/row/row0umod.cc
@@ -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)) {
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index d3d1c9a0fac..29b6e6ec086 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -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;
}