Commit 00f0c039 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-15270 Mariabackup should not try to use doublewrite buffer

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.
parent 33f70c4d
...@@ -2908,19 +2908,7 @@ xb_load_tablespaces() ...@@ -2908,19 +2908,7 @@ xb_load_tablespaces()
&flush_lsn); &flush_lsn);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
msg("mariabackup: Could not open or create data files.\n" msg("mariabackup: Could not open 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");
return(err); return(err);
} }
...@@ -3859,7 +3847,7 @@ xtrabackup_backup_func() ...@@ -3859,7 +3847,7 @@ xtrabackup_backup_func()
err = xb_load_tablespaces(); err = xb_load_tablespaces();
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
msg("mariabackup: error: xb_load_tablespaces() failed with" msg("mariabackup: error: xb_load_tablespaces() failed with"
"error code %u\n", err); " error code %u\n", err);
goto fail; goto fail;
} }
......
...@@ -28,7 +28,6 @@ EOF ...@@ -28,7 +28,6 @@ EOF
--remove_files_wildcard $MYSQLD_DATADIR ib_logfile* --remove_files_wildcard $MYSQLD_DATADIR ib_logfile*
--source include/start_mysqld.inc --source include/start_mysqld.inc
let SEARCH_RANGE= -50000;
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
--let SEARCH_PATTERN= InnoDB: New log files created, LSN=175964\d{8} --let SEARCH_PATTERN= InnoDB: New log files created, LSN=175964\d{8}
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -770,6 +770,10 @@ the double write buffer. ...@@ -770,6 +770,10 @@ the double write buffer.
bool bool
Datafile::restore_from_doublewrite() Datafile::restore_from_doublewrite()
{ {
if (srv_operation != SRV_OPERATION_NORMAL) {
return true;
}
/* Find if double write buffer contains page_no of given space id. */ /* 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 byte* page = recv_sys->dblwr.find_page(m_space_id, 0);
const page_id_t page_id(m_space_id, 0); const page_id_t page_id(m_space_id, 0);
......
...@@ -567,8 +567,9 @@ SysTablespace::read_lsn_and_check_flags(lsn_t* flushed_lsn) ...@@ -567,8 +567,9 @@ SysTablespace::read_lsn_and_check_flags(lsn_t* flushed_lsn)
ut_a(it->order() == 0); ut_a(it->order() == 0);
if (srv_operation == SRV_OPERATION_NORMAL) {
buf_dblwr_init_or_load_pages(it->handle(), it->filepath()); buf_dblwr_init_or_load_pages(it->handle(), it->filepath());
}
/* Check the contents of the first page of the /* Check the contents of the first page of the
first datafile. */ first datafile. */
......
...@@ -18571,7 +18571,7 @@ innodb_make_page_dirty( ...@@ -18571,7 +18571,7 @@ innodb_make_page_dirty(
return; return;
} }
if (srv_saved_page_number_debug > space->size) { if (srv_saved_page_number_debug >= space->size) {
fil_space_release(space); fil_space_release(space);
return; return;
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -363,7 +364,7 @@ class Datafile { ...@@ -363,7 +364,7 @@ class Datafile {
@param[in] read_only_mode if true, then readonly mode checks @param[in] read_only_mode if true, then readonly mode checks
are enforced. are enforced.
@return DB_SUCCESS or DB_IO_ERROR if page cannot be read */ @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)); MY_ATTRIBUTE((warn_unused_result));
/** Free the first page from memory when it is no longer needed. */ /** Free the first page from memory when it is no longer needed. */
......
...@@ -3147,7 +3147,9 @@ recv_init_crash_recovery_spaces() ...@@ -3147,7 +3147,9 @@ recv_init_crash_recovery_spaces()
<< "', but there were no modifications either."; << "', 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) { if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
/* Spawn the background thread to flush dirty pages /* Spawn the background thread to flush dirty pages
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. 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 Portions of this file contain modifications contributed and copyrighted
by Percona Inc.. Those modifications are by Percona Inc.. Those modifications are
...@@ -4994,7 +4994,7 @@ os_file_write_func( ...@@ -4994,7 +4994,7 @@ os_file_write_func(
if ((ulint) n_bytes != n && !os_has_said_disk_full) { if ((ulint) n_bytes != n && !os_has_said_disk_full) {
ib::error() ib::error()
<< "Write to file " << name << "failed at offset " << "Write to file " << name << " failed at offset "
<< offset << ", " << n << offset << ", " << n
<< " bytes should have been written," << " bytes should have been written,"
" only " << n_bytes << " were written." " only " << n_bytes << " were written."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment