summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-02-12 16:40:05 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-02-12 16:56:01 +0200
commit00f0c039d2f4213ccf0a0202349ecb162a799989 (patch)
tree6a2c82488899d0162ddf4e015414113da89ad14d
parent33f70c4d9c42b6e4da062312e1e4a4fb370313df (diff)
downloadmariadb-git-00f0c039d2f4213ccf0a0202349ecb162a799989.tar.gz
MDEV-15270 Mariabackup should not try to use doublewrite buffermariadb-10.2.13
When Mariabackup gets a bad read of the first page of the system tablespace file, it would inappropriately try to apply the doublewrite buffer and write changes back to the data file (to the source file)! This is very wrong and must be prevented. The correct action would be to retry reading the system tablespace as well as any other files whose first page was read incorrectly. Fixing this was not attempted. xb_load_tablespaces(): Shorten a bogus message to be more relevant. The message can be displayed by --backup or --prepare. xtrabackup_backup_func(), os_file_write_func(): Add a missing space to a message. Datafile::restore_from_doublewrite(): Do not even attempt the operation in Mariabackup. recv_init_crash_recovery_spaces(): Do not attempt to restore the doublewrite buffer in Mariabackup (--prepare or --export), because all pages should have been copied correctly in --backup already, and because --backup should ignore the doublewrite buffer. SysTablespace::read_lsn_and_check_flags(): Do not attempt to initialize the doublewrite buffer in Mariabackup. innodb_make_page_dirty(): Correct the bounds check. Datafile::read_first_page(): Correct the name of the parameter.
-rw-r--r--extra/mariabackup/xtrabackup.cc16
-rw-r--r--mysql-test/suite/mariabackup/huge_lsn.test1
-rw-r--r--storage/innobase/fsp/fsp0file.cc6
-rw-r--r--storage/innobase/fsp/fsp0sysspace.cc5
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/innobase/include/fsp0file.h3
-rw-r--r--storage/innobase/log/log0recv.cc4
-rw-r--r--storage/innobase/os/os0file.cc4
8 files changed, 18 insertions, 23 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 2d2734e0f30..7ac168b1778 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -2908,19 +2908,7 @@ xb_load_tablespaces()
&flush_lsn);
if (err != DB_SUCCESS) {
- msg("mariabackup: Could not open or create data files.\n"
- "mariabackup: If you tried to add new data files, and it "
- "failed here,\n"
- "mariabackup: you should now edit innodb_data_file_path in "
- "my.cnf back\n"
- "mariabackup: to what it was, and remove the new ibdata "
- "files InnoDB created\n"
- "mariabackup: in this failed attempt. InnoDB only wrote "
- "those files full of\n"
- "mariabackup: zeros, but did not yet use them in any way. "
- "But be careful: do not\n"
- "mariabackup: remove old data files which contain your "
- "precious data!\n");
+ msg("mariabackup: Could not open data files.\n");
return(err);
}
@@ -3859,7 +3847,7 @@ reread_log_header:
err = xb_load_tablespaces();
if (err != DB_SUCCESS) {
msg("mariabackup: error: xb_load_tablespaces() failed with"
- "error code %u\n", err);
+ " error code %u\n", err);
goto fail;
}
diff --git a/mysql-test/suite/mariabackup/huge_lsn.test b/mysql-test/suite/mariabackup/huge_lsn.test
index 417d40c8e7a..9e72f0ad8d0 100644
--- a/mysql-test/suite/mariabackup/huge_lsn.test
+++ b/mysql-test/suite/mariabackup/huge_lsn.test
@@ -28,7 +28,6 @@ EOF
--remove_files_wildcard $MYSQLD_DATADIR ib_logfile*
--source include/start_mysqld.inc
-let SEARCH_RANGE= -50000;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--let SEARCH_PATTERN= InnoDB: New log files created, LSN=175964\d{8}
--source include/search_pattern_in_file.inc
diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc
index c21c9497735..eaadaad851d 100644
--- a/storage/innobase/fsp/fsp0file.cc
+++ b/storage/innobase/fsp/fsp0file.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2017, 2018, 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
@@ -770,6 +770,10 @@ the double write buffer.
bool
Datafile::restore_from_doublewrite()
{
+ if (srv_operation != SRV_OPERATION_NORMAL) {
+ return true;
+ }
+
/* Find if double write buffer contains page_no of given space id. */
const byte* page = recv_sys->dblwr.find_page(m_space_id, 0);
const page_id_t page_id(m_space_id, 0);
diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc
index c459c8296e0..e9f04cbd6c5 100644
--- a/storage/innobase/fsp/fsp0sysspace.cc
+++ b/storage/innobase/fsp/fsp0sysspace.cc
@@ -567,8 +567,9 @@ SysTablespace::read_lsn_and_check_flags(lsn_t* flushed_lsn)
ut_a(it->order() == 0);
-
- buf_dblwr_init_or_load_pages(it->handle(), it->filepath());
+ if (srv_operation == SRV_OPERATION_NORMAL) {
+ buf_dblwr_init_or_load_pages(it->handle(), it->filepath());
+ }
/* Check the contents of the first page of the
first datafile. */
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index fae784ff12c..d256f42f2f6 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -18571,7 +18571,7 @@ innodb_make_page_dirty(
return;
}
- if (srv_saved_page_number_debug > space->size) {
+ if (srv_saved_page_number_debug >= space->size) {
fil_space_release(space);
return;
}
diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h
index 1f057be0877..68e9f687fcd 100644
--- a/storage/innobase/include/fsp0file.h
+++ b/storage/innobase/include/fsp0file.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2018, 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
@@ -363,7 +364,7 @@ private:
@param[in] read_only_mode if true, then readonly mode checks
are enforced.
@return DB_SUCCESS or DB_IO_ERROR if page cannot be read */
- dberr_t read_first_page(bool read_first_page)
+ dberr_t read_first_page(bool read_only_mode)
MY_ATTRIBUTE((warn_unused_result));
/** Free the first page from memory when it is no longer needed. */
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 818a0f0422e..e55c01aca3a 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -3147,7 +3147,9 @@ recv_init_crash_recovery_spaces()
<< "', but there were no modifications either.";
}
- buf_dblwr_process();
+ if (srv_operation == SRV_OPERATION_NORMAL) {
+ buf_dblwr_process();
+ }
if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
/* Spawn the background thread to flush dirty pages
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 51227696c1c..a824afc6e0e 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation.
+Copyright (c) 2013, 2018, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are
@@ -4994,7 +4994,7 @@ os_file_write_func(
if ((ulint) n_bytes != n && !os_has_said_disk_full) {
ib::error()
- << "Write to file " << name << "failed at offset "
+ << "Write to file " << name << " failed at offset "
<< offset << ", " << n
<< " bytes should have been written,"
" only " << n_bytes << " were written."