Commit bf0e1f44 authored by Michael Widenius's avatar Michael Widenius

Fixed portability problem with partiton_error.test

Added option to aria_read_log to crash recovery at certain points in the recovery process.
Fixed bug that caused future recovery attempts to fail if we got a crash/got killed during closing of tables at end of recovery process.


mysql-test/mysql-test-run.pl:
  Don't abort if 'var' points to stale place; Just remove it.
mysql-test/suite/maria/r/maria.result:
  Fixed wrong indentation
mysql-test/t/partition_error.test:
  Fixed portability problem with partiton_error.test
storage/maria/ma_close.c:
  More DBUG_PRINT info
storage/maria/ma_pagecache.c:
  Copy flush_log_callback when writing to page cache. This fixes problem in recovery when switching from mode of file
storage/maria/ma_recovery.c:
  Added option to aria_read_log to crash recovery at certain points in the recovery process.
storage/maria/ma_recovery.h:
  Added option to aria_read_log to crash recovery at certain points in the recovery process.
storage/maria/maria_chk.c:
  Align aria_chk -d output
  Don't write warning Aria table '...' is usable but should be fixed if the table was before marked as crashed but now is ok
storage/maria/maria_read_log.c:
  Added option to aria_read_log to crash recovery at certain points in the recovery process.
