diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-06 12:42:41 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-06 21:25:43 +0300 |
commit | 1d0380e029977033f2a971d618cc6b6cae9651dc (patch) | |
tree | 2b4bd9034dec109154500b5401f22c571ae77c0a | |
parent | 56df18be65ffa007a4d2c20413d69aac0bb0bdbd (diff) | |
download | mariadb-git-1d0380e029977033f2a971d618cc6b6cae9651dc.tar.gz |
MDEV-15528 preparation: Do not modify a freed page
btr_free_root(): Add the parameter bool invalidate.
btr_free_root_invalidate(): Remove.
-rw-r--r-- | storage/innobase/btr/btr0btr.cc | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index afd8f678235..1b04160082b 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1081,17 +1081,17 @@ void btr_page_get_father(dict_index_t* index, buf_block_t* block, mtr_t* mtr, mem_heap_free(heap); } +/** PAGE_INDEX_ID value for freed index B-trees */ +static const index_id_t BTR_FREED_INDEX_ID = 0; + /** Free a B-tree root page. btr_free_but_not_root() must already have been called. In a persistent tablespace, the caller must invoke fsp_init_file_page() before mtr.commit(). -@param[in,out] block index root page -@param[in,out] mtr mini-transaction */ -static -void -btr_free_root( - buf_block_t* block, - mtr_t* mtr) +@param[in,out] block index root page +@param[in,out] mtr mini-transaction +@param[in] invalidate whether to invalidate PAGE_INDEX_ID */ +static void btr_free_root(buf_block_t* block, mtr_t* mtr, bool invalidate) { fseg_header_t* header; @@ -1105,31 +1105,18 @@ btr_free_root( #ifdef UNIV_BTR_DEBUG ut_a(btr_root_fseg_validate(header, block->page.id.space())); #endif /* UNIV_BTR_DEBUG */ + if (invalidate) { + btr_page_set_index_id( + buf_block_get_frame(block), + buf_block_get_page_zip(block), + BTR_FREED_INDEX_ID, mtr); + } while (!fseg_free_step(header, true, mtr)) { /* Free the entire segment in small steps. */ } } -/** PAGE_INDEX_ID value for freed index B-trees */ -static const index_id_t BTR_FREED_INDEX_ID = 0; - -/** Invalidate an index root page so that btr_free_root_check() -will not find it. -@param[in,out] block index root page -@param[in,out] mtr mini-transaction */ -static -void -btr_free_root_invalidate( - buf_block_t* block, - mtr_t* mtr) -{ - btr_page_set_index_id( - buf_block_get_frame(block), - buf_block_get_page_zip(block), - BTR_FREED_INDEX_ID, mtr); -} - /** Prepare to free a B-tree. @param[in] page_id page id @param[in] page_size page size @@ -1249,11 +1236,8 @@ btr_create( PAGE_HEADER + PAGE_BTR_SEG_LEAF, mtr)) { /* Not enough space for new segment, free root segment before return. */ - btr_free_root(block, mtr); - if (!dict_table_is_temporary(index->table)) { - btr_free_root_invalidate(block, mtr); - } - + btr_free_root(block, mtr, + !index->table->is_temporary()); return(FIL_NULL); } @@ -1427,8 +1411,7 @@ btr_free_if_exists( btr_free_but_not_root(root, mtr->get_log_mode()); mtr->set_named_space(page_id.space()); - btr_free_root(root, mtr); - btr_free_root_invalidate(root, mtr); + btr_free_root(root, mtr, true); } /** Free an index tree in a temporary tablespace or during TRUNCATE TABLE. @@ -1448,7 +1431,7 @@ btr_free( if (block) { btr_free_but_not_root(block, MTR_LOG_NO_REDO); - btr_free_root(block, &mtr); + btr_free_root(block, &mtr, false); } mtr.commit(); } |