Commit 8373b4de authored by unknown's avatar unknown

Fixed core dump when running myisamchk (as this doesn't call translog_init)

Added option --transaction-log to maria_chk


storage/maria/ma_init.c:
  Fixed core dump when running maria_chk (as this doesn't call translog_init)
storage/maria/ma_test_all.sh:
  Added testing of --transaction-log
storage/maria/maria_chk.c:
  Enable logging of repair commands if run with --transaction-log
parent 45714353
...@@ -59,7 +59,8 @@ void maria_end(void) ...@@ -59,7 +59,8 @@ void maria_end(void)
ft_free_stopwords(); ft_free_stopwords();
ma_checkpoint_end(); ma_checkpoint_end();
trnman_destroy(); trnman_destroy();
translog_destroy(); if (translog_inited)
translog_destroy();
end_pagecache(maria_log_pagecache, TRUE); end_pagecache(maria_log_pagecache, TRUE);
end_pagecache(maria_pagecache, TRUE); end_pagecache(maria_pagecache, TRUE);
ma_control_file_end(); ma_control_file_end();
......
...@@ -132,6 +132,7 @@ run_repair_tests() ...@@ -132,6 +132,7 @@ run_repair_tests()
row_type=$1 row_type=$1
$maria_path/ma_test1$suffix $silent --checksum $row_type $maria_path/ma_test1$suffix $silent --checksum $row_type
$maria_path/maria_chk$suffix -se test1 $maria_path/maria_chk$suffix -se test1
$maria_path/maria_chk$suffix --silent -re --transaction-log test1
$maria_path/maria_chk$suffix -rs test1 $maria_path/maria_chk$suffix -rs test1
$maria_path/maria_chk$suffix -se test1 $maria_path/maria_chk$suffix -se test1
$maria_path/maria_chk$suffix -rqs test1 $maria_path/maria_chk$suffix -rqs test1
......
...@@ -41,6 +41,7 @@ static const char *set_collation_name, *opt_tmpdir; ...@@ -41,6 +41,7 @@ static const char *set_collation_name, *opt_tmpdir;
static CHARSET_INFO *set_collation; static CHARSET_INFO *set_collation;
static int stopwords_inited= 0; static int stopwords_inited= 0;
static MY_TMPDIR maria_chk_tmpdir; static MY_TMPDIR maria_chk_tmpdir;
static my_bool opt_transaction_logging;
static const char *type_names[]= static const char *type_names[]=
{ {
...@@ -93,6 +94,7 @@ int main(int argc, char **argv) ...@@ -93,6 +94,7 @@ int main(int argc, char **argv)
int error; int error;
MY_INIT(argv[0]); MY_INIT(argv[0]);
maria_data_root= ".";
maria_chk_init(&check_param); maria_chk_init(&check_param);
check_param.opt_lock_memory= 1; /* Lock memory if possible */ check_param.opt_lock_memory= 1; /* Lock memory if possible */
check_param.using_global_keycache = 0; check_param.using_global_keycache = 0;
...@@ -101,6 +103,26 @@ int main(int argc, char **argv) ...@@ -101,6 +103,26 @@ int main(int argc, char **argv)
error=0; error=0;
maria_init(); maria_init();
/*
If we are doing a repair and we have requested logging (on by default),
enable transaction log handling.
*/
if (opt_transaction_logging && (check_param.testflag & T_REP_ANY) &&
(ma_control_file_create_or_open() ||
init_pagecache(maria_log_pagecache,
TRANSLOG_PAGECACHE_SIZE, 0, 0,
TRANSLOG_PAGE_SIZE, MY_WME) == 0 ||
translog_init(maria_data_root, TRANSLOG_FILE_SIZE,
0, 0, maria_log_pagecache,
TRANSLOG_DEFAULT_FLAGS)))
{
_ma_check_print_error(&check_param,
"Can't initialize transaction logging. Run "
"recovery with switch --skip-transaction-log");
error= 1;
argc= 1; /* Force loop out */
}
while (--argc >= 0) while (--argc >= 0)
{ {
int new_error=maria_chk(&check_param, *(argv++)); int new_error=maria_chk(&check_param, *(argv++));
...@@ -157,7 +179,7 @@ enum options_mc { ...@@ -157,7 +179,7 @@ enum options_mc {
OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE,
OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN, OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN,
OPT_FT_MAX_WORD_LEN, OPT_FT_STOPWORD_FILE, OPT_FT_MAX_WORD_LEN, OPT_FT_STOPWORD_FILE,
OPT_MAX_RECORD_LENGTH, OPT_AUTO_CLOSE, OPT_STATS_METHOD OPT_MAX_RECORD_LENGTH, OPT_AUTO_CLOSE, OPT_STATS_METHOD, OPT_TRANSACTION_LOG
}; };
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
...@@ -279,6 +301,10 @@ static struct my_option my_long_options[] = ...@@ -279,6 +301,10 @@ static struct my_option my_long_options[] =
"Path for temporary files.", "Path for temporary files.",
(uchar**) &opt_tmpdir, (uchar**) &opt_tmpdir,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"transaction-log", OPT_TRANSACTION_LOG,
"Log repair command to transaction log",
(uchar**) &opt_transaction_logging, (uchar**) &opt_transaction_logging,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"update-state", 'U', {"update-state", 'U',
"Mark tables as crashed if any errors were found.", "Mark tables as crashed if any errors were found.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
...@@ -288,13 +314,12 @@ static struct my_option my_long_options[] = ...@@ -288,13 +314,12 @@ static struct my_option my_long_options[] =
{"verbose", 'v', {"verbose", 'v',
"Print more information. This can be used with --description and --check. Use many -v for more verbosity!", "Print more information. This can be used with --description and --check. Use many -v for more verbosity!",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', {"version", 'V', "Print version and exit.",
"Print version and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"wait", 'w', {"wait", 'w', "Wait if table is locked.",
"Wait if table is locked.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "page_buffer_size", OPT_PAGE_BUFFER_SIZE, "", { "page_buffer_size", OPT_PAGE_BUFFER_SIZE,
"Size of page buffer. Used by --safe-repair",
(uchar**) &check_param.use_buffers, (uchar**) &check_param.use_buffers, 0, (uchar**) &check_param.use_buffers, (uchar**) &check_param.use_buffers, 0,
GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) USE_BUFFER_INIT, GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) USE_BUFFER_INIT,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0},
...@@ -308,7 +333,8 @@ static struct my_option my_long_options[] = ...@@ -308,7 +333,8 @@ static struct my_option my_long_options[] =
(uchar**) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (uchar**) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD,
(long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0},
{ "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "", { "sort_buffer_size", OPT_SORT_BUFFER_SIZE,
"Size of sort buffer. Used by --recover",
(uchar**) &check_param.sort_buffer_length, (uchar**) &check_param.sort_buffer_length,
(uchar**) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (uchar**) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG,
(long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), (long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD),
...@@ -403,7 +429,7 @@ static void usage(void) ...@@ -403,7 +429,7 @@ static void usage(void)
-U --update-state Mark tables as crashed if you find any errors.\n\ -U --update-state Mark tables as crashed if you find any errors.\n\
-T, --read-only Don't mark table as checked.\n"); -T, --read-only Don't mark table as checked.\n");
puts("Repair options (When using '-r' or '-o'):\n\ puts("Recover (repair)/ options (When using '-r' or '-o'):\n\
-B, --backup Make a backup of the .MYD file as 'filename-time.BAK'.\n\ -B, --backup Make a backup of the .MYD file as 'filename-time.BAK'.\n\
--correct-checksum Correct checksum information for table.\n\ --correct-checksum Correct checksum information for table.\n\
-D, --data-file-length=# Max length of data file (when recreating data\n\ -D, --data-file-length=# Max length of data file (when recreating data\n\
...@@ -428,6 +454,9 @@ static void usage(void) ...@@ -428,6 +454,9 @@ static void usage(void)
-o, --safe-recover Uses old recovery method; Slower than '-r' but can\n\ -o, --safe-recover Uses old recovery method; Slower than '-r' but can\n\
handle a couple of cases where '-r' reports that it\n\ handle a couple of cases where '-r' reports that it\n\
can't fix the data file.\n\ can't fix the data file.\n\
--transaction-log Log repair command to transaction log. This is needed\n\
if one wants to use the maria_read_log to repeat the \n\
repair\n\
--character-sets-dir=...\n\ --character-sets-dir=...\n\
Directory where character sets are.\n\ Directory where character sets are.\n\
--set-collation=name\n\ --set-collation=name\n\
......
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