Skip to content

Commit 1d0380e

Browse files
committed
MDEV-15528 preparation: Do not modify a freed page
btr_free_root(): Add the parameter bool invalidate. btr_free_root_invalidate(): Remove.
1 parent 56df18b commit 1d0380e

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,17 +1081,17 @@ void btr_page_get_father(dict_index_t* index, buf_block_t* block, mtr_t* mtr,
10811081
mem_heap_free(heap);
10821082
}
10831083

1084+
/** PAGE_INDEX_ID value for freed index B-trees */
1085+
static const index_id_t BTR_FREED_INDEX_ID = 0;
1086+
10841087
/** Free a B-tree root page. btr_free_but_not_root() must already
10851088
have been called.
10861089
In a persistent tablespace, the caller must invoke fsp_init_file_page()
10871090
before mtr.commit().
1088-
@param[in,out] block index root page
1089-
@param[in,out] mtr mini-transaction */
1090-
static
1091-
void
1092-
btr_free_root(
1093-
buf_block_t* block,
1094-
mtr_t* mtr)
1091+
@param[in,out] block index root page
1092+
@param[in,out] mtr mini-transaction
1093+
@param[in] invalidate whether to invalidate PAGE_INDEX_ID */
1094+
static void btr_free_root(buf_block_t* block, mtr_t* mtr, bool invalidate)
10951095
{
10961096
fseg_header_t* header;
10971097

@@ -1105,31 +1105,18 @@ btr_free_root(
11051105
#ifdef UNIV_BTR_DEBUG
11061106
ut_a(btr_root_fseg_validate(header, block->page.id.space()));
11071107
#endif /* UNIV_BTR_DEBUG */
1108+
if (invalidate) {
1109+
btr_page_set_index_id(
1110+
buf_block_get_frame(block),
1111+
buf_block_get_page_zip(block),
1112+
BTR_FREED_INDEX_ID, mtr);
1113+
}
11081114

11091115
while (!fseg_free_step(header, true, mtr)) {
11101116
/* Free the entire segment in small steps. */
11111117
}
11121118
}
11131119

1114-
/** PAGE_INDEX_ID value for freed index B-trees */
1115-
static const index_id_t BTR_FREED_INDEX_ID = 0;
1116-
1117-
/** Invalidate an index root page so that btr_free_root_check()
1118-
will not find it.
1119-
@param[in,out] block index root page
1120-
@param[in,out] mtr mini-transaction */
1121-
static
1122-
void
1123-
btr_free_root_invalidate(
1124-
buf_block_t* block,
1125-
mtr_t* mtr)
1126-
{
1127-
btr_page_set_index_id(
1128-
buf_block_get_frame(block),
1129-
buf_block_get_page_zip(block),
1130-
BTR_FREED_INDEX_ID, mtr);
1131-
}
1132-
11331120
/** Prepare to free a B-tree.
11341121
@param[in] page_id page id
11351122
@param[in] page_size page size
@@ -1249,11 +1236,8 @@ btr_create(
12491236
PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr)) {
12501237
/* Not enough space for new segment, free root
12511238
segment before return. */
1252-
btr_free_root(block, mtr);
1253-
if (!dict_table_is_temporary(index->table)) {
1254-
btr_free_root_invalidate(block, mtr);
1255-
}
1256-
1239+
btr_free_root(block, mtr,
1240+
!index->table->is_temporary());
12571241
return(FIL_NULL);
12581242
}
12591243

@@ -1427,8 +1411,7 @@ btr_free_if_exists(
14271411

14281412
btr_free_but_not_root(root, mtr->get_log_mode());
14291413
mtr->set_named_space(page_id.space());
1430-
btr_free_root(root, mtr);
1431-
btr_free_root_invalidate(root, mtr);
1414+
btr_free_root(root, mtr, true);
14321415
}
14331416

14341417
/** Free an index tree in a temporary tablespace or during TRUNCATE TABLE.
@@ -1448,7 +1431,7 @@ btr_free(
14481431

14491432
if (block) {
14501433
btr_free_but_not_root(block, MTR_LOG_NO_REDO);
1451-
btr_free_root(block, &mtr);
1434+
btr_free_root(block, &mtr, false);
14521435
}
14531436
mtr.commit();
14541437
}

0 commit comments

Comments
 (0)