1# Maria helper script. 2# Runs recovery, compare with expected table data. 3 4# API: 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 14 15connection admin; 16 17# we may do a copy-back of tables before comparison, so save comparison 18# request made by caller: 19let $mms_compare_physically_save=$mms_compare_physically; 20let $mms_compare_physically=0; 21 22# warn mtr that mysqld is going to die and should not be restarted immediately 23#append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; 24#wait-maria_verify_recovery.inc 25#EOF 26# todo: remove this "system" and uncomment above when BUG#32296 is fixed 27system echo wait-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; 28 29# flush page cache and log, only log, or nothing, and kill mysqld with 30# abort(). 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). 34 35eval SET SESSION debug_dbug=$mvr_debug_option; 36--echo * crashing mysqld intentionally 37--error 2013 38eval $mvr_crash_statement; # this will crash (DBUG magic) 39 40if ($mvr_restore_old_snapshot) 41{ 42 43 # copy snapshot made by maria_make_snapshot_for_feeding_recovery back 44 # into datadir. 45 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) 50 { 51 -- source include/maria_make_snapshot.inc 52 dec $mms_table_to_use; 53 } 54 let $mms_reverse_copy=0; 55 56 # also copy back control file, to force recovery to start from an early 57 # point, ignoring further checkpoints. 58 -- error 0,1 59 remove_file $MYSQLD_DATADIR/$MARIA_LOG/aria_log_control; 60 copy_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.aria_log_control $MYSQLD_DATADIR/$MARIA_LOG/aria_log_control; 61} 62 63--echo * recovery happens 64# let mtr restart mysqld (and thus execute the maria log) 65#append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; 66#restart-maria_verify_recovery.inc 67#EOF 68system echo restart-maria_verify_recovery.inc >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; 69 70--source include/wait_until_connected_again.inc 71 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. 76let $mms_table_to_use=$mms_tables; 77let $mms_purpose=comparison; 78let $mms_compare_physically=$mms_compare_physically_save; 79while ($mms_table_to_use) 80{ 81 # the size of the index file is different for with/without encryption 82 --replace_result 372 <SIZE> 394 <SIZE> 83 eval check table $mms_tname$mms_table_to_use extended; 84 --echo * testing that checksum after recovery is as expected 85 let $new_checksum=`CHECKSUM TABLE $mms_tname$mms_table_to_use`; 86 let $old_checksum=`CHECKSUM TABLE mysqltest_for_$mms_purpose.$mms_tname$mms_table_to_use`; 87 # the $ text variables above are of the form "db.tablename\tchecksum", 88 # as db differs, we use substring(). 89 --disable_query_log 90 eval select if(substring("$new_checksum",instr("$new_checksum",".t1")) = substring("$old_checksum",instr("$old_checksum",".t1")),"ok","failure") as "Checksum-check"; 91 --enable_query_log 92 # this script may compare physically or do nothing 93 -- source include/maria_make_snapshot.inc 94 dec $mms_table_to_use; 95} 96 97connection default; 98# the effect of "use" is lost after a restart so we are back into db "test" 99use mysqltest; 100