Skip to content
Permalink
Browse files
MDEV-18415 mariabackup.mdev-14447 test case fails with Table 'test.t'…
… doesn't exist in engine

- Added retry logic if validation of first page fails with checksum
mismatch.
  • Loading branch information
Thirunarayanan authored and dr-m committed Feb 1, 2019
1 parent 20e19f6 commit f669cec
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
@@ -3092,7 +3092,16 @@ xb_load_single_table_tablespace(
die("Can't open datafile %s", name);
}

err = file->validate_first_page(&flush_lsn);
for (int i = 0; i < 10; i++) {
err = file->validate_first_page(&flush_lsn);
if (err != DB_CORRUPTION) {
break;
}

my_sleep(1000);
}

bool is_empty_file = file->exists() && file->is_empty_file();

if (err == DB_SUCCESS && file->space_id() != SRV_TMP_SPACE_ID) {
os_offset_t node_size = os_file_get_size(file->handle());
@@ -3124,9 +3133,7 @@ xb_load_single_table_tablespace(

delete file;

if (err != DB_SUCCESS && err != DB_CORRUPTION && xtrabackup_backup) {
/* allow corrupted first page for xtrabackup, it could be just
zero-filled page, which we restore from redo log later */
if (err != DB_SUCCESS && xtrabackup_backup && !is_empty_file) {
die("Failed to not validate first page of the file %s, error %d",name, (int)err);
}
}
@@ -7,6 +7,7 @@ COMMIT;
SELECT count(*) FROM t;
count(*)
100000
FOUND 1 /Checksum mismatch in datafile/ in backup.log
# Prepare full backup, apply incremental one
# Restore and check results
# shutdown server
@@ -1,3 +1,4 @@
--source include/have_debug.inc
call mtr.add_suppression("InnoDB: New log files created");

let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
@@ -9,16 +10,26 @@ echo # Create full backup , modify table, then create incremental/differential b
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
--enable_result_log

BEGIN;
INSERT INTO t select uuid(), uuid(), uuid(), uuid() from seq_1_to_100000;
COMMIT;
SELECT count(*) FROM t;

exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir;
let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;

exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,page_intermittent_checksum_mismatch 2> $backuplog;

--let SEARCH_RANGE = 10000000
--let SEARCH_PATTERN=Checksum mismatch in datafile
--let SEARCH_FILE=$backuplog
--source include/search_pattern_in_file.inc
remove_file $backuplog;

--disable_result_log
echo # Prepare full backup, apply incremental one;
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir;

exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;

echo # Restore and check results;
@@ -36,7 +47,6 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=
echo # restart server;
--source include/start_mysqld.inc


--enable_result_log
SELECT count(*) FROM t;
DROP TABLE t;
@@ -1103,6 +1103,16 @@ buf_page_is_corrupted(

if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {

DBUG_EXECUTE_IF(
"page_intermittent_checksum_mismatch", {
static int page_counter;
if (page_counter++ == 2) {
checksum_field2++;
}
});


crc32 = buf_page_check_crc32(read_buf,
checksum_field2);
crc32_inited = true;
@@ -314,6 +314,25 @@ class Datafile {
return(m_last_os_error);
}

/** Check whether the file is empty.
@return true if file is empty */
bool is_empty_file() const
{
#ifdef _WIN32
os_offset_t offset =
(os_offset_t) m_file_info.nFileSizeLow
| ((os_offset_t) m_file_info.nFileSizeHigh << 32);

return (offset == 0);
#else
return (m_file_info.st_size == 0);
#endif
}

/** Check if the file exist.
@return true if file exists. */
bool exists() const { return m_exists; }

/** Test if the filepath provided looks the same as this filepath
by string comparison. If they are two different paths to the same
file, same_as() will be used to show that after the files are opened.

0 comments on commit f669cec

Please sign in to comment.