Skip to content
Permalink
Browse files
MDEV-12266: Add dict_index_t::set_modified(mtr)
This is a non-functional change (pure refactoring).
  • Loading branch information
dr-m committed Mar 29, 2018
1 parent 39cbba1 commit e7980f9
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 72 deletions.
@@ -62,8 +62,8 @@ PageBulk::init()
because we don't guarantee pages are committed following
the allocation order, and we will always generate redo log
for page allocation, even when creating a new tablespace. */
mtr_start(&alloc_mtr);
alloc_mtr.set_named_space(dict_index_get_space(m_index));
alloc_mtr.start();
m_index->set_modified(alloc_mtr);

ulint n_reserved;
bool success;
@@ -84,7 +84,7 @@ PageBulk::init()
n_reserved);
}

mtr_commit(&alloc_mtr);
alloc_mtr.commit();

new_page = buf_block_get_frame(new_block);
new_page_zip = buf_block_get_page_zip(new_block);
@@ -963,9 +963,9 @@ BtrBulk::finish(dberr_t err)
root_page_no, m_root_level,
m_flush_observer);

mtr_start(&mtr);
mtr.set_named_space(dict_index_get_space(m_index));
mtr_x_lock(dict_index_get_lock(m_index), &mtr);
mtr.start();
m_index->set_modified(mtr);
mtr_x_lock(&m_index->lock, &mtr);

