mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
WL#4374 "Maria - force start if Recovery fails multiple times"
http://forge.mysql.com/worklog/task.php?id=4374 new option --maria-force-start-after-recovery-failures=N; number of consecutive recovery failures (failures of log reading or recovery processing, anything in [translog_init(),maria_recovery_from_log()]) is stored in the control file; if at a Maria start they are more than N, logs are removed. This is for automated systems which have to run whatever happens. As tables risk staying corrupted, --maria-recover should also be used on them: this revision makes maria-recover work (it was disabled). Fixed bug in translog_is_log_files(). translog_init() now prints message to error log if failed. Removed \0 in the output of SHOW ENGINE MARIA LOGS; removed hard-coded engine name there. KNOWN_BUGS.txt: As option --maria-force-start-after-recovery-failures is added, it corresponds to the wish "we should fix that if this happens etc". LOAD INDEX is not ignored since a few weeks. Listed concurrency bugs have been fixed some time ago. Recovery of fulltext and GIS indexes works since a few weeks. mysql-test/include/maria_make_snapshot.inc: configurable prefix in table's name (so far 't' or 't_corrupted') mysql-test/include/maria_make_snapshot_for_comparison.inc: configurable prefix in table's name (so far 't' or 't_corrupted') mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc: configurable prefix in table's name (so far 't' or 't_corrupted') mysql-test/include/maria_verify_recovery.inc: configurable prefix in table's name (so far 't' or 't_corrupted') mysql-test/lib/mtr_report.pl: new test maria-recover.test generates expected corruption warnings in the error log. maria-recovery.test's corrupted table is renamed to t_corrupted1 instead of t1. mysql-test/r/maria-preload.result: result update. maria_pagecache_read* values are similar to the previous version of this file, though a bit bigger because using the information_schema and the join leads to some internal maria temp table being used, and thus some blocks of it being read. mysql-test/r/maria-purge.result: engine's name in SHOW ENGINE MARIA LOGS changed. mysql-test/r/maria-recover.result: result for new test. We see corruption messages at first SELECT and then none at second SELECT, expected. mysql-test/r/maria-recovery.result: result update mysql-test/r/maria.result: new variables show up mysql-test/t/disabled.def: BUG#34911 is not fixed but the test had been made independent of the bug (workaround). A new bug (crash) has popped recently, so it has to stay disabled (BUG#35107). mysql-test/t/maria-preload.test: Work around BUG#34911 "FLUSH STATUS doesn't flush what it should": compute differences in status variables before and after relevant queries mysql-test/t/maria-recover-master.opt: test --maria-recover mysql-test/t/maria-recover.test: Test of the --maria-recover option (build a corrupted table and see if it is auto-repaired) mysql-test/t/maria-recovery-big.test: update for new API of include/maria*.inc mysql-test/t/maria-recovery-bitmap.test: update for new API of include/maria*.inc mysql-test/t/maria-recovery.test: update for new API of include/maria*.inc. Corrupted table t1 renamed to t_corrupted1, so that mtr_report.pl does not blindly remove all corruption messages for t1 which is a common name. storage/maria/ha_maria.cc: Enabling maria-recover. Adding option and global variable --maria_force_start_after_recovery_failures: ha_maria_init() calls mark_recovery_start() and mark_recovery_success() to keep track of failed consecutive recoveries and remove logs if needed. Removed \0 in the output of SHOW ENGINE MARIA LOGS; removed hard-coded engine name there. storage/maria/ma_checkpoint.c: new prototype storage/maria/ma_control_file.c: Storing in one byte in the control file, the number of consecutive recovery failures. storage/maria/ma_control_file.h: new prototype storage/maria/ma_init.c: new prototype storage/maria/ma_locking.c: Need to update open_count on disk at first write and close for transactional tables, like we already did for non-transactional tables, otherwise we cannot notice that the table is dubious. storage/maria/ma_loghandler.c: translog_is_log_files() is made more generic to serve either to search or to delete logs (the latter is for --maria-force-start-after-recovery-failures). It also had a bug (always returned FALSE). storage/maria/ma_loghandler.h: export function because ha_maria::mark_recovery_start() needs it storage/maria/ma_recovery.c: changing name of maria_recover() to distinguish from the maria-recover option. storage/maria/ma_recovery.h: changing name of maria_recover() to distinguish from the maria-recover option. storage/maria/ma_test_force_start.pl: Test of --maria-force-start-after-recovery-failures (and also, to be realistic, of --maria-recover). This is standalone because mysql-test-run does not support testing that multiple mysqld restarts expectedly failed. I'll have to run it on my machine and also on a Windows machine. storage/maria/unittest/ma_control_file-t.c: adding recovery_failures to the test storage/maria/unittest/ma_test_loghandler_multigroup-t.c: fix for compiler warning (unused variable in non-debug build)
This commit is contained in:
@ -10,28 +10,29 @@
|
||||
# $mms_copy : to copy table from database to spare directory
|
||||
# $mms_reverse : to copy it back
|
||||
# $mms_compare_physically : to compare both byte-for-byte
|
||||
# 2) set $mms_table_to_use to a number N: table will be mysqltest.tN
|
||||
# 2) set $mms_tname to a string and set $mms_table_to_use to a number: tables
|
||||
# will be mysqltest.$mms_tname$mms_table_to_use.
|
||||
# 3) set $mms_purpose to say what this copy is for (influences the naming
|
||||
# of the spare directory).
|
||||
|
||||
if ($mms_copy)
|
||||
{
|
||||
--echo * copied t$mms_table_to_use for $mms_purpose
|
||||
copy_file $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;
|
||||
copy_file $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;
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.frm $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.frm;
|
||||
--echo * copied $mms_tname$mms_table_to_use for $mms_purpose
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$mms_table_to_use.MAD;
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$mms_table_to_use.MAI;
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.frm $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$mms_table_to_use.frm;
|
||||
}
|
||||
|
||||
if ($mms_reverse_copy)
|
||||
{
|
||||
# do not call this without flushing target table first!
|
||||
--echo * copied t$mms_table_to_use back for $mms_purpose
|
||||
--echo * copied $mms_tname$mms_table_to_use back for $mms_purpose
|
||||
-- error 0,1
|
||||
remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD;
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/t$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAD;
|
||||
remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAD;
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAD;
|
||||
-- error 0,1
|
||||
remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/t$mms_table_to_use.MAI;
|
||||
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;
|
||||
remove_file $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAI;
|
||||
copy_file $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAI;
|
||||
}
|
||||
|
||||
if ($mms_compare_physically)
|
||||
@ -41,8 +42,8 @@ if ($mms_compare_physically)
|
||||
# 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;
|
||||
--echo * compared $mms_tname$mms_table_to_use to old version
|
||||
diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAD $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$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;
|
||||
# diff_files $MYSQLTEST_VARDIR/master-data/mysqltest/$mms_tname$mms_table_to_use.MAI $MYSQLTEST_VARDIR/master-data/mysqltest_for_$mms_purpose/$mms_tname$mms_table_to_use.MAI;
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
# Maria helper script
|
||||
# Copies clean tables' data and index file to other directory
|
||||
# Tables are t1...t[$mms_tables]
|
||||
# Tables are $mms_tname1...$mms_tname[$mms_tables]
|
||||
# They are later used as a reference to see if recovery works.
|
||||
|
||||
# API:
|
||||
# set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
|
||||
# set $mms_tname to a string, and $mms_tables to a number N, the script will
|
||||
# cover tables mysqltest.$mms_tname1,...$mms_tnameN
|
||||
|
||||
connection admin;
|
||||
|
||||
@ -22,7 +23,7 @@ eval create database mysqltest_for_$mms_purpose;
|
||||
while ($mms_table_to_use)
|
||||
{
|
||||
# to serve as a reference, table must be in a clean state
|
||||
eval flush table t$mms_table_to_use;
|
||||
eval flush table $mms_tname$mms_table_to_use;
|
||||
-- source include/maria_make_snapshot.inc
|
||||
dec $mms_table_to_use;
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
# Maria helper script
|
||||
# Copies tables' data and index file to other directory, and control file.
|
||||
# Tables are t1...t[$mms_tables].
|
||||
# Tables are $mms_tname1...$mms_tname[$mms_tables].
|
||||
# Later, mysqld is shutdown, and that snapshot is put back into the
|
||||
# datadir, control file too ("flashing recovery's brain"), and recovery is let
|
||||
# to run on it (see maria_verify_recovery.inc).
|
||||
|
||||
# API:
|
||||
# set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
|
||||
# set $mms_tname to a string, and $mms_tables to a number N, the script will
|
||||
# cover tables mysqltest.$mms_tname1,...$mms_tnameN
|
||||
|
||||
|
||||
connection admin;
|
||||
|
||||
|
@ -2,7 +2,8 @@
|
||||
# Runs recovery, compare with expected table data.
|
||||
|
||||
# API:
|
||||
# 1) set $mms_tables to N, the script will cover tables mysqltest.t1,...tN
|
||||
# 1) set $mms_tname to a string, and $mms_tables to a number N, the script
|
||||
# will cover tables mysqltest.$mms_tname1,...$mms_tnameN
|
||||
# 2) set $mvr_debug_option to the crash way
|
||||
# 3) set $mvr_crash_statement to the statement which will trigger a crash
|
||||
# 4) set $mvr_restore_old_snapshot to 1 if you want recovery to run on
|
||||
@ -77,10 +78,10 @@ let $mms_purpose=comparison;
|
||||
let $mms_compare_physically=$mms_compare_physically_save;
|
||||
while ($mms_table_to_use)
|
||||
{
|
||||
eval check table t$mms_table_to_use extended;
|
||||
eval check table $mms_tname$mms_table_to_use extended;
|
||||
--echo * testing that checksum after recovery is as expected
|
||||
let $new_checksum=`CHECKSUM TABLE t$mms_table_to_use`;
|
||||
let $old_checksum=`CHECKSUM TABLE mysqltest_for_$mms_purpose.t$mms_table_to_use`;
|
||||
let $new_checksum=`CHECKSUM TABLE $mms_tname$mms_table_to_use`;
|
||||
let $old_checksum=`CHECKSUM TABLE mysqltest_for_$mms_purpose.$mms_tname$mms_table_to_use`;
|
||||
# the $ text variables above are of the form "db.tablename\tchecksum",
|
||||
# as db differs, we use substring().
|
||||
--disable_query_log
|
||||
|
Reference in New Issue
Block a user