Skip to content

Commit 49019dd

Browse files
committed
MDEV-17138 follow-up: Optimize index page creation
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.
1 parent 2b7aa60 commit 49019dd

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

storage/innobase/btr/btr0btr.cc

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,23 @@ btr_create(
11561156
btr_page_set_index_id(page, page_zip, index_id, mtr);
11571157

11581158
/* Set the next node and previous node fields */
1159-
btr_page_set_next(page, page_zip, FIL_NULL, mtr);
1160-
btr_page_set_prev(page, page_zip, FIL_NULL, mtr);
1159+
compile_time_assert(FIL_PAGE_NEXT == FIL_PAGE_PREV + 4);
1160+
compile_time_assert(FIL_NULL == 0xffffffff);
1161+
#if MYSQL_VERSION_ID < 100500
1162+
if (UNIV_LIKELY_NULL(page_zip)) {
1163+
/* Avoid tripping the ut_a() in mlog_parse_nbytes()
1164+
when crash-downgrading to an earlier MariaDB 10.4 version. */
1165+
btr_page_set_next(page, page_zip, FIL_NULL, mtr);
1166+
btr_page_set_prev(page, page_zip, FIL_NULL, mtr);
1167+
} else {
1168+
mlog_memset(block, FIL_PAGE_PREV, 8, 0xff, mtr);
1169+
}
1170+
#else
1171+
mlog_memset(block, FIL_PAGE_PREV, 8, 0xff, mtr);
1172+
if (UNIV_LIKELY_NULL(page_zip)) {
1173+
memset(page_zip->data + FIL_PAGE_PREV, 0xff, 8);
1174+
}
1175+
#endif
11611176

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

19361951
/* Set the next node and previous node fields of new page */
1937-
btr_page_set_next(new_page, new_page_zip, FIL_NULL, mtr);
1938-
btr_page_set_prev(new_page, new_page_zip, FIL_NULL, mtr);
1952+
compile_time_assert(FIL_PAGE_NEXT == FIL_PAGE_PREV + 4);
1953+
compile_time_assert(FIL_NULL == 0xffffffff);
1954+
#if MYSQL_VERSION_ID < 100500
1955+
if (UNIV_LIKELY_NULL(new_page_zip)) {
1956+
/* Avoid tripping the ut_a() in mlog_parse_nbytes()
1957+
when crash-downgrading to an earlier MariaDB 10.4 version. */
1958+
btr_page_set_next(new_page, new_page_zip, FIL_NULL, mtr);
1959+
btr_page_set_prev(new_page, new_page_zip, FIL_NULL, mtr);
1960+
} else {
1961+
mlog_memset(new_block, FIL_PAGE_PREV, 8, 0xff, mtr);
1962+
}
1963+
#else
1964+
mlog_memset(new_block, FIL_PAGE_PREV, 8, 0xff, mtr);
1965+
if (UNIV_LIKELY_NULL(new_page_zip)) {
1966+
memset(new_page_zip->data + FIL_PAGE_PREV, 0xff, 8);
1967+
}
1968+
#endif
19391969

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

storage/innobase/mtr/mtr0log.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2017, 2018, MariaDB Corporation.
4+
Copyright (c) 2017, 2019, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -139,6 +139,7 @@ mlog_parse_nbytes(
139139

140140
ut_ad(type <= MLOG_8BYTES || type == MLOG_MEMSET);
141141
ut_a(!page || !page_zip
142+
|| type == MLOG_MEMSET
142143
|| !fil_page_index_page_check(page));
143144
if (end_ptr < ptr + 2) {
144145
return NULL;
@@ -164,6 +165,8 @@ mlog_parse_nbytes(
164165
if (page) {
165166
memset(page + offset, *ptr, val);
166167
if (page_zip) {
168+
ut_ad(offset + val <= PAGE_DATA
169+
|| !fil_page_index_page_check(page));
167170
memset(static_cast<page_zip_des_t*>(page_zip)
168171
->data + offset, *ptr, val);
169172
}

0 commit comments

Comments
 (0)