parent 2f6c43c5
......@@ -2345,9 +2345,11 @@ sub remove_stale_vardir () {
mtr_report(" - WARNING: Using the 'mysql-test/var' symlink");
# Make sure the directory where it points exist
mtr_error("The destination for symlink $opt_vardir does not exist")
if ! -d readlink($opt_vardir);
if (! -d readlink($opt_vardir))
{
mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory");
unlink($opt_vardir);
}
foreach my $bin ( glob("$opt_vardir/*") )
{
mtr_verbose("Removing bin $bin");
......@@ -2414,8 +2416,11 @@ sub setup_vardir() {
# it's a symlink
# Make sure the directory where it points exist
mtr_error("The destination for symlink $opt_vardir does not exist")
if ! -d readlink($opt_vardir);
if (! -d readlink($opt_vardir))
{
mtr_report("The destination for symlink $opt_vardir does not exist; Removing it and creating a new var directory");
unlink($opt_vardir);
}
}
elsif ( $opt_mem )
{
......
......@@ -2131,7 +2131,7 @@ c3 VARCHAR(10) NOT NULL,
KEY (c1),
KEY (c2)
) ENGINE=aria DEFAULT CHARSET=utf8 PACK_KEYS=0;
Aria file: MYSQLD_DATADIR/test/t1
Aria file: MYSQLD_DATADIR/test/t1
Record format: Block
Crashsafe: yes
Character set: utf8_general_ci (33)
......
......@@ -695,14 +695,13 @@ CREATE TABLE t1 (a INT) PARTITION BY HASH (a);
FLUSH TABLES;
--remove_file $MYSQLD_DATADIR/test/t1.par
--replace_result $MYSQLD_DATADIR ./
--replace_result \\ /
CHECK TABLE t1;
--replace_result \\ /
--replace_result $MYSQLD_DATADIR ./
--error 29
SELECT * FROM t1;
--echo # Note that it is currently impossible to drop a partitioned table
--echo # without the .par file
--replace_result \\ /
--replace_result $MYSQLD_DATADIR ./
--error 29
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.frm
......
......@@ -28,7 +28,8 @@ int maria_close(register MARIA_HA *info)
my_bool share_can_be_freed= FALSE;
MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_close");
DBUG_PRINT("enter",("base: 0x%lx reopen: %u locks: %u",
DBUG_PRINT("enter",("name: '%s' base: 0x%lx reopen: %u locks: %u",
share->open_file_name.str,
(long) info, (uint) share->reopen,
(uint) share->tot_locks));
......
......@@ -1808,7 +1808,14 @@ static PAGECACHE_HASH_LINK *get_hash_link(PAGECACHE *pagecache,
hash_link->requests++;
DBUG_ASSERT(hash_link->block == 0);
}
else
{
/*
We have to copy the flush_log callback, as it may change if the table
goes from non_transactional to transactional during recovery
*/
hash_link->file.flush_log_callback= file->flush_log_callback;
}
return hash_link;
}
......
......@@ -60,6 +60,7 @@ static int (*save_error_handler_hook)(uint, const char *,myf);
static uint recovery_warnings; /**< count of warnings */
static uint recovery_found_crashed_tables;
HASH tables_to_redo; /* For maria_read_log */
ulong maria_recovery_force_crash_counter;
#define prototype_redo_exec_hook(R) \
static int exec_REDO_LOGREC_ ## R(const TRANSLOG_HEADER_BUFFER *rec)
......@@ -2939,6 +2940,12 @@ static int run_undo_phase(uint uncommitted)
translog_free_record_header(&rec);
}
/* Force a crash to test recovery of recovery */
if (maria_recovery_force_crash_counter)
{
DBUG_ASSERT(--maria_recovery_force_crash_counter > 0);
}
if (trnman_rollback_trn(trn))
DBUG_RETURN(1);
/* We could want to span a few threads (4?) instead of 1 */
......@@ -3436,6 +3443,12 @@ static int close_all_tables(void)
prepare_table_for_close(info, addr);
error|= maria_close(info);
pthread_mutex_lock(&THR_LOCK_maria);
/* Force a crash to test recovery of recovery */
if (maria_recovery_force_crash_counter)
{
DBUG_ASSERT(--maria_recovery_force_crash_counter > 0);
}
}
end:
pthread_mutex_unlock(&THR_LOCK_maria);
......@@ -3510,7 +3523,7 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info,
/*
Reset state pointers. This is needed as in ALTER table we may do
commit fllowed by _ma_renable_logging_for_table and then
commit followed by _ma_renable_logging_for_table and then
info->state may point to a state that was deleted by
_ma_trnman_end_trans_hook()
*/
......
......@@ -32,4 +32,5 @@ int maria_apply_log(LSN lsn, LSN lsn_end, enum maria_apply_log_way apply,
my_bool take_checkpoints, uint *warnings_count);
/* Table of tables to recover */
extern HASH tables_to_redo;
extern ulong maria_recovery_force_crash_counter;
C_MODE_END
......@@ -949,6 +949,7 @@ static void get_options(register int *argc,register char ***argv)
static int maria_chk(HA_CHECK *param, char *filename)
{
int error,lock_type,recreate;
uint warning_printed_by_chk_status;
my_bool rep_quick= test(param->testflag & (T_QUICK | T_FORCE_UNIQUENESS));
MARIA_HA *info;
File datafile;
......@@ -961,6 +962,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
recreate=0;
datafile=0;
param->isam_file_name=filename; /* For error messages */
warning_printed_by_chk_status= 0;
if (!(info=maria_open(filename,
(param->testflag & (T_DESCRIPT | T_READONLY)) ?
O_RDONLY : O_RDWR,
......@@ -1303,7 +1305,12 @@ static int maria_chk(HA_CHECK *param, char *filename)
maria_chk_init_for_check(param, info);
if (opt_warning_for_wrong_transid == 0)
param->max_trid= ~ (ulonglong) 0;
error= maria_chk_status(param,info);
/* Forget warning printed by maria_chk_status if no problems found */
warning_printed_by_chk_status= param->warning_printed;
param->warning_printed= 0;
maria_intersect_keys_active(share->state.key_map, param->keys_in_use);
error|= maria_chk_size(param,info);
if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE)))
......@@ -1371,8 +1378,12 @@ static int maria_chk(HA_CHECK *param, char *filename)
(state_updated ? UPDATE_STAT : 0) |
((param->testflag & T_SORT_RECORDS) ?
UPDATE_SORT : 0)));
if (!(param->testflag & T_SILENT))
if (warning_printed_by_chk_status)
_ma_check_print_info(param, "Aria table '%s' was ok. Status updated",
filename);
else if (!(param->testflag & T_SILENT))
printf("State updated\n");
warning_printed_by_chk_status= 0;
}
info->update&= ~HA_STATE_CHANGED;
_ma_reenable_logging_for_table(info, FALSE);
......@@ -1426,7 +1437,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
"Aria table '%s' is corrupted\nFix it using switch \"-r\" or \"-o\"\n",
filename));
}
else if (param->warning_printed &&
else if ((param->warning_printed || warning_printed_by_chk_status) &&
! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_FORCE_CREATE)))
{
......@@ -1435,6 +1446,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
VOID(fprintf(stderr, "Aria table '%s' is usable but should be fixed\n",
filename));
}
VOID(fflush(stderr));
DBUG_RETURN(error);
} /* maria_chk */
......@@ -1464,7 +1476,7 @@ static void descript(HA_CHECK *param, register MARIA_HA *info, char *name)
DBUG_VOID_RETURN;
}
printf("Aria file: %s\n",name);
printf("Aria file: %s\n",name);
printf("Record format: %s\n", record_formats[share->data_file_type]);
printf("Crashsafe: %s\n",
share->base.born_transactional ? "yes" : "no");
......
......@@ -166,7 +166,7 @@ int main(int argc, char **argv)
#include "ma_check_standalone.h"
enum options_mc {
OPT_CHARSETS_DIR=256
OPT_CHARSETS_DIR=256, OPT_FORCE_CRASH
};
static struct my_option my_long_options[] =
......@@ -186,6 +186,9 @@ static struct my_option my_long_options[] =
#ifndef DBUG_OFF
{"debug", '#', "Output debug log. Often the argument is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"force-crash", OPT_FORCE_CRASH, "Force crash after # recovery events",
&maria_recovery_force_crash_counter, 0,0, GET_ULONG, REQUIRED_ARG,
0, 0, ~(long) 0, 0, 0, 0},
#endif
{"help", '?', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
......
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