Commit 9e6f3df5 authored by Jan Lindström's avatar Jan Lindström

MDEV-8799: Server crashes in btr_defragment_add_index,...

MDEV-8799: Server crashes in btr_defragment_add_index, encryption.innodb-bad-key-change5 and alike fail in buildbot

Problem was unsafe access to NULL pointer. Added additional checks to avoid
access to NULL pointer.
parent 3a0df3cf
...@@ -1671,13 +1671,22 @@ btr_cur_pessimistic_insert( ...@@ -1671,13 +1671,22 @@ btr_cur_pessimistic_insert(
btr_cur_get_page_zip(cursor), btr_cur_get_page_zip(cursor),
thr_get_trx(thr)->id, mtr); thr_get_trx(thr)->id, mtr);
} }
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
|| btr_page_get_prev( if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) {
buf_block_get_frame( /* split and inserted need to call
btr_cur_get_block(cursor)), mtr) lock_update_insert() always. */
== FIL_NULL) { inherit = TRUE;
}
buf_block_t* block = btr_cur_get_block(cursor);
buf_frame_t* frame = NULL;
if (block) {
frame = buf_block_get_frame(block);
}
/* split and inserted need to call /* split and inserted need to call
lock_update_insert() always. */ lock_update_insert() always. */
if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) {
inherit = TRUE; inherit = TRUE;
} }
} }
......
...@@ -220,8 +220,12 @@ btr_defragment_add_index( ...@@ -220,8 +220,12 @@ btr_defragment_add_index(
mtr_start(&mtr); mtr_start(&mtr);
// Load index rood page. // Load index rood page.
page_t* page = btr_page_get(space, zip_size, page_no, buf_block_t* block = btr_block_get(space, zip_size, page_no, RW_NO_LATCH, index, &mtr);
RW_NO_LATCH, index, &mtr); page_t* page = NULL;
if (block) {
page = buf_block_get_frame(block);
}
if (page == NULL && index->table->is_encrypted) { if (page == NULL && index->table->is_encrypted) {
mtr_commit(&mtr); mtr_commit(&mtr);
......
...@@ -750,9 +750,13 @@ btr_scrub_page( ...@@ -750,9 +750,13 @@ btr_scrub_page(
mtr_t* mtr) /*!< in: mtr */ mtr_t* mtr) /*!< in: mtr */
{ {
/* recheck if page needs scrubbing (knowing allocation status) */ /* recheck if page needs scrubbing (knowing allocation status) */
int needs_scrubbing = btr_page_needs_scrubbing( int needs_scrubbing = BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
scrub_data, block, allocated);
if (needs_scrubbing != BTR_SCRUB_PAGE) { if (block) {
btr_page_needs_scrubbing(scrub_data, block, allocated);
}
if (!block || needs_scrubbing != BTR_SCRUB_PAGE) {
mtr_commit(mtr); mtr_commit(mtr);
return needs_scrubbing; return needs_scrubbing;
} }
...@@ -784,7 +788,12 @@ btr_scrub_page( ...@@ -784,7 +788,12 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
} }
if (btr_page_get_index_id(buf_block_get_frame(block)) != buf_frame_t* frame = NULL;
if (block) {
frame = buf_block_get_frame(block);
}
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 */
mtr_commit(mtr); mtr_commit(mtr);
......
...@@ -1795,13 +1795,22 @@ btr_cur_pessimistic_insert( ...@@ -1795,13 +1795,22 @@ btr_cur_pessimistic_insert(
btr_cur_get_page_zip(cursor), btr_cur_get_page_zip(cursor),
thr_get_trx(thr)->id, mtr); thr_get_trx(thr)->id, mtr);
} }
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
|| btr_page_get_prev( if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) {
buf_block_get_frame( /* split and inserted need to call
btr_cur_get_block(cursor)), mtr) lock_update_insert() always. */
== FIL_NULL) { inherit = TRUE;
}
buf_block_t* block = btr_cur_get_block(cursor);
buf_frame_t* frame = NULL;
if (block) {
frame = buf_block_get_frame(block);
}
/* split and inserted need to call /* split and inserted need to call
lock_update_insert() always. */ lock_update_insert() always. */
if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) {
inherit = TRUE; inherit = TRUE;
} }
} }
......
...@@ -220,8 +220,12 @@ btr_defragment_add_index( ...@@ -220,8 +220,12 @@ btr_defragment_add_index(
mtr_start(&mtr); mtr_start(&mtr);
// Load index rood page. // Load index rood page.
page_t* page = btr_page_get(space, zip_size, page_no, buf_block_t* block = btr_block_get(space, zip_size, page_no, RW_NO_LATCH, index, &mtr);
RW_NO_LATCH, index, &mtr); page_t* page = NULL;
if (block) {
page = buf_block_get_frame(block);
}
if (page == NULL && index->table->is_encrypted) { if (page == NULL && index->table->is_encrypted) {
mtr_commit(&mtr); mtr_commit(&mtr);
......
...@@ -750,9 +750,13 @@ btr_scrub_page( ...@@ -750,9 +750,13 @@ btr_scrub_page(
mtr_t* mtr) /*!< in: mtr */ mtr_t* mtr) /*!< in: mtr */
{ {
/* recheck if page needs scrubbing (knowing allocation status) */ /* recheck if page needs scrubbing (knowing allocation status) */
int needs_scrubbing = btr_page_needs_scrubbing( int needs_scrubbing = BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
scrub_data, block, allocated);
if (needs_scrubbing != BTR_SCRUB_PAGE) { if (block) {
btr_page_needs_scrubbing(scrub_data, block, allocated);
}
if (!block || needs_scrubbing != BTR_SCRUB_PAGE) {
mtr_commit(mtr); mtr_commit(mtr);
return needs_scrubbing; return needs_scrubbing;
} }
...@@ -784,7 +788,12 @@ btr_scrub_page( ...@@ -784,7 +788,12 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE; return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
} }
if (btr_page_get_index_id(buf_block_get_frame(block)) != buf_frame_t* frame = NULL;
if (block) {
frame = buf_block_get_frame(block);
}
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 */
mtr_commit(mtr); mtr_commit(mtr);
......
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