mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
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.
This commit is contained in:
@@ -1671,15 +1671,24 @@ btr_cur_pessimistic_insert(
|
||||
btr_cur_get_page_zip(cursor),
|
||||
thr_get_trx(thr)->id, mtr);
|
||||
}
|
||||
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
|
||||
|| btr_page_get_prev(
|
||||
buf_block_get_frame(
|
||||
btr_cur_get_block(cursor)), mtr)
|
||||
== FIL_NULL) {
|
||||
|
||||
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) {
|
||||
/* split and inserted need to call
|
||||
lock_update_insert() always. */
|
||||
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
|
||||
lock_update_insert() always. */
|
||||
if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) {
|
||||
inherit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BTR_CUR_ADAPT
|
||||
|
||||
@@ -220,8 +220,12 @@ btr_defragment_add_index(
|
||||
|
||||
mtr_start(&mtr);
|
||||
// Load index rood page.
|
||||
page_t* page = btr_page_get(space, zip_size, page_no,
|
||||
RW_NO_LATCH, index, &mtr);
|
||||
buf_block_t* block = btr_block_get(space, zip_size, page_no, RW_NO_LATCH, index, &mtr);
|
||||
page_t* page = NULL;
|
||||
|
||||
if (block) {
|
||||
page = buf_block_get_frame(block);
|
||||
}
|
||||
|
||||
if (page == NULL && index->table->is_encrypted) {
|
||||
mtr_commit(&mtr);
|
||||
|
||||
@@ -750,9 +750,13 @@ btr_scrub_page(
|
||||
mtr_t* mtr) /*!< in: mtr */
|
||||
{
|
||||
/* recheck if page needs scrubbing (knowing allocation status) */
|
||||
int needs_scrubbing = btr_page_needs_scrubbing(
|
||||
scrub_data, block, allocated);
|
||||
if (needs_scrubbing != BTR_SCRUB_PAGE) {
|
||||
int needs_scrubbing = BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
|
||||
|
||||
if (block) {
|
||||
btr_page_needs_scrubbing(scrub_data, block, allocated);
|
||||
}
|
||||
|
||||
if (!block || needs_scrubbing != BTR_SCRUB_PAGE) {
|
||||
mtr_commit(mtr);
|
||||
return needs_scrubbing;
|
||||
}
|
||||
@@ -784,7 +788,12 @@ btr_scrub_page(
|
||||
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) {
|
||||
/* page has been reallocated to new index */
|
||||
mtr_commit(mtr);
|
||||
|
||||
@@ -1795,15 +1795,24 @@ btr_cur_pessimistic_insert(
|
||||
btr_cur_get_page_zip(cursor),
|
||||
thr_get_trx(thr)->id, mtr);
|
||||
}
|
||||
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))
|
||||
|| btr_page_get_prev(
|
||||
buf_block_get_frame(
|
||||
btr_cur_get_block(cursor)), mtr)
|
||||
== FIL_NULL) {
|
||||
|
||||
if (!page_rec_is_infimum(btr_cur_get_rec(cursor))) {
|
||||
/* split and inserted need to call
|
||||
lock_update_insert() always. */
|
||||
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
|
||||
lock_update_insert() always. */
|
||||
if (frame && btr_page_get_prev(frame, mtr) == FIL_NULL) {
|
||||
inherit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BTR_CUR_ADAPT
|
||||
|
||||
@@ -220,8 +220,12 @@ btr_defragment_add_index(
|
||||
|
||||
mtr_start(&mtr);
|
||||
// Load index rood page.
|
||||
page_t* page = btr_page_get(space, zip_size, page_no,
|
||||
RW_NO_LATCH, index, &mtr);
|
||||
buf_block_t* block = btr_block_get(space, zip_size, page_no, RW_NO_LATCH, index, &mtr);
|
||||
page_t* page = NULL;
|
||||
|
||||
if (block) {
|
||||
page = buf_block_get_frame(block);
|
||||
}
|
||||
|
||||
if (page == NULL && index->table->is_encrypted) {
|
||||
mtr_commit(&mtr);
|
||||
|
||||
@@ -750,9 +750,13 @@ btr_scrub_page(
|
||||
mtr_t* mtr) /*!< in: mtr */
|
||||
{
|
||||
/* recheck if page needs scrubbing (knowing allocation status) */
|
||||
int needs_scrubbing = btr_page_needs_scrubbing(
|
||||
scrub_data, block, allocated);
|
||||
if (needs_scrubbing != BTR_SCRUB_PAGE) {
|
||||
int needs_scrubbing = BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
|
||||
|
||||
if (block) {
|
||||
btr_page_needs_scrubbing(scrub_data, block, allocated);
|
||||
}
|
||||
|
||||
if (!block || needs_scrubbing != BTR_SCRUB_PAGE) {
|
||||
mtr_commit(mtr);
|
||||
return needs_scrubbing;
|
||||
}
|
||||
@@ -784,7 +788,12 @@ btr_scrub_page(
|
||||
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) {
|
||||
/* page has been reallocated to new index */
|
||||
mtr_commit(mtr);
|
||||
|
||||
Reference in New Issue
Block a user