Commit ac590d9c authored by unknown's avatar unknown

Addendum to WL#4137 "Maria- Framework for testing recovery in mysql-test-run":

possibility, if requested in the test, to do byte-for-byte comparison
of data files after recovery. This makes sense only when testing
REDOs, as UNDO phase generates new log records thus data pages get
new LSNs. First test of maria-recovery.test is changed to test only
REDOs and do byte-for-byte comparison.


mysql-test/include/maria_make_snapshot.inc:
  possibility to compare physically the data files (makes sense
  only if testing REDO phase).
mysql-test/include/maria_verify_recovery.inc:
  allow physical comparison of data files after recovery if requested
mysql-test/r/maria-recovery.result:
  result update (first test tests REDO only now)
mysql-test/t/maria-recovery.test:
  first test tests REDO only now, and thus can do byte-for-byte
  comparison of data files.
parent 5fbd5daf
......@@ -9,22 +9,11 @@
# 1) set one of
# $mms_copy : to copy table from database to spare directory
# $mms_reverse : to copy it back
# $mms_compare : to compare both
# $mms_compare_physically : to compare both byte-for-byte
# 2) set $mms_table_to_use to a number N: table will be mysqltest.tN
# 3) set $mms_purpose to say what this copy is for (influences the naming
# of the spare directory).
if (!$mms_copy)
{
if (!$mms_reverse_copy)
{
if (!$mms_compare)
{
--die misuse of maria_make_snapshot.inc: no command
}
}
}
if ($mms_copy)
{
--echo * copied t$mms_table_to_use for $mms_purpose
......@@ -45,14 +34,15 @@ if ($mms_reverse_copy)
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI;
}
if ($mms_compare)
if ($mms_compare_physically)
{
# this was meant to do a physical file compare (diff_files)
# but after the UNDO phase this is normally impossible
# After the UNDO phase this is normally impossible
# (UNDO execution has created new log records => pages have new LSNs).
# So for now it does nothing.
# --echo * compared t$mms_table_to_use
# diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD;
# So, do this only when testing REDO phase.
# If UNDO phase, we nevertheless compare checksums
# (see maria_verify_recovery.inc).
--echo * compared t$mms_table_to_use to old version
diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD;
# index file not yet recovered
# diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAI;
}
......@@ -6,11 +6,18 @@
# 2) set $mvr_debug_option to the crash way
# 3) set $mvr_restore_old_snapshot to 1 if you want recovery to run on
# an old copy of tables and of the control file, 0 for normal recovery.
# 4) set $mms_compare_physically to 1 if you want a physical byte-for-byte
# comparison with expected table. Checksum comparison is always done.
# "mvr" is a namespace for Maria_Verify_Recovery
connection admin;
# we may do a copy-back of tables before comparison, so save comparison
# request made by caller:
let $mms_compare_physically_save=$mms_compare_physically;
let $mms_compare_physically=0;
# warn mtr that mysqld is going to die and should not be restarted immediately
#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
#wait-maria_verify_recovery.inc
......@@ -61,10 +68,13 @@ system echo restart-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.e
--source include/wait_until_connected_again.inc
# compare that tables of $mms_tables are identical to old.
# Compare that tables of $mms_tables are identical to old.
# We always compare with CHECKSUM TABLE, and if requested (which makes sense
# only for testing the REDO phase, as UNDO phase generates new records so new
# LSNs on pages.) with a physical byte-for-byte comparison.
let $mms_table_to_use=$mms_tables;
let $mms_purpose=comparison;
let $mms_compare=1;
let $mms_compare_physically=$mms_compare_physically_save;
while ($mms_table_to_use)
{
# Todo: remove this REPAIR when we have index recovery working.
......@@ -77,10 +87,10 @@ while ($mms_table_to_use)
# the $ text variables above are of the form "db.tablename\tchecksum",
# as db differs, we use substring().
eval select if(substring("$new_checksum",instr("$new_checksum",".t1")) = substring("$old_checksum",instr("$old_checksum",".t1")),"ok","failure");
# this script may compare physically or do nothing
-- source include/maria_make_snapshot.inc
dec $mms_table_to_use;
}
let $mms_compare=0;
connection default;
# the effect of "use" is lost after a restart so we are back into db "test"
......
......@@ -4,13 +4,11 @@ use mysqltest;
* shut down mysqld, removed logs, restarted it
use mysqltest;
create table t1 (a varchar(1000)) engine=maria;
* TEST: see if recovery can reconstruct if we give it an old table
* TEST of REDO: see if recovery can reconstruct if we give it an old table
* copied t1 for feeding_recovery
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally
set global maria_checkpoint_interval=1;
......@@ -25,11 +23,12 @@ mysqltest.t1 repair status OK
select if(substring("mysqltest.t1 488070860",instr("mysqltest.t1 488070860",".t1")) = substring("mysqltest_for_comparison.t1 488070860",instr("mysqltest_for_comparison.t1 488070860",".t1")),"ok","failure");
if(substring("mysqltest.t1 488070860",instr("mysqltest.t1 488070860",".t1")) = substring("mysqltest_for_comparison.t1 488070860",instr("mysqltest_for_comparison.t1 488070860",".t1")),"ok","failure")
ok
* compared t1 to old version
use mysqltest;
select * from t1;
a
00000000
* TEST: normal recovery test (no moving tables under its feet)
* TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
insert into t1 values ("00000000");
flush table t1;
* copied t1 for comparison
......
......@@ -25,25 +25,26 @@ use mysqltest;
let $mms_tables=1;
create table t1 (a varchar(1000)) engine=maria;
--echo * TEST: see if recovery can reconstruct if we give it an old table
--echo * TEST of REDO: see if recovery can reconstruct if we give it an old table
-- source include/maria_make_snapshot_for_feeding_recovery.inc
# Your committed statements here, which we expect to
# be reconstructed from the log
insert into t1 values ("00000000");
-- source include/maria_make_snapshot_for_comparison.inc
# Your statements which should not commit and we expect to be rolled back
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
# we want recovery to run on the first snapshot made above
let $mvr_restore_old_snapshot=1;
# the script below will trigger recovery and compare checksums
# As we did only committed work, we test REDO applying, which could
# produce a physically identical table.
let $mms_compare_physically=1;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
# the script below will trigger recovery and compare checksums
-- source include/maria_verify_recovery.inc
let $mms_compare_physically=0;
# so a SELECT like this is pure visual effect, brings nothing.
select * from t1;
--echo * TEST: normal recovery test (no moving tables under its feet)
--echo * TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
# different types of crash => a loop; here are loop control variables
let $crash_no_flush=1;
......@@ -54,6 +55,9 @@ let $crash_loop=1;
# we want recovery to use the tables as they were at time of crash
let $mvr_restore_old_snapshot=0;
# UNDO phase prevents physical comparison, normally,
# so we'll only use checksums to compare.
let $mms_compare_physically=0;
# Note that we don't remove logs between iterations. Test is
# cumulative (each new recovery processes more log records than the previous).
......@@ -109,7 +113,7 @@ drop table t1;
# we had a bug where new page's LSN was 0... todo.
#
# Test problem where an UPDATE purges and rewrites a tail page, and
# Test for this bug: an UPDATE purges and rewrites a tail page, and
# recovery applied the purge, stamped page with UNDO's LSN, thus
# the rewrite was ignored.
#
......@@ -128,6 +132,7 @@ SELECT LENGTH(b) FROM t1 WHERE i=3;
-- source include/maria_make_snapshot_for_comparison.inc
# we want recovery to run on the first snapshot made above
let $mvr_restore_old_snapshot=1;
let $mms_compare_physically=0;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
-- source include/maria_verify_recovery.inc
SELECT LENGTH(b) FROM t1 WHERE i=3;
......
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