summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-01-23 16:14:28 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-01-23 16:25:46 +0200
commit1d12bff42c7dd73b2a0158d6780267467b9e0871 (patch)
tree0145c0d7a84eee3147118759179eac6f4b52245c /storage
parent7c166e68aaf51bd9c1b3152ba9674fcc261f3d84 (diff)
downloadmariadb-git-1d12bff42c7dd73b2a0158d6780267467b9e0871.tar.gz
MDEV-20775: page_zip_validate() failure due to AUTO_INCREMENT
cmake -DWITH_INNODB_EXTRA_DEBUG:BOOL=ON was broken ever since commit 8777458a6eb73ac1d7d864ebac390ea7039e21c1 (MDEV-6076 Persistent AUTO_INCREMENT for InnoDB). There is a race condition between page reads that call page_zip_validate() (while holding clustered index root page S-latch) and writes that update PAGE_ROOT_AUTO_INC (with buf_block_t::lock SX-latch, compatible with S-latch). page_zip_validate_low(): Skip the PAGE_ROOT_AUTO_INC field on clustered index root pages in order to avoid false positives.
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/page/page0zip.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index 1c0c8f75f78..7a017913dfe 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2014, 2019, MariaDB Corporation.
+Copyright (c) 2014, 2020, 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
@@ -3336,7 +3336,19 @@ page_zip_validate_low(
FIL_PAGE_LSN - FIL_PAGE_PREV)
|| memcmp(page_zip->data + FIL_PAGE_TYPE, page + FIL_PAGE_TYPE, 2)
|| memcmp(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA,
- PAGE_DATA - FIL_PAGE_DATA)) {
+ PAGE_ROOT_AUTO_INC)
+ /* The PAGE_ROOT_AUTO_INC can be updated while holding an SX-latch
+ on the clustered index root page (page number 3 in .ibd files).
+ That allows concurrent readers (holding buf_block_t::lock S-latch).
+ Because we do not know what type of a latch our caller is holding,
+ we will ignore the field on clustered index root pages in order
+ to avoid false positives. */
+ || (page_get_page_no(page) != 3/* clustered index root page */
+ && memcmp(&page_zip->data[FIL_PAGE_DATA + PAGE_ROOT_AUTO_INC],
+ &page[FIL_PAGE_DATA + PAGE_ROOT_AUTO_INC], 8))
+ || memcmp(&page_zip->data[FIL_PAGE_DATA + PAGE_HEADER_PRIV_END],
+ &page[FIL_PAGE_DATA + PAGE_HEADER_PRIV_END],
+ PAGE_DATA - FIL_PAGE_DATA - PAGE_HEADER_PRIV_END)) {
page_zip_fail(("page_zip_validate: page header\n"));
page_zip_hexdump(page_zip, sizeof *page_zip);
page_zip_hexdump(page_zip->data, page_zip_get_size(page_zip));