Commit 452e8495 authored by Jan Lindström's avatar Jan Lindström

MDEV-10886: encryption.innodb-bad-key-change fails (crashes) in buildbot

Problem was that NULL-pointer was accessed inside a macro when
page read from tablespace is encrypted but decrypt fails because
of incorrect key file.

Removed unsafe macro using inlined function where used pointers
are checked.
parent 4e2a0c34
...@@ -2138,9 +2138,12 @@ btr_cur_update_in_place( ...@@ -2138,9 +2138,12 @@ btr_cur_update_in_place(
if (page_zip if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP) && !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index) && !dict_index_is_clust(index)
&& page_is_leaf(buf_block_get_frame(block))) { && block) {
/* Update the free bits in the insert buffer. */ buf_frame_t* frame = buf_block_get_frame(block);
ibuf_update_free_bits_zip(block, mtr); if (frame && page_is_leaf(frame)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
}
} }
return(err); return(err);
......
...@@ -368,12 +368,17 @@ btr_optimistic_scrub( ...@@ -368,12 +368,17 @@ btr_optimistic_scrub(
/* We play safe and reset the free bits */ /* We play safe and reset the free bits */
if (!dict_index_is_clust(index) && if (!dict_index_is_clust(index) &&
page_is_leaf(buf_block_get_frame(block))) { block != NULL) {
buf_frame_t* frame = buf_block_get_frame(block);
if (frame &&
page_is_leaf(frame)) {
ibuf_reset_free_bits(block); ibuf_reset_free_bits(block);
}
} }
scrub_data->scrub_stat.page_reorganizations++; scrub_data->scrub_stat.page_reorganizations++;
return DB_SUCCESS; return DB_SUCCESS;
} }
...@@ -488,9 +493,13 @@ btr_pessimistic_scrub( ...@@ -488,9 +493,13 @@ btr_pessimistic_scrub(
/* We play safe and reset the free bits /* We play safe and reset the free bits
* NOTE: need to call this prior to btr_page_split_and_insert */ * NOTE: need to call this prior to btr_page_split_and_insert */
if (!dict_index_is_clust(index) && if (!dict_index_is_clust(index) &&
page_is_leaf(buf_block_get_frame(block))) { block != NULL) {
buf_frame_t* frame = buf_block_get_frame(block);
if (frame &&
page_is_leaf(frame)) {
ibuf_reset_free_bits(block); ibuf_reset_free_bits(block);
}
} }
rec = btr_page_split_and_insert( rec = btr_page_split_and_insert(
...@@ -788,11 +797,8 @@ btr_scrub_page( ...@@ -788,11 +797,8 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
} }
buf_frame_t* frame = NULL; buf_frame_t* frame = buf_block_get_frame(block);
if (block) {
frame = buf_block_get_frame(block);
}
if (!frame || btr_page_get_index_id(frame) != if (!frame || btr_page_get_index_id(frame) !=
scrub_data->current_index->id) { scrub_data->current_index->id) {
/* page has been reallocated to new index */ /* page has been reallocated to new index */
......
...@@ -915,9 +915,15 @@ ibuf_set_free_bits_low( ...@@ -915,9 +915,15 @@ ibuf_set_free_bits_low(
page_t* bitmap_page; page_t* bitmap_page;
ulint space; ulint space;
ulint page_no; ulint page_no;
buf_frame_t* frame;
if (!page_is_leaf(buf_block_get_frame(block))) { if (!block) {
return;
}
frame = buf_block_get_frame(block);
if (!frame || !page_is_leaf(frame)) {
return; return;
} }
...@@ -1091,7 +1097,11 @@ ibuf_update_free_bits_zip( ...@@ -1091,7 +1097,11 @@ ibuf_update_free_bits_zip(
page_no = buf_block_get_page_no(block); page_no = buf_block_get_page_no(block);
zip_size = buf_block_get_zip_size(block); zip_size = buf_block_get_zip_size(block);
ut_a(page_is_leaf(buf_block_get_frame(block))); ut_a(block);
buf_frame_t* frame = buf_block_get_frame(block);
ut_a(frame && page_is_leaf(frame));
ut_a(zip_size); ut_a(zip_size);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr); bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
......
...@@ -295,9 +295,17 @@ btr_block_get_func( ...@@ -295,9 +295,17 @@ btr_block_get_func(
@param idx index tree, may be NULL if not the insert buffer tree @param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle @param mtr mini-transaction handle
@return the uncompressed page frame */ @return the uncompressed page frame */
# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \ UNIV_INLINE
buf_block_get_frame(btr_block_get(space,zip_size,page_no, \ page_t*
mode,idx,mtr)) btr_page_get(
/*=========*/
ulint space,
ulint zip_size,
ulint root_page_no,
ulint mode,
dict_index_t* index,
mtr_t* mtr)
MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/**************************************************************//** /**************************************************************//**
Gets the index id field of a page. Gets the index id field of a page.
......
...@@ -98,6 +98,38 @@ btr_page_set_index_id( ...@@ -98,6 +98,38 @@ btr_page_set_index_id(
mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr); mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr);
} }
} }
/** Gets a buffer page and declares its latching order level.
@param space tablespace identifier
@param zip_size compressed page size in bytes or 0 for uncompressed pages
@param page_no page number
@param mode latch mode
@param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
ulint space,
ulint zip_size,
ulint root_page_no,
ulint mode,
dict_index_t* index,
mtr_t* mtr)
{
buf_block_t* block=NULL;
buf_frame_t* frame=NULL;
block = btr_block_get(space, zip_size, root_page_no, mode, index, mtr);
if (block) {
frame = buf_block_get_frame(block);
}
return ((page_t*)frame);
}
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/**************************************************************//** /**************************************************************//**
......
...@@ -2281,9 +2281,12 @@ btr_cur_update_in_place( ...@@ -2281,9 +2281,12 @@ btr_cur_update_in_place(
if (page_zip if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP) && !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index) && !dict_index_is_clust(index)
&& page_is_leaf(buf_block_get_frame(block))) { && block) {
/* Update the free bits in the insert buffer. */ buf_frame_t* frame = buf_block_get_frame(block);
ibuf_update_free_bits_zip(block, mtr); if (frame && page_is_leaf(frame)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
}
} }
return(err); return(err);
......
...@@ -368,12 +368,17 @@ btr_optimistic_scrub( ...@@ -368,12 +368,17 @@ btr_optimistic_scrub(
/* We play safe and reset the free bits */ /* We play safe and reset the free bits */
if (!dict_index_is_clust(index) && if (!dict_index_is_clust(index) &&
page_is_leaf(buf_block_get_frame(block))) { block != NULL) {
buf_frame_t* frame = buf_block_get_frame(block);
if (frame &&
page_is_leaf(frame)) {
ibuf_reset_free_bits(block); ibuf_reset_free_bits(block);
}
} }
scrub_data->scrub_stat.page_reorganizations++; scrub_data->scrub_stat.page_reorganizations++;
return DB_SUCCESS; return DB_SUCCESS;
} }
...@@ -488,9 +493,13 @@ btr_pessimistic_scrub( ...@@ -488,9 +493,13 @@ btr_pessimistic_scrub(
/* We play safe and reset the free bits /* We play safe and reset the free bits
* NOTE: need to call this prior to btr_page_split_and_insert */ * NOTE: need to call this prior to btr_page_split_and_insert */
if (!dict_index_is_clust(index) && if (!dict_index_is_clust(index) &&
page_is_leaf(buf_block_get_frame(block))) { block != NULL) {
buf_frame_t* frame = buf_block_get_frame(block);
if (frame &&
page_is_leaf(frame)) {
ibuf_reset_free_bits(block); ibuf_reset_free_bits(block);
}
} }
rec = btr_page_split_and_insert( rec = btr_page_split_and_insert(
...@@ -788,11 +797,8 @@ btr_scrub_page( ...@@ -788,11 +797,8 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
} }
buf_frame_t* frame = NULL; buf_frame_t* frame = buf_block_get_frame(block);
if (block) {
frame = buf_block_get_frame(block);
}
if (!frame || btr_page_get_index_id(frame) != if (!frame || btr_page_get_index_id(frame) !=
scrub_data->current_index->id) { scrub_data->current_index->id) {
/* page has been reallocated to new index */ /* page has been reallocated to new index */
......
...@@ -956,9 +956,15 @@ ibuf_set_free_bits_low( ...@@ -956,9 +956,15 @@ ibuf_set_free_bits_low(
page_t* bitmap_page; page_t* bitmap_page;
ulint space; ulint space;
ulint page_no; ulint page_no;
buf_frame_t* frame;
if (!page_is_leaf(buf_block_get_frame(block))) { if (!block) {
return;
}
frame = buf_block_get_frame(block);
if (!frame || !page_is_leaf(frame)) {
return; return;
} }
...@@ -1132,7 +1138,11 @@ ibuf_update_free_bits_zip( ...@@ -1132,7 +1138,11 @@ ibuf_update_free_bits_zip(
page_no = buf_block_get_page_no(block); page_no = buf_block_get_page_no(block);
zip_size = buf_block_get_zip_size(block); zip_size = buf_block_get_zip_size(block);
ut_a(page_is_leaf(buf_block_get_frame(block))); ut_a(block);
buf_frame_t* frame = buf_block_get_frame(block);
ut_a(frame && page_is_leaf(frame));
ut_a(zip_size); ut_a(zip_size);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr); bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
......
...@@ -298,9 +298,17 @@ btr_block_get_func( ...@@ -298,9 +298,17 @@ btr_block_get_func(
@param idx index tree, may be NULL if not the insert buffer tree @param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle @param mtr mini-transaction handle
@return the uncompressed page frame */ @return the uncompressed page frame */
# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \ UNIV_INLINE
buf_block_get_frame(btr_block_get(space,zip_size,page_no, \ page_t*
mode,idx,mtr)) btr_page_get(
/*=========*/
ulint space,
ulint zip_size,
ulint root_page_no,
ulint mode,
dict_index_t* index,
mtr_t* mtr)
MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/**************************************************************//** /**************************************************************//**
Gets the index id field of a page. Gets the index id field of a page.
......
...@@ -98,6 +98,38 @@ btr_page_set_index_id( ...@@ -98,6 +98,38 @@ btr_page_set_index_id(
mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr); mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr);
} }
} }
/** Gets a buffer page and declares its latching order level.
@param space tablespace identifier
@param zip_size compressed page size in bytes or 0 for uncompressed pages
@param page_no page number
@param mode latch mode
@param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
ulint space,
ulint zip_size,
ulint root_page_no,
ulint mode,
dict_index_t* index,
mtr_t* mtr)
{
buf_block_t* block=NULL;
buf_frame_t* frame=NULL;
block = btr_block_get(space, zip_size, root_page_no, mode, index, mtr);
if (block) {
frame = buf_block_get_frame(block);
}
return ((page_t*)frame);
}
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/**************************************************************//** /**************************************************************//**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment