Commit 75a8907e authored by unknown's avatar unknown

Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-maria

into  gbichot4.local:/home/mysql_src/mysql-maria-for-undo-phase


storage/maria/ma_loghandler.c:
  Auto merged
storage/maria/ma_recovery.c:
  Auto merged
mysql-test/r/maria-recovery.result:
  merge
mysql-test/t/maria-recovery.test:
  merge
parents 6cad0204 e580e058
# 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
......
set global storage_engine=maria; set global storage_engine=maria;
set session storage_engine=maria; set session storage_engine=maria;
set global maria_log_file_size=4294967296; set global maria_log_file_size=4294967295;
drop table if exists t1,t2; drop table if exists t1,t2;
SET SQL_WARNINGS=1; SET SQL_WARNINGS=1;
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -222,6 +222,16 @@ flush table t1; ...@@ -222,6 +222,16 @@ flush table t1;
lock tables t1 write; lock tables t1 write;
insert into t1 values(3); insert into t1 values(3);
delete from t1 where a in (1,2,3); delete from t1 where a in (1,2,3);
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"; SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
* crashing mysqld intentionally * crashing mysqld intentionally
set global maria_checkpoint_interval=1; set global maria_checkpoint_interval=1;
......
...@@ -6,7 +6,7 @@ set session storage_engine=maria; ...@@ -6,7 +6,7 @@ set session storage_engine=maria;
let $def_logsize=`select @@global.maria_log_file_size`; let $def_logsize=`select @@global.maria_log_file_size`;
let $def_checkinterval=`select @@global.maria_checkpoint_interval`; let $def_checkinterval=`select @@global.maria_checkpoint_interval`;
set global maria_log_file_size=4294967296; set global maria_log_file_size=4294967295;
# Initialise # Initialise
--disable_warnings --disable_warnings
drop table if exists t1,t2; drop table if exists t1,t2;
......
...@@ -179,6 +179,16 @@ let $mvr_crash_statement= set global maria_checkpoint_interval=1; ...@@ -179,6 +179,16 @@ 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;
# next test will help us verify that a next recovery is ok
--echo * TEST of UNDO_ROW_DELETE preserving rowid --echo * TEST of UNDO_ROW_DELETE preserving rowid
# we want recovery to use the tables as they were at time of crash # we want recovery to use the tables as they were at time of crash
let $mvr_restore_old_snapshot=0; let $mvr_restore_old_snapshot=0;
......
...@@ -3073,7 +3073,7 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3073,7 +3073,7 @@ my_bool translog_init_with_table(const char *directory,
int old_log_was_recovered= 0, logs_found= 0; int old_log_was_recovered= 0, logs_found= 0;
uint old_flags= flags; uint old_flags= flags;
uint32 start_file_num= 1; uint32 start_file_num= 1;
TRANSLOG_ADDRESS sure_page, last_page, last_valid_page; TRANSLOG_ADDRESS sure_page, last_page, last_valid_page, checkpoint_lsn;
my_bool version_changed= 0; my_bool version_changed= 0;
DBUG_ENTER("translog_init_with_table"); DBUG_ENTER("translog_init_with_table");
...@@ -3161,13 +3161,6 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3161,13 +3161,6 @@ my_bool translog_init_with_table(const char *directory,
log_descriptor.buffer_capacity_chunk_2, log_descriptor.buffer_capacity_chunk_2,
log_descriptor.half_buffer_capacity_chunk_2)); log_descriptor.half_buffer_capacity_chunk_2));
/*
last_logno and last_checkpoint_lsn were set in
ma_control_file_create_or_open()
*/
logs_found= (last_logno != FILENO_IMPOSSIBLE);
/* Just to init it somehow (hack for bootstrap)*/ /* Just to init it somehow (hack for bootstrap)*/
{ {
TRANSLOG_FILE *file= 0; TRANSLOG_FILE *file= 0;
...@@ -3196,6 +3189,7 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3196,6 +3189,7 @@ my_bool translog_init_with_table(const char *directory,
logs_found= (last_logno != FILENO_IMPOSSIBLE); logs_found= (last_logno != FILENO_IMPOSSIBLE);
translog_status= (readonly ? TRANSLOG_READONLY : TRANSLOG_OK); translog_status= (readonly ? TRANSLOG_READONLY : TRANSLOG_OK);
checkpoint_lsn= last_checkpoint_lsn;
if (logs_found) if (logs_found)
{ {
...@@ -3211,8 +3205,8 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3211,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
{ {
...@@ -3226,8 +3220,12 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3226,8 +3220,12 @@ my_bool translog_init_with_table(const char *directory,
{ {
if (!translog_is_log_files()) if (!translog_is_log_files())
{ {
/* files was deleted, just start from the next log number */ /*
Files was deleted, just start from the next log number, so that
existing tables are in the past.
*/
start_file_num= last_logno + 1; start_file_num= last_logno + 1;
checkpoint_lsn= LSN_IMPOSSIBLE; /* no log so no checkpoint */
logs_found= 0; logs_found= 0;
} }
else else
...@@ -3471,8 +3469,8 @@ my_bool translog_init_with_table(const char *directory, ...@@ -3471,8 +3469,8 @@ my_bool translog_init_with_table(const char *directory,
DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 == DBUG_ASSERT(log_descriptor.max_file - log_descriptor.min_file + 1 ==
log_descriptor.open_files.elements); log_descriptor.open_files.elements);
if (ma_control_file_write_and_force(LSN_IMPOSSIBLE, 1, if (ma_control_file_write_and_force(checkpoint_lsn, start_file_num,
CONTROL_FILE_UPDATE_ONLY_LOGNO)) CONTROL_FILE_UPDATE_ALL))
DBUG_RETURN(1); DBUG_RETURN(1);
/* assign buffer 0 */ /* assign buffer 0 */
translog_start_buffer(log_descriptor.buffers, &log_descriptor.bc, 0); translog_start_buffer(log_descriptor.buffers, &log_descriptor.bc, 0);
...@@ -3742,7 +3740,8 @@ void translog_destroy() ...@@ -3742,7 +3740,8 @@ void translog_destroy()
my_close(log_descriptor.directory_fd, MYF(MY_WME)); my_close(log_descriptor.directory_fd, MYF(MY_WME));
my_atomic_rwlock_destroy(&LOCK_id_to_share); my_atomic_rwlock_destroy(&LOCK_id_to_share);
my_free((uchar*)(id_to_share + 1), MYF(MY_ALLOW_ZERO_PTR)); if (id_to_share != NULL)
my_free((uchar*)(id_to_share + 1), MYF(MY_WME));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -331,13 +331,8 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply, ...@@ -331,13 +331,8 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply,
{ {
if (last_checkpoint_lsn == LSN_IMPOSSIBLE) if (last_checkpoint_lsn == LSN_IMPOSSIBLE)
{ {
from_lsn= translog_first_theoretical_lsn(); from_lsn= translog_first_lsn_in_log();
/* if (unlikely(from_lsn == LSN_ERROR))
as far as we have not yet any checkpoint then the very first
log file should be present.
*/
if (unlikely((from_lsn == LSN_IMPOSSIBLE) ||
(from_lsn == LSN_ERROR)))
goto err; goto err;
} }
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