diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-11-10 18:18:48 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-11-16 09:36:36 +0200 |
commit | a5ed56cd4f243f2f7c8de64e7b07159b6ebf34fc (patch) | |
tree | 39611f223b2633163559039452b82eb2ff787b48 | |
parent | af7bd64edb2c240755decb381de8afd03f654c1b (diff) | |
download | mariadb-git-a5ed56cd4f243f2f7c8de64e7b07159b6ebf34fc.tar.gz |
Cleanup: Remove BTR_MODIFY_EXTERNAL
btr_blob_log_check_t::check(): Acquire an index U-latch upfront and
pass the flag BTR_MODIFY_LEAF_ALREADY_LATCHED to the search.
-rw-r--r-- | storage/innobase/btr/btr0cur.cc | 65 | ||||
-rw-r--r-- | storage/innobase/include/btr0btr.h | 14 | ||||
-rw-r--r-- | storage/innobase/row/row0ins.cc | 2 |
3 files changed, 24 insertions, 57 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index af28557364b..245f745969c 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1254,7 +1254,6 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, ulint root_height = 0; /* remove warning */ btr_intention_t lock_intention; - bool modify_external; buf_block_t* tree_blocks[BTR_MAX_LEVELS]; ulint tree_savepoints[BTR_MAX_LEVELS]; ulint n_blocks = 0; @@ -1303,11 +1302,9 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, cursor->low_match = ULINT_UNDEFINED; #endif /* UNIV_DEBUG */ - ibool s_latch_by_caller; + const bool latch_by_caller = latch_mode & BTR_ALREADY_S_LATCHED; - s_latch_by_caller = latch_mode & BTR_ALREADY_S_LATCHED; - - ut_ad(!s_latch_by_caller + ut_ad(!latch_by_caller || srv_read_only_mode || mtr->memo_contains_flagged(&index->lock, MTR_MEMO_S_LOCK | MTR_MEMO_SX_LOCK)); @@ -1344,14 +1341,10 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, lock_intention = btr_cur_get_and_clear_intention(&latch_mode); - modify_external = latch_mode & BTR_MODIFY_EXTERNAL; - /* Turn the flags unrelated to the latch mode off. */ latch_mode = BTR_LATCH_MODE_WITHOUT_FLAGS(latch_mode); - ut_ad(!modify_external || latch_mode == BTR_MODIFY_LEAF); - - ut_ad(!s_latch_by_caller + ut_ad(!latch_by_caller || latch_mode == BTR_SEARCH_LEAF || latch_mode == BTR_SEARCH_TREE || latch_mode == BTR_MODIFY_LEAF); @@ -1381,7 +1374,6 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, if (!btr_search_enabled) { } else if (autoinc == 0 && latch_mode <= BTR_MODIFY_LEAF - && !modify_external # ifdef PAGE_CUR_LE_OR_EXTENDS && mode != PAGE_CUR_LE_OR_EXTENDS # endif /* PAGE_CUR_LE_OR_EXTENDS */ @@ -1463,16 +1455,9 @@ x_latch_index: break; default: if (!srv_read_only_mode) { - if (s_latch_by_caller) { - } else if (!modify_external) { - /* BTR_SEARCH_TREE is intended to be used with - BTR_ALREADY_S_LATCHED */ + if (!latch_by_caller) { ut_ad(latch_mode != BTR_SEARCH_TREE); - mtr_s_lock_index(index, mtr); - } else { - /* BTR_MODIFY_EXTERNAL needs to be excluded */ - mtr_sx_lock_index(index, mtr); } upper_rw_latch = RW_S_LATCH; } else { @@ -1540,10 +1525,9 @@ search_loop: each pages should be latched before reading. */ if (height == ULINT_UNDEFINED && upper_rw_latch == RW_S_LATCH - && (modify_external || autoinc)) { + && autoinc) { /* needs sx-latch of root page - for fseg operation or for writing - PAGE_ROOT_AUTO_INC */ + for writing PAGE_ROOT_AUTO_INC */ rw_latch = RW_SX_LATCH; } else { rw_latch = upper_rw_latch; @@ -1727,7 +1711,7 @@ retry_page_get: is latched differently from leaf pages. */ ut_ad(root_leaf_rw_latch != RW_NO_LATCH); ut_ad(rw_latch == RW_S_LATCH || rw_latch == RW_SX_LATCH); - ut_ad(rw_latch == RW_S_LATCH || modify_external || autoinc); + ut_ad(rw_latch == RW_S_LATCH || autoinc); ut_ad(!autoinc || root_leaf_rw_latch == RW_X_LATCH); ut_ad(n_blocks == 0); @@ -1789,12 +1773,9 @@ retry_page_get: case BTR_CONT_SEARCH_TREE: break; default: - if (!s_latch_by_caller - && !srv_read_only_mode - && !modify_external) { + if (!latch_by_caller + && !srv_read_only_mode) { /* Release the tree s-latch */ - /* NOTE: BTR_MODIFY_EXTERNAL - needs to keep tree sx-latch */ mtr_release_s_latch_at_savepoint( mtr, savepoint, &index->lock); @@ -1817,7 +1798,7 @@ retry_page_get: for (; n_releases < n_blocks; n_releases++) { if (n_releases == 0 - && (modify_external || autoinc)) { + && (autoinc)) { /* keep the root page latch */ ut_ad(mtr->memo_contains_flagged( tree_blocks[n_releases], @@ -2355,7 +2336,7 @@ need_opposite_intention: ut_ad(mtr->memo_contains_flagged(block, upper_rw_latch)); - if (s_latch_by_caller) { + if (latch_by_caller) { ut_ad(latch_mode == BTR_SEARCH_TREE); /* to exclude modifying tree operations should sx-latch the index. */ @@ -2478,15 +2459,11 @@ btr_cur_open_at_index_side( ut_ad(level != ULINT_UNDEFINED); - bool s_latch_by_caller; - - s_latch_by_caller = latch_mode & BTR_ALREADY_S_LATCHED; + const bool latch_by_caller = latch_mode & BTR_ALREADY_S_LATCHED; latch_mode &= ulint(~BTR_ALREADY_S_LATCHED); lock_intention = btr_cur_get_and_clear_intention(&latch_mode); - ut_ad(!(latch_mode & BTR_MODIFY_EXTERNAL)); - /* This function doesn't need to lock left page of the leaf page */ if (latch_mode == BTR_SEARCH_PREV) { latch_mode = BTR_SEARCH_LEAF; @@ -2521,16 +2498,13 @@ btr_cur_open_at_index_side( upper_rw_latch = RW_X_LATCH; break; default: - ut_ad(!s_latch_by_caller + ut_ad(!latch_by_caller || mtr->memo_contains_flagged(&index->lock, MTR_MEMO_SX_LOCK | MTR_MEMO_S_LOCK)); if (!srv_read_only_mode) { - if (!s_latch_by_caller) { - /* BTR_SEARCH_TREE is intended to be used with - BTR_ALREADY_S_LATCHED */ + if (!latch_by_caller) { ut_ad(latch_mode != BTR_SEARCH_TREE); - mtr_s_lock_index(index, mtr); } upper_rw_latch = RW_S_LATCH; @@ -2631,7 +2605,7 @@ btr_cur_open_at_index_side( if (UNIV_UNLIKELY(srv_read_only_mode)) { break; } - if (!s_latch_by_caller) { + if (!latch_by_caller) { /* Release the tree s-latch */ mtr_release_s_latch_at_savepoint( mtr, savepoint, &index->lock); @@ -2649,12 +2623,12 @@ btr_cur_open_at_index_side( && UNIV_LIKELY(!srv_read_only_mode)) { /* We already have the block latched. */ ut_ad(latch_mode == BTR_SEARCH_TREE); - ut_ad(s_latch_by_caller); + ut_ad(latch_by_caller); ut_ad(upper_rw_latch == RW_S_LATCH); ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_S_FIX)); - if (s_latch_by_caller) { + if (latch_by_caller) { /* to exclude modifying tree operations should sx-latch the index. */ ut_ad(mtr->memo_contains(index->lock, @@ -2808,8 +2782,6 @@ btr_cur_open_at_rnd_pos( lock_intention = btr_cur_get_and_clear_intention(&latch_mode); - ut_ad(!(latch_mode & BTR_MODIFY_EXTERNAL)); - ulint savepoint = mtr_set_savepoint(mtr); rw_lock_type_t upper_rw_latch; @@ -6824,8 +6796,9 @@ struct btr_blob_log_check_t { + offs; } else { ut_ad(m_pcur->rel_pos == BTR_PCUR_ON); + mtr_sx_lock_index(index, m_mtr); ut_a(m_pcur->restore_position( - BTR_MODIFY_LEAF | BTR_MODIFY_EXTERNAL, + BTR_MODIFY_LEAF_ALREADY_LATCHED, m_mtr) == btr_pcur_t::SAME_ALL); } diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 5c01e0ee7c1..74798a1e2c6 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -103,8 +103,8 @@ enum btr_latch_mode { BTR_SEARCH_TREE_ALREADY_S_LATCHED = BTR_SEARCH_TREE | BTR_ALREADY_S_LATCHED, /** Search and X-latch a leaf page, assuming that the - dict_index_t::lock S-latch is being held. */ - BTR_MODIFY_LEAF_ALREADY_S_LATCHED = BTR_MODIFY_LEAF + dict_index_t::lock is being held in non-exclusive mode. */ + BTR_MODIFY_LEAF_ALREADY_LATCHED = BTR_MODIFY_LEAF | BTR_ALREADY_S_LATCHED, /** Attempt to delete-mark a secondary index record. */ @@ -146,10 +146,6 @@ the insert buffer to speed up inserts */ to find proper rec to undo insert.*/ #define BTR_RTREE_UNDO_INS 4096U -/** In the case of BTR_MODIFY_LEAF, the caller intends to allocate or -free the pages of externally stored fields. */ -#define BTR_MODIFY_EXTERNAL 16384U - /** Try to delete mark the record at the searched position when the record is in spatial index */ #define BTR_RTREE_DELETE_MARK 16384U @@ -163,13 +159,11 @@ record is in spatial index */ | BTR_IGNORE_SEC_UNIQUE \ | BTR_ALREADY_S_LATCHED \ | BTR_LATCH_FOR_INSERT \ - | BTR_LATCH_FOR_DELETE \ - | BTR_MODIFY_EXTERNAL))) + | BTR_LATCH_FOR_DELETE))) #define BTR_LATCH_MODE_WITHOUT_INTENTION(latch_mode) \ ((latch_mode) & ulint(~(BTR_LATCH_FOR_INSERT \ - | BTR_LATCH_FOR_DELETE \ - | BTR_MODIFY_EXTERNAL))) + | BTR_LATCH_FOR_DELETE))) /**************************************************************//** Checks and adjusts the root node of a tree during IMPORT TABLESPACE. diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index ad0b97fbae4..770cefe2a6c 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2574,7 +2574,7 @@ row_ins_clust_index_entry_low( } else { if (mode == BTR_MODIFY_LEAF && dict_index_is_online_ddl(index)) { - mode = BTR_MODIFY_LEAF_ALREADY_S_LATCHED; + mode = BTR_MODIFY_LEAF_ALREADY_LATCHED; mtr_s_lock_index(index, &mtr); } |