From 065ba53ccbf3ab468408dc5a5dbcb3741750a02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 26 Mar 2019 13:51:15 +0200 Subject: MDEV-12711 mariabackup --backup is refused for multi-file system tablespace Before MDEV-12113 (MariaDB Server 10.1.25), on shutdown InnoDB would write the current LSN to the first page of each file of the system tablespace. This is incompatible with MariaDB's InnoDB table encryption, because encryption repurposed the field for an encryption key ID and checksum. buf_page_is_corrupted(): For the InnoDB system tablespace, skip FIL_PAGE_FILE_FLUSH_LSN when checking if a page is all zero, because the first page of each file in the system tablespace can contain nonzero bytes in the field. --- storage/innobase/buf/buf0buf.cc | 33 +++++++++++++++++++++++---------- storage/xtradb/buf/buf0buf.cc | 31 +++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 20 deletions(-) (limited to 'storage') diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 621433c1c5c..78200198e62 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -946,18 +946,31 @@ buf_page_is_corrupted( #error "FIL_PAGE_LSN must be 64 bit aligned" #endif - /* declare empty pages non-corrupted */ - if (checksum_field1 == 0 && checksum_field2 == 0 - && *reinterpret_cast(read_buf + - FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ - for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) { - if (read_buf[i] != 0) { - return(true); + /* A page filled with NUL bytes is considered not corrupted. + The FIL_PAGE_FILE_FLUSH_LSN field may be written nonzero for + the first page of each file of the system tablespace. + Ignore it for the system tablespace. */ + if (!checksum_field1 && !checksum_field2) { + ulint i = 0; + do { + if (read_buf[i]) { + return true; } - } + } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - return(false); +#ifndef UNIV_INNOCHECKSUM + if (!space || !space->id) { + /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + in the system tablespace. */ + i += 8; + } +#endif + do { + if (read_buf[i]) { + return true; + } + } while (++i < srv_page_size); + return false; } switch (curr_algo) { diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index f4ef3ca7015..773b528b40d 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -945,18 +945,29 @@ buf_page_is_corrupted( #error "FIL_PAGE_LSN must be 64 bit aligned" #endif - /* declare empty pages non-corrupted */ - if (checksum_field1 == 0 && checksum_field2 == 0 - && *reinterpret_cast(read_buf + - FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ - for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) { - if (read_buf[i] != 0) { - return(true); + /* A page filled with NUL bytes is considered not corrupted. + The FIL_PAGE_FILE_FLUSH_LSN field may be written nonzero for + the first page of each file of the system tablespace. + Ignore it for the system tablespace. */ + if (!checksum_field1 && !checksum_field2) { + ulint i = 0; + do { + if (read_buf[i]) { + return true; } - } + } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - return(false); + if (!space || !space->id) { + /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + in the system tablespace. */ + i += 8; + } + do { + if (read_buf[i]) { + return true; + } + } while (++i < srv_page_size); + return false; } switch (curr_algo) { -- cgit v1.2.1