summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-11-13 18:35:04 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-11-13 18:35:04 +0200
commit49019dde6515aceb53f38a70bf85d29d18ad9095 (patch)
tree9b6d521df72ddc8a87756f624822e812b9e6c84d /storage
parent2b7aa60b7e6973e33b0990926ddfdab8c7715ff9 (diff)
downloadmariadb-git-49019dde6515aceb53f38a70bf85d29d18ad9095.tar.gz
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.
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/btr/btr0btr.cc38
-rw-r--r--storage/innobase/mtr/mtr0log.cc5
2 files changed, 38 insertions, 5 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index b9975bfa194..5477473c0fe 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -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
@@ -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. */
diff --git a/storage/innobase/mtr/mtr0log.cc b/storage/innobase/mtr/mtr0log.cc
index e15b1a2225e..da7088dd7d9 100644
--- a/storage/innobase/mtr/mtr0log.cc
+++ b/storage/innobase/mtr/mtr0log.cc
@@ -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
@@ -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;
@@ -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);
}