Skip to content

Commit f669cec

Browse files
Thirunarayanandr-m
authored andcommitted
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.
1 parent 20e19f6 commit f669cec

File tree

5 files changed

+53
-6
lines changed

5 files changed

+53
-6
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,16 @@ xb_load_single_table_tablespace(
30923092
die("Can't open datafile %s", name);
30933093
}
30943094

3095-
err = file->validate_first_page(&flush_lsn);
3095+
for (int i = 0; i < 10; i++) {
3096+
err = file->validate_first_page(&flush_lsn);
3097+
if (err != DB_CORRUPTION) {
3098+
break;
3099+
}
3100+
3101+
my_sleep(1000);
3102+
}
3103+
3104+
bool is_empty_file = file->exists() && file->is_empty_file();
30963105

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

31253134
delete file;
31263135

3127-
if (err != DB_SUCCESS && err != DB_CORRUPTION && xtrabackup_backup) {
3128-
/* allow corrupted first page for xtrabackup, it could be just
3129-
zero-filled page, which we restore from redo log later */
3136+
if (err != DB_SUCCESS && xtrabackup_backup && !is_empty_file) {
31303137
die("Failed to not validate first page of the file %s, error %d",name, (int)err);
31313138
}
31323139
}

mysql-test/suite/mariabackup/mdev-14447.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ COMMIT;
77
SELECT count(*) FROM t;
88
count(*)
99
100000
10+
FOUND 1 /Checksum mismatch in datafile/ in backup.log
1011
# Prepare full backup, apply incremental one
1112
# Restore and check results
1213
# shutdown server

mysql-test/suite/mariabackup/mdev-14447.test

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--source include/have_debug.inc
12
call mtr.add_suppression("InnoDB: New log files created");
23

34
let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
@@ -9,16 +10,26 @@ echo # Create full backup , modify table, then create incremental/differential b
910
--disable_result_log
1011
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
1112
--enable_result_log
13+
1214
BEGIN;
1315
INSERT INTO t select uuid(), uuid(), uuid(), uuid() from seq_1_to_100000;
1416
COMMIT;
1517
SELECT count(*) FROM t;
1618

17-
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir;
19+
let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
20+
21+
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,page_intermittent_checksum_mismatch 2> $backuplog;
22+
23+
--let SEARCH_RANGE = 10000000
24+
--let SEARCH_PATTERN=Checksum mismatch in datafile
25+
--let SEARCH_FILE=$backuplog
26+
--source include/search_pattern_in_file.inc
27+
remove_file $backuplog;
1828

1929
--disable_result_log
2030
echo # Prepare full backup, apply incremental one;
2131
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir;
32+
2233
exec $XTRABACKUP --prepare --verbose --apply-log-only --target-dir=$basedir --incremental-dir=$incremental_dir ;
2334

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

39-
4050
--enable_result_log
4151
SELECT count(*) FROM t;
4252
DROP TABLE t;

storage/innobase/buf/buf0buf.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,16 @@ buf_page_is_corrupted(
11031103

11041104
if (srv_checksum_algorithm
11051105
== SRV_CHECKSUM_ALGORITHM_CRC32) {
1106+
1107+
DBUG_EXECUTE_IF(
1108+
"page_intermittent_checksum_mismatch", {
1109+
static int page_counter;
1110+
if (page_counter++ == 2) {
1111+
checksum_field2++;
1112+
}
1113+
});
1114+
1115+
11061116
crc32 = buf_page_check_crc32(read_buf,
11071117
checksum_field2);
11081118
crc32_inited = true;

storage/innobase/include/fsp0file.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,25 @@ class Datafile {
314314
return(m_last_os_error);
315315
}
316316

317+
/** Check whether the file is empty.
318+
@return true if file is empty */
319+
bool is_empty_file() const
320+
{
321+
#ifdef _WIN32
322+
os_offset_t offset =
323+
(os_offset_t) m_file_info.nFileSizeLow
324+
| ((os_offset_t) m_file_info.nFileSizeHigh << 32);
325+
326+
return (offset == 0);
327+
#else
328+
return (m_file_info.st_size == 0);
329+
#endif
330+
}
331+
332+
/** Check if the file exist.
333+
@return true if file exists. */
334+
bool exists() const { return m_exists; }
335+
317336
/** Test if the filepath provided looks the same as this filepath
318337
by string comparison. If they are two different paths to the same
319338
file, same_as() will be used to show that after the files are opened.

0 commit comments

Comments
 (0)