Commit e580e058 authored by unknown's avatar unknown

Maria: more log handler fixes for when logs manually deleted


mysql-test/include/maria_empty_logs.inc:
  can now ask that control file be preserved
mysql-test/lib/mtr_report.pl:
  expected warning (produced by translog_init() when log is missing)
mysql-test/r/maria-recovery.result:
  result update
mysql-test/t/maria-recovery.test:
  test of removing logs manually; recovery used to fail
storage/maria/ma_loghandler.c:
  The addition to maria-recovery.test uncovered a bug: log 1 was
  manually deleted, Maria restarted, created log 2, then crash
  before a checkpoint: logs_found is TRUE, last_checkpoint_lsn
  is LSN_IMPOSSIBLE, so sure_page assumes that log 1 exists;
  using last_logno instead (only the last log needs to be checked,
  as the 'else' branch checks only after last_checkpoint_lsn:
  creation of a log is as good a starting point as a checkpoint,
  for scanning the log).
parent 345451ce
# Maria help script. # Maria help script.
# Cleans up all logs to give recovery a fresh start. # Cleans up all logs to give recovery a fresh start.
# API: none, just uses vardir, port and socket. # API: set mel_keep_control_file=1 if want to keep control file;
# uses vardir, port and socket.
connection admin; connection admin;
...@@ -12,7 +13,10 @@ EOF ...@@ -12,7 +13,10 @@ EOF
--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= shutdown 2>&1; --exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= shutdown 2>&1;
remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control; if (!$mel_keep_control_file)
{
remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control;
}
remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000001; remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000001;
-- error 0,1 # maybe there is just one log -- error 0,1 # maybe there is just one log
remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000002; remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000002;
......
...@@ -363,7 +363,10 @@ sub mtr_report_stats ($) { ...@@ -363,7 +363,10 @@ sub mtr_report_stats ($) {
# master # master
/Slave: Unknown column 'c7' in 't15' Error_code: 1054/ or /Slave: Unknown column 'c7' in 't15' Error_code: 1054/ or
/Slave: Can't DROP 'c7'.* 1091/ or /Slave: Can't DROP 'c7'.* 1091/ or
/Slave: Key column 'c6'.* 1072/ /Slave: Key column 'c6'.* 1072/ or
# maria-recovery.test has warning about missing log file
/Can't get stat of '.*maria_log.00*/
) )
{ {
next; # Skip these lines next; # Skip these lines
......
...@@ -214,6 +214,28 @@ t1 CREATE TABLE `t1` ( ...@@ -214,6 +214,28 @@ t1 CREATE TABLE `t1` (
KEY `c` (`c`) KEY `c` (`c`)
) ENGINE=MARIA AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 ) ENGINE=MARIA AUTO_INCREMENT=16 DEFAULT CHARSET=latin1
drop table t1; drop table t1;
* TEST of removing logs manually
* shut down mysqld, removed logs, restarted it
use mysqltest;
create table t1 (a varchar(1000)) engine=maria;
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;
ERROR HY000: Lost connection to MySQL server during query
* recovery happens
check table t1 extended;
Table Op Msg_type Msg_text
mysqltest.t1 check status OK
* testing that checksum after recovery is as expected
Checksum-check
ok
use mysqltest;
drop table t1;
drop database mysqltest_for_feeding_recovery; drop database mysqltest_for_feeding_recovery;
drop database mysqltest_for_comparison; drop database mysqltest_for_comparison;
drop database mysqltest; drop database mysqltest;
...@@ -179,6 +179,27 @@ let $mvr_crash_statement= set global maria_checkpoint_interval=1; ...@@ -179,6 +179,27 @@ let $mvr_crash_statement= set global maria_checkpoint_interval=1;
show create table t1; show create table t1;
drop table t1; drop table t1;
# Test of removing logs manually
--echo * TEST of removing logs manually
let $mel_keep_control_file=1;
# this will shut mysqld down cleanly (so, take a checkpoint) and
# remove only logs; at restart Maria will create a new log with a high
# number
-- source include/maria_empty_logs.inc
let $mel_keep_control_file=0;
# and see if even a next recovery is ok
let $mvr_restore_old_snapshot=0;
let $mms_compare_physically=0;
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
create table t1 (a varchar(1000)) engine=maria;
insert into t1 values ("00000000");
-- source include/maria_make_snapshot_for_comparison.inc
lock tables t1 write;
insert into t1 values ("aaaaaaaaa");
-- source include/maria_verify_recovery.inc
drop table t1;
# clean up everything # clean up everything
let $mms_purpose=feeding_recovery; let $mms_purpose=feeding_recovery;
eval drop database mysqltest_for_$mms_purpose; eval drop database mysqltest_for_$mms_purpose;
......
...@@ -3205,8 +3205,8 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3205,8 +3205,8 @@ my_bool translog_init_with_table(const char *directory,
if (LSN_FILE_NO(last_checkpoint_lsn) == FILENO_IMPOSSIBLE) if (LSN_FILE_NO(last_checkpoint_lsn) == FILENO_IMPOSSIBLE)
{ {
DBUG_ASSERT(LSN_OFFSET(last_checkpoint_lsn) == 0); DBUG_ASSERT(LSN_OFFSET(last_checkpoint_lsn) == 0);
/* there was no checkpoints we will read from the beginning */ /* only last log needs to be checked */
sure_page= (LSN_ONE_FILE | TRANSLOG_PAGE_SIZE); sure_page= MAKE_LSN(last_logno, TRANSLOG_PAGE_SIZE);
} }
else else
{ {
......
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