2017-04-18 20:43:20 +02:00
|
|
|
/******************************************************
|
2017-10-25 08:06:45 +02:00
|
|
|
MariaBackup: hot backup tool for InnoDB
|
2017-04-18 20:43:20 +02:00
|
|
|
(c) 2009-2013 Percona LLC and/or its affiliates.
|
|
|
|
Originally Created 3/3/2009 Yasufumi Kinoshita
|
|
|
|
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
|
|
|
|
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
|
|
|
|
|
|
|
|
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 Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-05-11 21:19:05 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
|
2017-04-18 20:43:20 +02:00
|
|
|
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
/* Page write filters implementation */
|
|
|
|
|
2017-08-21 16:57:08 +02:00
|
|
|
#include <my_global.h>
|
2017-04-18 20:43:20 +02:00
|
|
|
#include <my_base.h>
|
|
|
|
#include "common.h"
|
|
|
|
#include "write_filt.h"
|
|
|
|
#include "fil_cur.h"
|
|
|
|
#include "xtrabackup.h"
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Write-through page write filter. */
|
2023-04-12 09:40:46 +02:00
|
|
|
static my_bool wf_wt_init(ds_ctxt *ds_meta,
|
|
|
|
xb_write_filt_ctxt_t *ctxt, char *dst_name,
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_fil_cur_t *cursor, CorruptedPages *corrupted_pages);
|
2017-04-18 20:43:20 +02:00
|
|
|
static my_bool wf_wt_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile);
|
|
|
|
|
|
|
|
xb_write_filt_t wf_write_through = {
|
|
|
|
&wf_wt_init,
|
|
|
|
&wf_wt_process,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Incremental page write filter. */
|
2023-04-12 09:40:46 +02:00
|
|
|
static my_bool wf_incremental_init(ds_ctxt *ds_meta,
|
|
|
|
xb_write_filt_ctxt_t *ctxt, char *dst_name,
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_fil_cur_t *cursor, CorruptedPages *corrupted_pages);
|
2017-04-18 20:43:20 +02:00
|
|
|
static my_bool wf_incremental_process(xb_write_filt_ctxt_t *ctxt,
|
|
|
|
ds_file_t *dstfile);
|
|
|
|
static my_bool wf_incremental_finalize(xb_write_filt_ctxt_t *ctxt,
|
|
|
|
ds_file_t *dstfile);
|
|
|
|
static void wf_incremental_deinit(xb_write_filt_ctxt_t *ctxt);
|
|
|
|
|
|
|
|
xb_write_filt_t wf_incremental = {
|
|
|
|
&wf_incremental_init,
|
|
|
|
&wf_incremental_process,
|
|
|
|
&wf_incremental_finalize,
|
|
|
|
&wf_incremental_deinit
|
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Initialize incremental page write filter.
|
|
|
|
|
|
|
|
@return TRUE on success, FALSE on error. */
|
|
|
|
static my_bool
|
2023-04-12 09:40:46 +02:00
|
|
|
wf_incremental_init(ds_ctxt *ds_meta,
|
|
|
|
xb_write_filt_ctxt_t *ctxt, char *dst_name,
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_fil_cur_t *cursor, CorruptedPages *corrupted_pages)
|
2017-04-18 20:43:20 +02:00
|
|
|
{
|
|
|
|
char meta_name[FN_REFLEN];
|
|
|
|
xb_wf_incremental_ctxt_t *cp =
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
&(ctxt->wf_incremental_ctxt);
|
2017-04-18 20:43:20 +02:00
|
|
|
|
|
|
|
ctxt->cursor = cursor;
|
|
|
|
|
|
|
|
/* allocate buffer for incremental backup (4096 pages) */
|
2019-02-06 18:50:11 +01:00
|
|
|
cp->delta_buf_size = (cursor->page_size / 4) * cursor->page_size;
|
2020-04-02 21:54:08 +02:00
|
|
|
cp->delta_buf = (unsigned char *)my_large_malloc(&cp->delta_buf_size, MYF(0));
|
2017-11-09 19:59:08 +01:00
|
|
|
|
|
|
|
if (!cp->delta_buf) {
|
2019-01-14 22:28:23 +01:00
|
|
|
msg(cursor->thread_n,"Can't allocate %zu bytes",
|
|
|
|
(size_t) cp->delta_buf_size);
|
2017-11-09 19:59:08 +01:00
|
|
|
return (FALSE);
|
|
|
|
}
|
2017-04-18 20:43:20 +02:00
|
|
|
|
|
|
|
/* write delta meta info */
|
|
|
|
snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,
|
|
|
|
XB_DELTA_INFO_SUFFIX);
|
2019-02-06 18:50:11 +01:00
|
|
|
const xb_delta_info_t info(cursor->page_size, cursor->zip_size,
|
|
|
|
cursor->space_id);
|
2023-04-12 09:40:46 +02:00
|
|
|
if (!xb_write_delta_metadata(ds_meta, meta_name, &info)) {
|
2019-01-14 22:28:23 +01:00
|
|
|
msg(cursor->thread_n,"Error: "
|
|
|
|
"failed to write meta info for %s",
|
|
|
|
cursor->rel_path);
|
2017-04-18 20:43:20 +02:00
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* change the target file name, since we are only going to write
|
|
|
|
delta pages */
|
|
|
|
strcat(dst_name, ".delta");
|
|
|
|
|
|
|
|
mach_write_to_4(cp->delta_buf, 0x78747261UL); /*"xtra"*/
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
|
2017-04-18 20:43:20 +02:00
|
|
|
cp->npages = 1;
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
cp->corrupted_pages = corrupted_pages;
|
2017-04-18 20:43:20 +02:00
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Run the next batch of pages through incremental page write filter.
|
|
|
|
|
|
|
|
@return TRUE on success, FALSE on error. */
|
|
|
|
static my_bool
|
|
|
|
wf_incremental_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
|
|
|
|
{
|
2020-12-02 17:29:49 +01:00
|
|
|
unsigned i;
|
2017-04-18 20:43:20 +02:00
|
|
|
xb_fil_cur_t *cursor = ctxt->cursor;
|
|
|
|
byte *page;
|
2019-02-06 18:50:11 +01:00
|
|
|
const ulint page_size = cursor->page_size;
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_wf_incremental_ctxt_t *cp = &(ctxt->wf_incremental_ctxt);
|
2017-04-18 20:43:20 +02:00
|
|
|
|
|
|
|
for (i = 0, page = cursor->buf; i < cursor->buf_npages;
|
|
|
|
i++, page += page_size) {
|
|
|
|
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
if ((!cp->corrupted_pages ||
|
2021-07-22 10:22:47 +02:00
|
|
|
!cp->corrupted_pages->contains({cursor->node->space->id,
|
|
|
|
cursor->buf_page_no + i})) &&
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
incremental_lsn >= mach_read_from_8(page + FIL_PAGE_LSN))
|
2017-04-18 20:43:20 +02:00
|
|
|
continue;
|
|
|
|
|
2022-10-24 17:16:43 +02:00
|
|
|
/* Check whether TRX_SYS page has been changed */
|
|
|
|
if (mach_read_from_4(page + FIL_PAGE_SPACE_ID)
|
|
|
|
== TRX_SYS_SPACE
|
|
|
|
&& mach_read_from_4(page + FIL_PAGE_OFFSET)
|
|
|
|
== TRX_SYS_PAGE_NO) {
|
|
|
|
msg(cursor->thread_n,
|
|
|
|
"--incremental backup is impossible if "
|
|
|
|
"the server had been restarted with "
|
|
|
|
"different innodb_undo_tablespaces.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-12-03 13:09:43 +01:00
|
|
|
/* Check whether TRX_SYS page has been changed */
|
|
|
|
if (mach_read_from_4(page + FIL_PAGE_SPACE_ID)
|
|
|
|
== TRX_SYS_SPACE
|
|
|
|
&& mach_read_from_4(page + FIL_PAGE_OFFSET)
|
|
|
|
== TRX_SYS_PAGE_NO) {
|
|
|
|
msg(cursor->thread_n,
|
|
|
|
"--incremental backup is impossible if "
|
|
|
|
"the server had been restarted with "
|
|
|
|
"different innodb_undo_tablespaces.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-18 20:43:20 +02:00
|
|
|
/* updated page */
|
|
|
|
if (cp->npages == page_size / 4) {
|
|
|
|
/* flush buffer */
|
|
|
|
if (ds_write(dstfile, cp->delta_buf,
|
|
|
|
cp->npages * page_size)) {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear buffer */
|
|
|
|
memset(cp->delta_buf, 0, page_size / 4 * page_size);
|
|
|
|
/*"xtra"*/
|
|
|
|
mach_write_to_4(cp->delta_buf, 0x78747261UL);
|
|
|
|
cp->npages = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mach_write_to_4(cp->delta_buf + cp->npages * 4,
|
|
|
|
cursor->buf_page_no + i);
|
|
|
|
memcpy(cp->delta_buf + cp->npages * page_size, page,
|
|
|
|
page_size);
|
|
|
|
|
|
|
|
cp->npages++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Flush the incremental page write filter's buffer.
|
|
|
|
|
|
|
|
@return TRUE on success, FALSE on error. */
|
|
|
|
static my_bool
|
|
|
|
wf_incremental_finalize(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
|
|
|
|
{
|
|
|
|
xb_fil_cur_t *cursor = ctxt->cursor;
|
2019-02-06 18:50:11 +01:00
|
|
|
const ulint page_size = cursor->page_size;
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_wf_incremental_ctxt_t *cp = &(ctxt->wf_incremental_ctxt);
|
2017-04-18 20:43:20 +02:00
|
|
|
|
|
|
|
if (cp->npages != page_size / 4) {
|
|
|
|
mach_write_to_4(cp->delta_buf + cp->npages * 4, 0xFFFFFFFFUL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the final block */
|
|
|
|
mach_write_to_4(cp->delta_buf, 0x58545241UL); /*"XTRA"*/
|
|
|
|
|
|
|
|
/* flush buffer */
|
|
|
|
if (ds_write(dstfile, cp->delta_buf, cp->npages * page_size)) {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Free the incremental page write filter's buffer. */
|
|
|
|
static void
|
|
|
|
wf_incremental_deinit(xb_write_filt_ctxt_t *ctxt)
|
|
|
|
{
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_wf_incremental_ctxt_t *cp = &(ctxt->wf_incremental_ctxt);
|
2020-04-02 21:54:08 +02:00
|
|
|
my_large_free(cp->delta_buf, cp->delta_buf_size);
|
2017-04-18 20:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Initialize the write-through page write filter.
|
|
|
|
|
|
|
|
@return TRUE on success, FALSE on error. */
|
|
|
|
static my_bool
|
2023-04-12 09:40:46 +02:00
|
|
|
wf_wt_init(ds_ctxt *ds_meta __attribute__((unused)),
|
|
|
|
xb_write_filt_ctxt_t *ctxt, char *dst_name __attribute__((unused)),
|
MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered
The new option --log-innodb-page-corruption is introduced.
When this option is set, backup is not interrupted if innodb corrupted
page is detected. Instead it logs all found corrupted pages in
innodb_corrupted_pages file in backup directory and finishes with error.
For incremental backup corrupted pages are also copied to .delta file,
because we can't do LSN check for such pages during backup,
innodb_corrupted_pages will also be created in incremental backup
directory.
During --prepare, corrupted pages list is read from the file just after
redo log is applied, and each page from the list is checked if it is allocated
in it's tablespace or not. If it is not allocated, then it is zeroed out,
flushed to the tablespace and removed from the list. If all pages are removed
from the list, then --prepare is finished successfully and
innodb_corrupted_pages file is removed from backup directory. Otherwise
--prepare is finished with error message and innodb_corrupted_pages contains
the list of the pages, which are detected as corrupted during backup, and are
allocated in their tablespaces, what means backup directory contains corrupted
innodb pages, and backup can not be considered as consistent.
For incremental --prepare corrupted pages from .delta files are applied
to the base backup, innodb_corrupted_pages is read from both base in
incremental directories, and the same action is proceded for corrupted
pages list as for full --prepare. innodb_corrupted_pages file is
modified or removed only in base directory.
If DDL happens during backup, it is also processed at the end of backup
to have correct tablespace names in innodb_corrupted_pages.
2020-08-20 15:49:40 +02:00
|
|
|
xb_fil_cur_t *cursor, CorruptedPages *)
|
2017-04-18 20:43:20 +02:00
|
|
|
{
|
|
|
|
ctxt->cursor = cursor;
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Write the next batch of pages to the destination datasink.
|
|
|
|
|
|
|
|
@return TRUE on success, FALSE on error. */
|
|
|
|
static my_bool
|
|
|
|
wf_wt_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
|
|
|
|
{
|
|
|
|
xb_fil_cur_t *cursor = ctxt->cursor;
|
|
|
|
|
|
|
|
if (ds_write(dstfile, cursor->buf, cursor->buf_read)) {
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|