summaryrefslogtreecommitdiff
path: root/extra/mariabackup/backup_copy.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/backup_copy.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/backup_copy.cc')
-rw-r--r--extra/mariabackup/backup_copy.cc32
1 files changed, 18 insertions, 14 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index 0ba220364e2..d3fa3605c21 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -867,21 +867,14 @@ datafile_rsync_backup(const char *filepath, bool save_to_list, FILE *f)
return(true);
}
-
-static
-bool
-backup_file_vprintf(const char *filename, const char *fmt, va_list ap)
+bool backup_file_print_buf(const char *filename, const char *buf, int buf_len)
{
ds_file_t *dstfile = NULL;
MY_STAT stat; /* unused for now */
- char *buf = 0;
- int buf_len;
const char *action;
memset(&stat, 0, sizeof(stat));
- buf_len = vasprintf(&buf, fmt, ap);
-
stat.st_size = buf_len;
stat.st_mtime = my_time(0);
@@ -905,7 +898,6 @@ backup_file_vprintf(const char *filename, const char *fmt, va_list ap)
/* close */
msg(" ...done");
- free(buf);
if (ds_close(dstfile)) {
goto error_close;
@@ -914,7 +906,6 @@ backup_file_vprintf(const char *filename, const char *fmt, va_list ap)
return(true);
error:
- free(buf);
if (dstfile != NULL) {
ds_close(dstfile);
}
@@ -922,8 +913,21 @@ error:
error_close:
msg("Error: backup file failed.");
return(false); /*ERROR*/
-}
+ return true;
+};
+
+static
+bool
+backup_file_vprintf(const char *filename, const char *fmt, va_list ap)
+{
+ char *buf = 0;
+ int buf_len;
+ buf_len = vasprintf(&buf, fmt, ap);
+ bool result = backup_file_print_buf(filename, buf, buf_len);
+ free(buf);
+ return result;
+}
bool
backup_file_printf(const char *filename, const char *fmt, ...)
@@ -1446,7 +1450,7 @@ out:
return(ret);
}
-void backup_fix_ddl(void);
+void backup_fix_ddl(CorruptedPages &);
lsn_t get_current_lsn(MYSQL *connection)
{
@@ -1471,7 +1475,7 @@ lsn_t get_current_lsn(MYSQL *connection)
lsn_t server_lsn_after_lock;
extern void backup_wait_for_lsn(lsn_t lsn);
/** Start --backup */
-bool backup_start()
+bool backup_start(CorruptedPages &corrupted_pages)
{
if (!opt_no_lock) {
if (opt_safe_slave_backup) {
@@ -1506,7 +1510,7 @@ bool backup_start()
msg("Waiting for log copy thread to read lsn %llu", (ulonglong)server_lsn_after_lock);
backup_wait_for_lsn(server_lsn_after_lock);
- backup_fix_ddl();
+ backup_fix_ddl(corrupted_pages);
// There is no need to stop slave thread before coping non-Innodb data when
// --no-lock option is used because --no-lock option requires that no DDL or