summaryrefslogtreecommitdiff
path: root/storage/maria
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-06-13 12:46:11 +0300
committerMichael Widenius <monty@askmonty.org>2011-06-13 12:46:11 +0300
commitbf0e1f44c6b3306e84bbfd783c898a1764836242 (patch)
tree4dcf93558b18c7fdf52ee2b4a445a78973f01513 /storage/maria
parent2f6c43c5a02482ba92f2d463a6f5bf6383f0ec51 (diff)
downloadmariadb-git-bf0e1f44c6b3306e84bbfd783c898a1764836242.tar.gz
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.
Diffstat (limited to 'storage/maria')
-rw-r--r--storage/maria/ma_close.c3
-rw-r--r--storage/maria/ma_pagecache.c9
-rw-r--r--storage/maria/ma_recovery.c15
-rw-r--r--storage/maria/ma_recovery.h1
-rw-r--r--storage/maria/maria_chk.c18
-rw-r--r--storage/maria/maria_read_log.c5
6 files changed, 44 insertions, 7 deletions
diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c
index e97664ebe42..2427dfd042d 100644
--- a/storage/maria/ma_close.c
+++ b/storage/maria/ma_close.c
@@ -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));
diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c
index 0e44b0e7a22..8272aa970c5 100644
--- a/storage/maria/ma_pagecache.c
+++ b/storage/maria/ma_pagecache.c
@@ -1808,7 +1808,14 @@ restart:
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;
}
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 5be30dee0b5..8752f70668c 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -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()
*/
diff --git a/storage/maria/ma_recovery.h b/storage/maria/ma_recovery.h
index 5b22c4fd9b2..45dba0e86b3 100644
--- a/storage/maria/ma_recovery.h
+++ b/storage/maria/ma_recovery.h
@@ -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
diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c
index bb345f63b02..ec8af652fe3 100644
--- a/storage/maria/maria_chk.c
+++ b/storage/maria/maria_chk.c
@@ -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 @@ end2:
"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 @@ end2:
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");
diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c
index b335aa3692e..9471f01dbc8 100644
--- a/storage/maria/maria_read_log.c
+++ b/storage/maria/maria_read_log.c
@@ -166,7 +166,7 @@ err:
#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},