diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-11-17 08:19:01 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-11-17 08:19:01 +0200 |
commit | 24fe53477c07f700e50beb172cb6e0cf3fb1d409 (patch) | |
tree | 32a12a0af7300b785a405ddace9bf45b584249ff /storage/innobase/row/row0log.cc | |
parent | 89ec4b53ac4c7568b9c9765fff50d9bec7cf3534 (diff) | |
download | mariadb-git-24fe53477c07f700e50beb172cb6e0cf3fb1d409.tar.gz |
MDEV-29603 btr_cur_open_at_index_side() is missing some consistency checks
btr_cur_t: Zero-initialize all fields in the default constructor.
btr_cur_t::index: Remove; it duplicated page_cur.index.
Many functions: Remove arguments that were duplicating
page_cur_t::index and page_cur_t::block.
page_cur_open_level(), btr_pcur_open_level(): Replaces
btr_cur_open_at_index_side() for dict_stats_analyze_index().
At the end, release all latches except the dict_index_t::lock
and the buf_page_t::lock on the requested page.
dict_stats_analyze_index(): Rely on mtr_t::rollback_to_savepoint()
to release all uninteresting page latches.
btr_search_guess_on_hash(): Simplify the logic, and invoke
mtr_t::rollback_to_savepoint().
We will use plain C++ std::vector<mtr_memo_slot_t> for mtr_t::m_memo.
In this way, we can avoid setting mtr_memo_slot_t::object to nullptr
and instead just remove garbage from m_memo.
mtr_t::rollback_to_savepoint(): Shrink the vector. We will be needing this
in dict_stats_analyze_index(), where we will release page latches and
only retain the index->lock in mtr_t::m_memo.
mtr_t::release_last_page(): Release the last acquired page latch.
Replaces btr_leaf_page_release().
mtr_t::release(const buf_block_t&): Release a single page latch.
Used in btr_pcur_move_backward_from_page().
mtr_t::memo_release(): Replaced with mtr_t::release().
mtr_t::upgrade_buffer_fix(): Acquire a latch for a buffer-fixed page.
This replaces the double bookkeeping in btr_cur_t::open_leaf().
Reviewed by: Vladislav Lesin
Diffstat (limited to 'storage/innobase/row/row0log.cc')
-rw-r--r-- | storage/innobase/row/row0log.cc | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 1b56d18cd3d..0689f9ca029 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1658,7 +1658,7 @@ row_log_table_apply_delete_low( dberr_t error; row_ext_t* ext; dtuple_t* row; - dict_index_t* index = btr_pcur_get_btr_cur(pcur)->index; + dict_index_t* index = pcur->index(); ut_ad(dict_index_is_clust(index)); @@ -1695,8 +1695,9 @@ err_exit: row, ext, index, heap); mtr->start(); index->set_modified(*mtr); - error = btr_pcur_open(index, entry, PAGE_CUR_LE, - BTR_PURGE_TREE, pcur, mtr); + pcur->btr_cur.page_cur.index = index; + error = btr_pcur_open(entry, PAGE_CUR_LE, + BTR_PURGE_TREE, pcur, 0, mtr); if (error) { goto err_exit; } @@ -1760,6 +1761,7 @@ row_log_table_apply_delete( btr_pcur_t pcur; rec_offs* offsets; + pcur.btr_cur.page_cur.index = index; ut_ad(rec_offs_n_fields(moffsets) == index->first_user_field()); ut_ad(!rec_offs_any_extern(moffsets)); @@ -1778,8 +1780,8 @@ row_log_table_apply_delete( mtr_start(&mtr); index->set_modified(mtr); - dberr_t err = btr_pcur_open(index, old_pk, PAGE_CUR_LE, - BTR_PURGE_TREE, &pcur, &mtr); + dberr_t err = btr_pcur_open(old_pk, PAGE_CUR_LE, + BTR_PURGE_TREE, &pcur, 0, &mtr); if (err != DB_SUCCESS) { goto all_done; } @@ -1891,6 +1893,8 @@ row_log_table_apply_update( dberr_t error; ulint n_index = 0; + pcur.btr_cur.page_cur.index = index; + ut_ad(dtuple_get_n_fields_cmp(old_pk) == dict_index_get_n_unique(index)); ut_ad(dtuple_get_n_fields(old_pk) - (log->same_pk ? 0 : 2) @@ -1913,8 +1917,8 @@ row_log_table_apply_update( mtr.start(); index->set_modified(mtr); - error = btr_pcur_open(index, old_pk, PAGE_CUR_LE, - BTR_MODIFY_TREE, &pcur, &mtr); + error = btr_pcur_open(old_pk, PAGE_CUR_LE, + BTR_MODIFY_TREE, &pcur, 0, &mtr); if (error != DB_SUCCESS) { func_exit: mtr.commit(); @@ -2059,7 +2063,7 @@ func_exit_committed: for (n_index += index->type != DICT_CLUSTERED; (index = dict_table_get_next_index(index)); n_index++) { - if (index->type & DICT_FTS) { + if (!index->is_btree()) { continue; } @@ -2087,9 +2091,10 @@ func_exit_committed: mtr.start(); index->set_modified(mtr); + pcur.btr_cur.page_cur.index = index; if (ROW_FOUND != row_search_index_entry( - index, entry, BTR_MODIFY_TREE, &pcur, &mtr)) { + entry, BTR_MODIFY_TREE, &pcur, &mtr)) { ut_ad(0); error = DB_CORRUPTION; break; @@ -3069,13 +3074,14 @@ row_log_apply_op_low( mtr_start(&mtr); index->set_modified(mtr); + cursor.page_cur.index = index; /* We perform the pessimistic variant of the operations if we already hold index->lock exclusively. First, search the record. The operation may already have been performed, depending on when the row in the clustered index was scanned. */ - *error = btr_cur_search_to_nth_level(index, 0, entry, PAGE_CUR_LE, + *error = btr_cur_search_to_nth_level(0, entry, PAGE_CUR_LE, has_index_lock ? BTR_MODIFY_TREE : BTR_MODIFY_LEAF, @@ -3130,7 +3136,7 @@ row_log_apply_op_low( mtr_start(&mtr); index->set_modified(mtr); *error = btr_cur_search_to_nth_level( - index, 0, entry, PAGE_CUR_LE, + 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, &mtr); if (UNIV_UNLIKELY(*error != DB_SUCCESS)) { goto func_exit; @@ -3234,7 +3240,7 @@ insert_the_rec: mtr_start(&mtr); index->set_modified(mtr); *error = btr_cur_search_to_nth_level( - index, 0, entry, PAGE_CUR_LE, + 0, entry, PAGE_CUR_LE, BTR_MODIFY_TREE, &cursor, &mtr); if (*error != DB_SUCCESS) { break; @@ -3949,8 +3955,8 @@ void UndorecApplier::log_insert(const dtuple_t &tuple, } bool success= true; - dict_index_t *index= dict_table_get_next_index(clust_index); - while (index) + for (dict_index_t *index= clust_index; + (index= dict_table_get_next_index(index)) != nullptr; ) { index->lock.s_lock(SRW_LOCK_CALL); if (index->online_log && @@ -3969,7 +3975,6 @@ void UndorecApplier::log_insert(const dtuple_t &tuple, row_log_mark_other_online_index_abort(index->table); return; } - index= dict_table_get_next_index(index); } } } |