Commit 1b4c6fa6 authored by unknown's avatar unknown

Build maria_dump_log under Windows. Enable maria_chk --zerofill-keep-lsn

in release builds, use it to fine-tune physical file comparisons in
ma_test_recovery.pl.


storage/maria/CMakeLists.txt:
  build maria_dump_log under Windows too
storage/maria/maria_chk.c:
  make --zerofill-keep-lsn usable in release builds too, it makes sense.
  This option needn't reset state's LSNs, and it's more useful if it
  does not (see added comment) as it changes less the table.
storage/maria/unittest/ma_test_recovery.pl:
  - getting rid of 'cmp'
  - if physical comparison of two MAD or MAI files fails, it might
  be in irrelevant portions (unushed index or data page pieces):
  we use --zerofill-keep-lsn and retry the comparison. This fixes
  a part of test failures under Windows.
parent 1dfeb478
......@@ -62,6 +62,10 @@ TARGET_LINK_LIBRARIES(maria_read_log maria myisam mysys dbug strings zlib wsock3
ADD_EXECUTABLE(maria_pack maria_pack.c)
TARGET_LINK_LIBRARIES(maria_pack maria myisam mysys dbug strings zlib wsock32)
ADD_EXECUTABLE(maria_dump_log ma_loghandler.c)
TARGET_LINK_LIBRARIES(maria_dump_log maria myisam mysys dbug strings zlib wsock32)
SET_TARGET_PROPERTIES(maria_dump_log PROPERTIES COMPILE_FLAGS "-DMARIA_DUMP_LOG")
ADD_EXECUTABLE(ma_test1 ma_test1.c)
TARGET_LINK_LIBRARIES(ma_test1 maria myisam mysys dbug strings zlib wsock32)
......
......@@ -375,12 +375,10 @@ static struct my_option my_long_options[] =
{ "zerofill", 'z',
"Fill empty space in data and index files with zeroes",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
{ "zerofill-keep-lsn", OPT_ZEROFILL_KEEP_LSN,
"Like --zerofill but does not zero out LSN of data/index pages;"
" used only for testing and debugging",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
......@@ -511,13 +509,9 @@ static void usage(void)
(It may be VERY slow to do a sort the first time!).\n\
-b, --block-search=#\n\
Find a record, a block at given offset belongs to.\n\
-z, --zerofill Fill empty space in data and index files with zeroes"
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
"\n\
-z, --zerofill Fill empty space in data and index files with zeroes\n\
--zerofill-keep-lsn Like --zerofill but does not zero out LSN of\n\
data/index pages; used only for testing and debugging"
#endif
".");
data/index pages.");
print_defaults("my", load_default_groups);
my_print_variables(my_long_options);
......@@ -1123,13 +1117,23 @@ static int maria_chk(HA_CHECK *param, char *filename)
if (!error)
{
/*
Tell the server's Recovery to ignore old REDOs on this table; we don't
Unless this was only --zerofill-keep-lsn, old REDOs are not
applicable, tell the server's Recovery to ignore them; we don't
know what the log's end LSN is now, so we just let the server know
that it will have to find and store it.
This is the only case where create_rename_lsn can be a horizon and not
a LSN.
If this was only --zerofill-keep-lsn, the table can be used in
Recovery and especially in this scenario: do a dirty-copy-based backup
(snapshot-like), --zerofill-keep-lsn on the copies to achieve better
compression, compress the copies with an external tool, and after a
restore, Recovery still works (because pages and state still have
their correct LSNs).
*/
if (share->base.born_transactional)
if (share->base.born_transactional &&
((param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_ZEROFILL | T_ZEROFILL_KEEP_LSN)) !=
(T_ZEROFILL | T_ZEROFILL_KEEP_LSN)))
share->state.create_rename_lsn= share->state.is_of_horizon=
share->state.skip_redo_lsn= LSN_REPAIRED_BY_MARIA_CHK;
}
......
......@@ -2,6 +2,7 @@
use Getopt::Long;
use File::Copy;
use File::Compare;
use File::Basename;
$|= 1;
......@@ -140,18 +141,14 @@ sub main
move("$table.MAI", "$tmp/$table-good.MAI") ||
die "Can't move $table.MAI to $tmp/$table-good.MAI\n";
apply_log($table, "shouldnotchangelog");
$res= `cmp $table.MAD $tmp/$table-good.MAD`;
print MY_LOG $res;
$res= `cmp $table.MAI $tmp/$table-good.MAI`;
print MY_LOG $res;
check_table_is_same($table, $checksum);
$res= physical_cmp($table, "$tmp/$table-good");
print MY_LOG $res;
print MY_LOG "testing idempotency\n";
apply_log($table, "shouldnotchangelog");
$res= `cmp $table.MAD $tmp/$table-good.MAD`;
print MY_LOG $res;
$res= `cmp $table.MAI $tmp/$table-good.MAI`;
print MY_LOG $res;
check_table_is_same($table, $checksum);
$res= physical_cmp($table, "$tmp/$table-good");
print MY_LOG $res;
}
print MY_LOG "Testing the REDO AND UNDO PHASE\n";
......@@ -255,21 +252,16 @@ sub main
check_table_is_same($table, $checksum);
print MY_LOG "testing idempotency\n";
apply_log($table, "shouldnotchangelog");
# We can't do a binary compary as there may have been different number
# of calls to compact_page. We can enable this if we first call
# maria-check to generate identically compacted pages.
# cmp $table.MAD $tmp/$table-after_undo.MAD
$res= `cmp $table.MAI $tmp/$table-after_undo.MAI`;
print MY_LOG $res;
check_table_is_same($table, $checksum);
$res= physical_cmp($table, "$tmp/$table-after_undo");
print MY_LOG $res;
print MY_LOG "testing applying of CLRs to recreate table\n";
unlink <$table.MA?>;
# cp $tmp/maria_log* $maria_path #unneeded
apply_log($table, "shouldnotchangelog");
# cmp $table.MAD $tmp/$table-after_undo.MAD
$res= `cmp $table.MAI $tmp/$table-after_undo.MAI`;
print MY_LOG $res;
check_table_is_same($table, $checksum);
$res= physical_cmp($table, "$tmp/$table-after_undo");
print MY_LOG $res;
}
unlink <$table.* $tmp/$table* $tmp/maria_chk_*.txt $tmp/maria_read_log_$table.txt>;
}
......@@ -357,7 +349,7 @@ sub apply_log
{
print MY_LOG "bad argument '$shouldchangelog'\n";
return 1;
}
}
$log_md5= `$md5sum maria_log.*`;
print MY_LOG "applying log\n";
......@@ -395,6 +387,43 @@ sub my_which
}
####
#### physical_cmp: compares two tables (MAI and MAD) physically;
#### uses zerofill-keep-lsn to reduce irrelevant differences.
####
sub physical_cmp
{
my ($table1, $table2)= @_;
my ($zerofilled, $ret_text);
foreach my $file_suffix ("MAD", "MAI")
{
my $file1= "$table1.$file_suffix";
my $file2= "$table2.$file_suffix";
my ($error_text, $differences_text)=
("error in comparison of $file1 and $file2\n",
"$file1 and $file2 differ\n");
my $res= File::Compare::compare($file1, $file2);
return $error_text if ($res == -1);
if ($res == 1 # they differ
and !$zerofilled)
{
# let's try with --zerofill-keep-lsn
$zerofilled= 1; # but no need to do it twice
foreach my $table ($table1, $table2)
{
$com= "$maria_exe_path/maria_chk$suffix -s --zerofill-keep-lsn $table";
$res= `$com`;
print MY_LOG $res;
}
$res= File::Compare::compare($file1, $file2);
return $error_text if ($res == -1);
}
$ret_text.= $differences_text if ($res != 0);
}
}
####
#### usage
####
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment