summaryrefslogtreecommitdiff
path: root/extra/mariabackup/fil_cur.cc
diff options
context:
space:
mode:
authorVlad Lesin <vlad_lesin@mail.ru>2020-08-20 16:49:40 +0300
committerVlad Lesin <vlad_lesin@mail.ru>2020-12-01 08:08:57 +0300
commite6b3e38d62d13206ae982fc7b740d5d8024b207a (patch)
tree6c6063f74aa476673366f6e1cbf161a5649fb9fa /extra/mariabackup/fil_cur.cc
parent828471cbf83774f4537a78551290b7a4a7f5d374 (diff)
downloadmariadb-git-e6b3e38d62d13206ae982fc7b740d5d8024b207a.tar.gz
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.
Diffstat (limited to 'extra/mariabackup/fil_cur.cc')
-rw-r--r--extra/mariabackup/fil_cur.cc50
1 files changed, 35 insertions, 15 deletions
diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc
index b229a37d934..3d48cb3e108 100644
--- a/extra/mariabackup/fil_cur.cc
+++ b/extra/mariabackup/fil_cur.cc
@@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
#include "read_filt.h"
#include "xtrabackup.h"
#include "xb0xb.h"
+#include "backup_debug.h"
/* Size of read buffer in pages (640 pages = 10M for 16K sized pages) */
#define XB_FIL_CUR_PAGES 640
@@ -372,16 +373,15 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
return buf_page_is_corrupted(true, page, cursor->page_size, space);
}
-/************************************************************************
-Reads and verifies the next block of pages from the source
+/** Reads and verifies the next block of pages from the source
file. Positions the cursor after the last read non-corrupted page.
-
+@param[in,out] cursor source file cursor
+@param[out] corrupted_pages adds corrupted pages if
+opt_log_innodb_page_corruption is set
@return XB_FIL_CUR_SUCCESS if some have been read successfully, XB_FIL_CUR_EOF
if there are no more pages to read and XB_FIL_CUR_ERROR on error. */
-xb_fil_cur_result_t
-xb_fil_cur_read(
-/*============*/
- xb_fil_cur_t* cursor) /*!< in/out: source file cursor */
+xb_fil_cur_result_t xb_fil_cur_read(xb_fil_cur_t* cursor,
+ CorruptedPages &corrupted_pages)
{
byte* page;
ulint i;
@@ -455,20 +455,40 @@ read_retry:
retry_count--;
if (retry_count == 0) {
+ const char *ignore_corruption_warn = opt_log_innodb_page_corruption ?
+ " WARNING!!! The corruption is ignored due to"
+ " log-innodb-page-corruption option, the backup can contain"
+ " corrupted data." : "";
msg(cursor->thread_n,
"Error: failed to read page after "
"10 retries. File %s seems to be "
- "corrupted.", cursor->abs_path);
- ret = XB_FIL_CUR_ERROR;
+ "corrupted.%s", cursor->abs_path, ignore_corruption_warn);
buf_page_print(page, cursor->page_size);
- break;
+ if (opt_log_innodb_page_corruption) {
+ corrupted_pages.add_page(cursor->node->name, cursor->node->space->id,
+ page_no);
+ retry_count = 1;
+ }
+ else {
+ ret = XB_FIL_CUR_ERROR;
+ break;
+ }
+ }
+ else {
+ msg(cursor->thread_n, "Database page corruption detected at page "
+ ULINTPF ", retrying...",
+ page_no);
+ os_thread_sleep(100000);
+ goto read_retry;
}
- msg(cursor->thread_n, "Database page corruption detected at page "
- ULINTPF ", retrying...",
- page_no);
- os_thread_sleep(100000);
- goto read_retry;
}
+ DBUG_EXECUTE_FOR_KEY("add_corrupted_page_for", cursor->node->space->name,
+ {
+ ulint corrupted_page_no = strtoul(dbug_val, NULL, 10);
+ if (page_no == corrupted_page_no)
+ corrupted_pages.add_page(cursor->node->name, cursor->node->space->id,
+ corrupted_page_no);
+ });
cursor->buf_read += page_size;
cursor->buf_npages++;
}