Skip to content

Commit 17a7baf

Browse files
committed
MDEV-22110 preparation: Remove mtr_memo_contains macros
Let us invoke the debug member functions of mtr_t directly. mtr_t::memo_contains(): Change the parameter type to const rw_lock_t&. This function cannot be invoked on buf_block_t::lock. The function mtr_t::memo_contains_flagged() is intended to be invoked on buf_block_t* or rw_lock_t*, and it along with mtr_t::memo_contains_page_flagged() are the way to check whether a buffer pool page has been latched within a mini-transaction.
1 parent d6f8c48 commit 17a7baf

File tree

20 files changed

+242
-325
lines changed

20 files changed

+242
-325
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 39 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,9 @@ btr_height_get(
287287
buf_block_t* root_block;
288288

289289
ut_ad(srv_read_only_mode
290-
|| mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
291-
MTR_MEMO_S_LOCK
292-
| MTR_MEMO_X_LOCK
293-
| MTR_MEMO_SX_LOCK));
290+
|| mtr->memo_contains_flagged(&index->lock, MTR_MEMO_S_LOCK
291+
| MTR_MEMO_X_LOCK
292+
| MTR_MEMO_SX_LOCK));
294293

295294
/* S latches the page */
296295
root_block = btr_root_block_get(index, RW_S_LATCH, mtr);
@@ -438,7 +437,7 @@ btr_page_create(
438437
ulint level,/*!< in: the B-tree level of the page */
439438
mtr_t* mtr)/*!< in: mtr */
440439
{
441-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
440+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
442441
byte *index_id= my_assume_aligned<2>(PAGE_HEADER + PAGE_INDEX_ID +
443442
block->frame);
444443

@@ -607,8 +606,7 @@ btr_get_size(
607606
ulint n=0;
608607

609608
ut_ad(srv_read_only_mode
610-
|| mtr_memo_contains(mtr, dict_index_get_lock(index),
611-
MTR_MEMO_S_LOCK));
609+
|| mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
612610
ut_ad(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
613611

614612
if (index->page == FIL_NULL
@@ -654,9 +652,7 @@ btr_get_size_and_reserved(
654652
{
655653
ulint dummy;
656654

657-
ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index),
658-
MTR_MEMO_S_LOCK));
659-
655+
ut_ad(mtr->memo_contains(index->lock, MTR_MEMO_S_LOCK));
660656
ut_a(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE);
661657

662658
if (index->page == FIL_NULL
@@ -697,7 +693,7 @@ btr_page_free_for_ibuf(
697693
buf_block_t* block,/*!< in: block to be freed, x-latched */
698694
mtr_t* mtr)/*!< in: mtr */
699695
{
700-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
696+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
701697

702698
buf_block_t* root = btr_root_block_get(index, RW_SX_LATCH, mtr);
703699

@@ -715,7 +711,7 @@ btr_page_free_for_ibuf(
715711
void btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr,
716712
bool blob)
717713
{
718-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
714+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
719715
#ifdef BTR_CUR_HASH_ADAPT
720716
if (block->index && !block->index->freed()) {
721717
ut_ad(!blob);
@@ -752,7 +748,7 @@ void btr_page_free(dict_index_t* index, buf_block_t* block, mtr_t* mtr,
752748
/* The page was marked free in the allocation bitmap, but it
753749
should remain exclusively latched until mtr_t::commit() or until it
754750
is explicitly freed from the mini-transaction. */
755-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
751+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
756752

757753
/* MDEV-15528 FIXME: Zero out the page after the redo log for
758754
this mini-transaction has been durably written.
@@ -841,9 +837,8 @@ btr_page_get_father_node_ptr_func(
841837
ut_ad(!dict_index_is_spatial(index));
842838

843839
ut_ad(srv_read_only_mode
844-
|| mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
845-
MTR_MEMO_X_LOCK
846-
| MTR_MEMO_SX_LOCK));
840+
|| mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
841+
| MTR_MEMO_SX_LOCK));
847842

848843
ut_ad(dict_index_get_page(index) != page_no);
849844

@@ -968,8 +963,8 @@ before mtr.commit().
968963
@param[in] invalidate whether to invalidate PAGE_INDEX_ID */
969964
static void btr_free_root(buf_block_t *block, mtr_t *mtr, bool invalidate)
970965
{
971-
ut_ad(mtr_memo_contains_flagged(mtr, block,
972-
MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX));
966+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX |
967+
MTR_MEMO_PAGE_SX_FIX));
973968
ut_ad(mtr->is_named_space(block->page.id().space()));
974969

975970
btr_search_drop_page_hash_index(block);
@@ -1384,7 +1379,7 @@ static void btr_page_reorganize_low(page_cur_t *cursor, dict_index_t *index,
13841379

13851380
buf_block_t *const block= cursor->block;
13861381

1387-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
1382+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
13881383
ut_ad(!is_buf_block_get_page_zip(block));
13891384
btr_assert_not_corrupted(block, index);
13901385
ut_ad(fil_page_index_page_check(block->frame));
@@ -1693,7 +1688,7 @@ btr_page_empty(
16931688
ulint level,
16941689
mtr_t* mtr)
16951690
{
1696-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
1691+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
16971692
ut_ad(page_zip == buf_block_get_page_zip(block));
16981693
ut_ad(!index->is_dummy);
16991694
ut_ad(index->table->space->id == block->page.id().space());
@@ -1895,10 +1890,9 @@ btr_root_raise_and_insert(
18951890

18961891
ut_a(dict_index_get_page(index) == root->page.id().page_no());
18971892
#endif /* UNIV_BTR_DEBUG */
1898-
ut_ad(mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
1899-
MTR_MEMO_X_LOCK
1900-
| MTR_MEMO_SX_LOCK));
1901-
ut_ad(mtr_memo_contains(mtr, root, MTR_MEMO_PAGE_X_FIX));
1893+
ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
1894+
| MTR_MEMO_SX_LOCK));
1895+
ut_ad(mtr->memo_contains_flagged(root, MTR_MEMO_PAGE_X_FIX));
19021896

19031897
/* Allocate a new page to the tree. Root splitting is done by first
19041898
moving the root records to the new page, emptying the root, putting
@@ -2490,8 +2484,8 @@ btr_attach_half_pages(
24902484
buf_block_t* lower_block;
24912485
buf_block_t* upper_block;
24922486

2493-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
2494-
ut_ad(mtr_memo_contains(mtr, new_block, MTR_MEMO_PAGE_X_FIX));
2487+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
2488+
ut_ad(mtr->memo_contains_flagged(new_block, MTR_MEMO_PAGE_X_FIX));
24952489

24962490
/* Create a memory heap where the data tuple is stored */
24972491
heap = mem_heap_create(1024);
@@ -2653,10 +2647,9 @@ btr_insert_into_right_sibling(
26532647
page_t* page = buf_block_get_frame(block);
26542648
const uint32_tnext_page_no = btr_page_get_next(page);
26552649

2656-
ut_ad(mtr_memo_contains_flagged(
2657-
mtr, dict_index_get_lock(cursor->index),
2658-
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
2659-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
2650+
ut_ad(mtr->memo_contains_flagged(&cursor->index->lock,
2651+
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
2652+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
26602653
ut_ad(heap);
26612654

26622655
if (next_page_no == FIL_NULL || !page_rec_is_supremum(
@@ -2815,9 +2808,8 @@ btr_page_split_and_insert(
28152808
mem_heap_empty(*heap);
28162809
*offsets = NULL;
28172810

2818-
ut_ad(mtr_memo_contains_flagged(mtr,
2819-
dict_index_get_lock(cursor->index),
2820-
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
2811+
ut_ad(mtr->memo_contains_flagged(&cursor->index->lock, MTR_MEMO_X_LOCK
2812+
| MTR_MEMO_SX_LOCK));
28212813
ut_ad(!dict_index_is_online_ddl(cursor->index)
28222814
|| (flags & BTR_CREATE_FLAG)
28232815
|| dict_index_is_clust(cursor->index));
@@ -2828,7 +2820,7 @@ btr_page_split_and_insert(
28282820
page = buf_block_get_frame(block);
28292821
page_zip = buf_block_get_page_zip(block);
28302822

2831-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
2823+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
28322824
ut_ad(!page_is_empty(page));
28332825

28342826
/* try to insert to the next page if possible before split */
@@ -3177,7 +3169,7 @@ btr_page_split_and_insert(
31773169
void btr_level_list_remove(const buf_block_t& block, const dict_index_t& index,
31783170
mtr_t* mtr)
31793171
{
3180-
ut_ad(mtr_memo_contains(mtr, &block, MTR_MEMO_PAGE_X_FIX));
3172+
ut_ad(mtr->memo_contains_flagged(&block, MTR_MEMO_PAGE_X_FIX));
31813173
ut_ad(block.zip_size() == index.table->space->zip_size());
31823174
ut_ad(index.table->space->id == block.page.id().space());
31833175
/* Get the previous and next page numbers of page */
@@ -3246,7 +3238,7 @@ btr_lift_page_up(
32463238
buf_block_t* block_orig = block;
32473239

32483240
ut_ad(!page_has_siblings(page));
3249-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
3241+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
32503242

32513243
page_level = btr_page_get_level(page);
32523244
root_page_no = dict_index_get_page(index);
@@ -3313,8 +3305,8 @@ btr_lift_page_up(
33133305
page_level = btr_page_get_level(page);
33143306

33153307
ut_ad(!page_has_siblings(page));
3316-
ut_ad(mtr_memo_contains(
3317-
mtr, block, MTR_MEMO_PAGE_X_FIX));
3308+
ut_ad(mtr->memo_contains_flagged(block,
3309+
MTR_MEMO_PAGE_X_FIX));
33183310

33193311
father_block = blocks[0];
33203312
father_page_zip = buf_block_get_page_zip(father_block);
@@ -3450,18 +3442,9 @@ btr_compress(
34503442

34513443
btr_assert_not_corrupted(block, index);
34523444

3453-
#ifdef UNIV_DEBUG
3454-
if (dict_index_is_spatial(index)) {
3455-
ut_ad(mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
3456-
MTR_MEMO_X_LOCK));
3457-
} else {
3458-
ut_ad(mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
3459-
MTR_MEMO_X_LOCK
3460-
| MTR_MEMO_SX_LOCK));
3461-
}
3462-
#endif /* UNIV_DEBUG */
3463-
3464-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
3445+
ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
3446+
| MTR_MEMO_SX_LOCK));
3447+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
34653448

34663449
MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS);
34673450

@@ -3936,7 +3919,7 @@ btr_discard_only_page_on_level(
39363919
ut_a(!page_has_siblings(page));
39373920
ut_ad(fil_page_index_page_check(page));
39383921
ut_ad(block->page.id().space() == index->table->space->id);
3939-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
3922+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
39403923
btr_search_drop_page_hash_index(block);
39413924

39423925
if (dict_index_is_spatial(index)) {
@@ -4046,10 +4029,9 @@ btr_discard_page(
40464029

40474030
ut_ad(dict_index_get_page(index) != block->page.id().page_no());
40484031

4049-
ut_ad(mtr_memo_contains_flagged(mtr, dict_index_get_lock(index),
4050-
MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK));
4051-
4052-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
4032+
ut_ad(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK
4033+
| MTR_MEMO_SX_LOCK));
4034+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
40534035

40544036
MONITOR_INC(MONITOR_INDEX_DISCARD);
40554037

@@ -4217,7 +4199,7 @@ btr_print_recursive(
42174199
ulint i = 0;
42184200
mtr_tmtr2;
42194201

4220-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_SX_FIX));
4202+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_SX_FIX));
42214203

42224204
ib::info() << "NODE ON LEVEL " << btr_page_get_level(page)
42234205
<< " page " << block->page.id;
@@ -4311,7 +4293,7 @@ btr_check_node_ptr(
43114293
btr_cur_tcursor;
43124294
page_t* page = buf_block_get_frame(block);
43134295

4314-
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
4296+
ut_ad(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX));
43154297

43164298
if (dict_index_get_page(index) == block->page.id().page_no()) {
43174299

0 commit comments

Comments
 (0)