1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

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.
This commit is contained in:
Jan Lindström
2016-09-26 12:29:31 +03:00
parent 4e2a0c34b0
commit 452e849522
10 changed files with 148 additions and 30 deletions

View File

@@ -2138,9 +2138,12 @@ func_exit:
if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index)
&& page_is_leaf(buf_block_get_frame(block))) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
&& block) {
buf_frame_t* frame = buf_block_get_frame(block);
if (frame && page_is_leaf(frame)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
}
}
return(err);

View File

@@ -368,12 +368,17 @@ btr_optimistic_scrub(
/* We play safe and reset the free bits */
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);
}
}
scrub_data->scrub_stat.page_reorganizations++;
return DB_SUCCESS;
}
@@ -488,9 +493,13 @@ btr_pessimistic_scrub(
/* We play safe and reset the free bits
* NOTE: need to call this prior to btr_page_split_and_insert */
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(
@@ -788,11 +797,8 @@ btr_scrub_page(
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) !=
scrub_data->current_index->id) {
/* page has been reallocated to new index */

View File

@@ -915,9 +915,15 @@ ibuf_set_free_bits_low(
page_t* bitmap_page;
ulint space;
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;
}
@@ -1091,7 +1097,11 @@ ibuf_update_free_bits_zip(
page_no = buf_block_get_page_no(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);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);

View File

@@ -295,9 +295,17 @@ btr_block_get_func(
@param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \
buf_block_get_frame(btr_block_get(space,zip_size,page_no, \
mode,idx,mtr))
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)
MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
Gets the index id field of a page.

View File

@@ -98,6 +98,38 @@ btr_page_set_index_id(
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 */
/**************************************************************//**

View File

@@ -2281,9 +2281,12 @@ func_exit:
if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index)
&& page_is_leaf(buf_block_get_frame(block))) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
&& block) {
buf_frame_t* frame = buf_block_get_frame(block);
if (frame && page_is_leaf(frame)) {
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_zip(block, mtr);
}
}
return(err);

View File

@@ -368,12 +368,17 @@ btr_optimistic_scrub(
/* We play safe and reset the free bits */
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);
}
}
scrub_data->scrub_stat.page_reorganizations++;
return DB_SUCCESS;
}
@@ -488,9 +493,13 @@ btr_pessimistic_scrub(
/* We play safe and reset the free bits
* NOTE: need to call this prior to btr_page_split_and_insert */
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(
@@ -788,11 +797,8 @@ btr_scrub_page(
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) !=
scrub_data->current_index->id) {
/* page has been reallocated to new index */

View File

@@ -956,9 +956,15 @@ ibuf_set_free_bits_low(
page_t* bitmap_page;
ulint space;
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;
}
@@ -1132,7 +1138,11 @@ ibuf_update_free_bits_zip(
page_no = buf_block_get_page_no(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);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);

View File

@@ -298,9 +298,17 @@ btr_block_get_func(
@param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \
buf_block_get_frame(btr_block_get(space,zip_size,page_no, \
mode,idx,mtr))
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)
MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
Gets the index id field of a page.

View File

@@ -98,6 +98,38 @@ btr_page_set_index_id(
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 */
/**************************************************************//**