Skip to content

Commit

Permalink
MDEV-17138 follow-up: Optimize index page creation
Browse files Browse the repository at this point in the history
btr_create(), btr_root_raise_and_insert(): Write a MLOG_MEMSET record
to set FIL_PAGE_PREV,FIL_PAGE_NEXT to FIL_NULL, instead of writing
two MLOG_4BYTES records.

For ROW_FORMAT=COMPRESSED pages, we will not use MLOG_MEMSET
because we want the crash-downgrade to earlier 10.4 releases to succeed.

mlog_parse_nbytes(): Relax the too strict assertion. There is no problem
with MLOG_MEMSET records that affect the uncompressed header of
ROW_FORMAT=COMPRESSED index pages.
  • Loading branch information
dr-m committed Nov 13, 2019
1 parent 2b7aa60 commit 49019dd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
38 changes: 34 additions & 4 deletions storage/innobase/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,23 @@ btr_create(
btr_page_set_index_id(page, page_zip, index_id, mtr);

/* Set the next node and previous node fields */
btr_page_set_next(page, page_zip, FIL_NULL, mtr);
btr_page_set_prev(page, page_zip, FIL_NULL, mtr);
compile_time_assert(FIL_PAGE_NEXT == FIL_PAGE_PREV + 4);
compile_time_assert(FIL_NULL == 0xffffffff);
#if MYSQL_VERSION_ID < 100500
if (UNIV_LIKELY_NULL(page_zip)) {
/* Avoid tripping the ut_a() in mlog_parse_nbytes()
when crash-downgrading to an earlier MariaDB 10.4 version. */
btr_page_set_next(page, page_zip, FIL_NULL, mtr);
btr_page_set_prev(page, page_zip, FIL_NULL, mtr);
} else {
mlog_memset(block, FIL_PAGE_PREV, 8, 0xff, mtr);
}
#else
mlog_memset(block, FIL_PAGE_PREV, 8, 0xff, mtr);
if (UNIV_LIKELY_NULL(page_zip)) {
memset(page_zip->data + FIL_PAGE_PREV, 0xff, 8);
}
#endif

/* We reset the free bits for the page in a separate
mini-transaction to allow creation of several trees in the
Expand Down Expand Up @@ -1934,8 +1949,23 @@ btr_root_raise_and_insert(
btr_page_create(new_block, new_page_zip, index, level, mtr);

/* Set the next node and previous node fields of new page */
btr_page_set_next(new_page, new_page_zip, FIL_NULL, mtr);
btr_page_set_prev(new_page, new_page_zip, FIL_NULL, mtr);
compile_time_assert(FIL_PAGE_NEXT == FIL_PAGE_PREV + 4);
compile_time_assert(FIL_NULL == 0xffffffff);
#if MYSQL_VERSION_ID < 100500
if (UNIV_LIKELY_NULL(new_page_zip)) {
/* Avoid tripping the ut_a() in mlog_parse_nbytes()
when crash-downgrading to an earlier MariaDB 10.4 version. */
btr_page_set_next(new_page, new_page_zip, FIL_NULL, mtr);
btr_page_set_prev(new_page, new_page_zip, FIL_NULL, mtr);
} else {
mlog_memset(new_block, FIL_PAGE_PREV, 8, 0xff, mtr);
}
#else
mlog_memset(new_block, FIL_PAGE_PREV, 8, 0xff, mtr);
if (UNIV_LIKELY_NULL(new_page_zip)) {
memset(new_page_zip->data + FIL_PAGE_PREV, 0xff, 8);
}
#endif

/* Copy the records from root to the new page one by one. */

Expand Down
5 changes: 4 additions & 1 deletion storage/innobase/mtr/mtr0log.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -139,6 +139,7 @@ mlog_parse_nbytes(

ut_ad(type <= MLOG_8BYTES || type == MLOG_MEMSET);
ut_a(!page || !page_zip
|| type == MLOG_MEMSET
|| !fil_page_index_page_check(page));
if (end_ptr < ptr + 2) {
return NULL;
Expand All @@ -164,6 +165,8 @@ mlog_parse_nbytes(
if (page) {
memset(page + offset, *ptr, val);
if (page_zip) {
ut_ad(offset + val <= PAGE_DATA
|| !fil_page_index_page_check(page));
memset(static_cast<page_zip_des_t*>(page_zip)
->data + offset, *ptr, val);
}
Expand Down

0 comments on commit 49019dd

Please sign in to comment.