ut_ad(last_page_no != FIL_NULL);
last_block = btr_block_get(page_id, page_size,
@@ -977,7 +977,7 @@ BtrBulk::finish(dberr_t err)
/* Copy last page to root page. */
err = root_page_bulk.init();
if (err != DB_SUCCESS) {
mtr_commit(&mtr);
mtr.commit();
return(err);
}
root_page_bulk.copyIn(first_rec);
@@ -988,7 +988,7 @@ BtrBulk::finish(dberr_t err)
/* Do not flush the last page. */
last_block->page.flush_observer = NULL;

mtr_commit(&mtr);
mtr.commit();

err = pageCommit(&root_page_bulk, NULL, false);
ut_ad(err == DB_SUCCESS);
@@ -7073,7 +7073,7 @@ struct btr_blob_log_check_t {
const mtr_log_t log_mode = m_mtr->get_log_mode();
m_mtr->start();
m_mtr->set_log_mode(log_mode);
m_mtr->set_named_space(index->space);
index->set_modified(*m_mtr);
m_mtr->set_flush_observer(observer);

if (m_op == BTR_STORE_INSERT_BULK) {
@@ -7276,8 +7276,8 @@ btr_store_big_rec_extern_fields(
rec_page_no = rec_block->page.id.page_no();
}

mtr_start(&mtr);
mtr.set_named_space(index->space);
mtr.start();
index->set_modified(mtr);
mtr.set_log_mode(btr_mtr->get_log_mode());
mtr.set_flush_observer(btr_mtr->get_flush_observer());

@@ -7293,7 +7293,7 @@ btr_store_big_rec_extern_fields(
mtr_t *alloc_mtr;

if (op == BTR_STORE_INSERT_BULK) {
mtr_start(&mtr_bulk);
mtr_bulk.start();
mtr_bulk.set_spaces(mtr);
alloc_mtr = &mtr_bulk;
} else {
@@ -7304,7 +7304,7 @@ btr_store_big_rec_extern_fields(
FSP_BLOB, alloc_mtr,
1)) {

mtr_commit(alloc_mtr);
alloc_mtr->commit();
error = DB_OUT_OF_FILE_SPACE;
goto func_exit;
}
@@ -7315,7 +7315,7 @@ btr_store_big_rec_extern_fields(
alloc_mtr->release_free_extents(r_extents);

if (op == BTR_STORE_INSERT_BULK) {
mtr_commit(&mtr_bulk);
mtr_bulk.commit();
}

ut_a(block != NULL);
@@ -7542,7 +7542,7 @@ btr_store_big_rec_extern_fields(

prev_page_no = page_no;

mtr_commit(&mtr);
mtr.commit();

if (extern_len == 0) {
break;
@@ -799,7 +799,7 @@ DECLARE_THREAD(btr_defragment_thread)(void*)
mtr_start(&mtr);
cursor = btr_pcur_get_btr_cur(pcur);
index = btr_cur_get_index(cursor);
mtr.set_named_space(index->space);
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);
@@ -822,14 +822,7 @@ dict_create_index_tree_step(
the index and its root address is written to the index entry in
sys_indexes */

mtr_start(&mtr);

const bool missing = !index->is_readable()
|| dict_table_is_discarded(index->table);

if (!missing) {
mtr.set_named_space(index->space);
}
mtr.start();

search_tuple = dict_create_search_tuple(node->ind_row, node->heap);

@@ -842,9 +835,11 @@ dict_create_index_tree_step(

dberr_t err = DB_SUCCESS;

if (missing) {
if (!index->is_readable() || dict_table_is_discarded(index->table)) {
node->page_no = FIL_NULL;
} else {
index->set_modified(mtr);

node->page_no = btr_create(
index->type, index->space,
dict_table_page_size(index->table),
@@ -865,7 +860,7 @@ dict_create_index_tree_step(

btr_pcur_close(&pcur);

mtr_commit(&mtr);
mtr.commit();

return(err);
}
@@ -1894,16 +1894,16 @@ rtr_estimate_n_rows_in_range(
page_t* page;
ulint n_recs;

mtr_start(&mtr);
mtr.set_named_space(dict_index_get_space(index));
mtr_s_lock(dict_index_get_lock(index), &mtr);
mtr.start();
index->set_modified(mtr);
mtr_s_lock(&index->lock, &mtr);

block = btr_block_get(page_id, page_size, RW_S_LATCH, index, &mtr);
page = buf_block_get_frame(block);
n_recs = page_header_get_field(page, PAGE_N_RECS);

if (n_recs == 0) {
mtr_commit(&mtr);
mtr.commit();
return(HA_POS_ERROR);
}

@@ -1987,7 +1987,7 @@ rtr_estimate_n_rows_in_range(
rec = page_rec_get_next(rec);
}

mtr_commit(&mtr);
mtr.commit();
mem_heap_free(heap);

if (!isfinite(area)) {
@@ -4267,7 +4267,7 @@ innobase_add_instant_try(

mtr_t mtr;
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_pcur_t pcur;
btr_pcur_open_at_index_side(true, index, BTR_MODIFY_TREE, &pcur, true,
0, &mtr);
@@ -4340,7 +4340,7 @@ innobase_add_instant_try(
ut_ad(user_table->is_instant());
mtr.commit();
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
dberr_t err;
if (page_t* root = btr_root_get(index, &mtr)) {
switch (fil_page_get_type(root)) {
@@ -4364,7 +4364,7 @@ innobase_add_instant_try(
page_set_instant(root, index->n_core_fields, &mtr);
mtr.commit();
mtr.start();
mtr.set_named_space(index->space);
index->set_modified(mtr);
err = row_ins_clust_index_entry_low(
BTR_NO_LOCKING_FLAG, BTR_MODIFY_TREE, index,
index->n_uniq, entry, 0, thr, false);
@@ -1060,6 +1060,10 @@ struct dict_index_t{
uncommitted = !committed;
}

/** Notify that the index pages are going to be modified.
@param[in,out] mtr mini-transaction */
inline void set_modified(mtr_t& mtr) const;

/** @return whether this index is readable
@retval true normally
@retval false if this is a single-table tablespace
@@ -1944,6 +1948,11 @@ struct dict_table_t {
dict_vcol_templ_t* vc_templ;
};

inline void dict_index_t::set_modified(mtr_t& mtr) const
{
mtr.set_named_space(space);
}

inline bool dict_index_t::is_readable() const
{
return(UNIV_LIKELY(!table->file_unreadable));
@@ -409,7 +409,7 @@ row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic)
mtr->set_log_mode(MTR_LOG_NO_REDO);
break;
default:
mtr->set_named_space(index->space);
index->set_modified(*mtr);
break;
}

@@ -2471,7 +2471,7 @@ row_ins_index_entry_big_rec(
if (index->table->is_temporary()) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
}

btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_MODIFY_TREE,
@@ -2565,7 +2565,7 @@ row_ins_clust_index_entry_low(
ut_ad(!index->is_instant());
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);

if (mode == BTR_MODIFY_LEAF
&& dict_index_is_online_ddl(index)) {
@@ -2801,8 +2801,8 @@ row_ins_sec_mtr_start_and_check_if_aborted(

const mtr_log_t log_mode = mtr->get_log_mode();

mtr_start(mtr);
mtr->set_named_space(index->space);
mtr->start();
index->set_modified(*mtr);
mtr->set_log_mode(log_mode);

if (!check) {
@@ -2884,7 +2884,7 @@ row_ins_sec_index_entry_low(
ut_ad(flags & BTR_NO_LOCKING_FLAG);
mtr.set_log_mode(MTR_LOG_NO_REDO);
} else {
mtr.set_named_space(index->space);
index->set_modified(mtr);
if (!dict_index_is_spatial(index)) {
search_mode |= BTR_INSERT;
}
@@ -2937,7 +2937,7 @@ row_ins_sec_index_entry_low(
index, false);
rtr_info_update_btr(&cursor, &rtr_info);
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
search_mode &= ulint(~BTR_MODIFY_LEAF);
search_mode |= BTR_MODIFY_TREE;
err = btr_cur_search_to_nth_level(
@@ -1832,8 +1832,8 @@ row_log_table_apply_delete_low(

const dtuple_t* entry = row_build_index_entry(
row, save_ext, index, heap);
mtr_start(mtr);
mtr->set_named_space(index->space);
mtr->start();
index->set_modified(*mtr);
btr_pcur_open(index, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE,
pcur, mtr);
@@ -1860,14 +1860,14 @@ row_log_table_apply_delete_low(
found, because new_table is being modified by
this thread only, and all indexes should be
updated in sync. */
mtr_commit(mtr);
mtr->commit();
return(DB_INDEX_CORRUPT);
}

btr_cur_pessimistic_delete(&error, FALSE,
btr_pcur_get_btr_cur(pcur),
BTR_CREATE_FLAG, false, mtr);
mtr_commit(mtr);
mtr->commit();
}

return(error);
@@ -1919,7 +1919,7 @@ row_log_table_apply_delete(
}

mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_pcur_open(index, old_pk, PAGE_CUR_LE,
BTR_MODIFY_TREE | BTR_LATCH_FOR_DELETE,
&pcur, &mtr);
@@ -2067,7 +2067,7 @@ row_log_table_apply_update(
}

mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_pcur_open(index, old_pk, PAGE_CUR_LE,
BTR_MODIFY_TREE, &pcur, &mtr);
#ifdef UNIV_DEBUG
@@ -2327,7 +2327,7 @@ row_log_table_apply_update(
}

mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);

if (ROW_FOUND != row_search_index_entry(
index, entry, BTR_MODIFY_TREE, &pcur, &mtr)) {
@@ -2359,7 +2359,7 @@ row_log_table_apply_update(
}

mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
}

goto func_exit;
@@ -3296,7 +3296,7 @@ row_log_apply_op_low(
<< rec_printer(entry).str());

mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);

/* We perform the pessimistic variant of the operations if we
already hold index->lock exclusively. First, search the
@@ -3353,7 +3353,7 @@ row_log_apply_op_low(
Lock the index tree exclusively. */
mtr_commit(&mtr);
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE, &cursor, 0,
@@ -3456,7 +3456,7 @@ row_log_apply_op_low(
Lock the index tree exclusively. */
mtr_commit(&mtr);
mtr_start(&mtr);
mtr.set_named_space(index->space);
index->set_modified(mtr);
btr_cur_search_to_nth_level(
index, 0, entry, PAGE_CUR_LE,
BTR_MODIFY_TREE, &cursor, 0,

0 comments on commit e7980f9

Please sign in to comment.