2
# Runs recovery, compare with expected table data.
5
# 1) set $mms_tname to a string, and $mms_tables to a number N, the script
6
# will cover tables mysqltest.$mms_tname1,...$mms_tnameN
7
# 2) set $mvr_debug_option to the crash way
8
# 3) set $mvr_crash_statement to the statement which will trigger a crash
9
# 4) set $mvr_restore_old_snapshot to 1 if you want recovery to run on
10
# an old copy of tables and of the control file, 0 for normal recovery.
11
# 5) set $mms_compare_physically to 1 if you want a physical byte-for-byte
12
# comparison with expected table. Checksum comparison is always done.
13
# "mvr" is a namespace for Maria_Verify_Recovery
17
# we may do a copy-back of tables before comparison, so save comparison
18
# request made by caller:
19
let $mms_compare_physically_save=$mms_compare_physically;
20
let $mms_compare_physically=0;
22
# warn mtr that mysqld is going to die and should not be restarted immediately
23
#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
24
#wait-maria_verify_recovery.inc
26
# todo: remove this "system" and uncomment above when BUG#32296 is fixed
27
system echo wait-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.expect;
29
# flush page cache and log, only log, or nothing, and kill mysqld with
31
# When we restore an old snapshot, we could just kill mysqld nicely,
32
# but that would implicitely commit all work, which the tester may
33
# not want (tester may want to observe rollback happening).
35
eval SET SESSION debug=$mvr_debug_option;
36
--echo * crashing mysqld intentionally
38
eval $mvr_crash_statement; # this will crash (DBUG magic)
40
if ($mvr_restore_old_snapshot)
43
# copy snapshot made by maria_make_snapshot_for_feeding_recovery back
46
let $mms_table_to_use=$mms_tables;
47
let $mms_purpose=feeding_recovery;
48
let $mms_reverse_copy=1;
49
while ($mms_table_to_use)
51
-- source include/maria_make_snapshot.inc
52
dec $mms_table_to_use;
54
let $mms_reverse_copy=0;
56
# also copy back control file, to force recovery to start from an early
57
# point, ignoring further checkpoints.
59
remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log_control;
60
copy_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log_control;
63
--echo * recovery happens
64
# let mtr restart mysqld (and thus execute the maria log)
65
#append_file $MYSQLTEST_VARDIR/tmp/master0.expect;
66
#restart-maria_verify_recovery.inc
68
system echo restart-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/master0.expect;
70
--source include/wait_until_connected_again.inc
72
# Compare that tables of $mms_tables are identical to old.
73
# We always compare with CHECKSUM TABLE, and if requested (which makes sense
74
# only for testing the REDO phase, as UNDO phase generates new records so new
75
# LSNs on pages.) with a physical byte-for-byte comparison.
76
let $mms_table_to_use=$mms_tables;
77
let $mms_purpose=comparison;
78
let $mms_compare_physically=$mms_compare_physically_save;
79
while ($mms_table_to_use)
81
eval check table $mms_tname$mms_table_to_use extended;
82
--echo * testing that checksum after recovery is as expected
83
let $new_checksum=`CHECKSUM TABLE $mms_tname$mms_table_to_use`;
84
let $old_checksum=`CHECKSUM TABLE mysqltest_for_$mms_purpose.$mms_tname$mms_table_to_use`;
85
# the $ text variables above are of the form "db.tablename\tchecksum",
86
# as db differs, we use substring().
88
eval select if(substring("$new_checksum",instr("$new_checksum",".t1")) = substring("$old_checksum",instr("$old_checksum",".t1")),"ok","failure") as "Checksum-check";
90
# this script may compare physically or do nothing
91
-- source include/maria_make_snapshot.inc
92
dec $mms_table_to_use;
96
# the effect of "use" is lost after a restart so we are back into db "test"