From a1255fc299a0c3dd74303cfd0d246ac70634b5e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Jan 2008 23:03:23 +0200 Subject: [PATCH] Support of moving logs in other directory then data root. Fixed typo in maria_read_log "help" output. Compilation warning on Mac OS fixed. mysql-test/include/maria_empty_logs.inc: Added support of moving maria log relatively to master data directory. mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc: Added support of moving maria log relatively to master data directory. mysql-test/include/maria_verify_recovery.inc: Added support of moving maria log relatively to master data directory. mysql-test/t/maria-recovery-master.opt: Check of recovery with logs in other place. mysql-test/t/maria-recovery.test: Check of recovery with logs in other place. storage/maria/ha_maria.cc: Support of moving logs in other directory then data root. storage/maria/ma_loghandler.c: Compilation warning on Mac OS fixed. storage/maria/ma_static.c: Support of moving logs in other directory then data root. storage/maria/ma_test1.c: Support of moving logs in other directory then data root. storage/maria/maria_def.h: Support of moving logs in other directory then data root. storage/maria/maria_read_log.c: Support of moving logs in other directory then data root. Fixed typo in maria_read_log "help" output. --- mysql-test/include/maria_empty_logs.inc | 42 +++++++++---------- ...ria_make_snapshot_for_feeding_recovery.inc | 2 +- mysql-test/include/maria_verify_recovery.inc | 4 +- mysql-test/t/maria-recovery-master.opt | 2 +- mysql-test/t/maria-recovery.test | 1 + storage/maria/ha_maria.cc | 10 ++++- storage/maria/ma_loghandler.c | 8 ++-- storage/maria/ma_static.c | 2 +- storage/maria/ma_test1.c | 2 +- storage/maria/maria_def.h | 2 +- storage/maria/maria_read_log.c | 8 +++- 11 files changed, 48 insertions(+), 35 deletions(-) diff --git a/mysql-test/include/maria_empty_logs.inc b/mysql-test/include/maria_empty_logs.inc index 1849eaf82a2..2a4defe7b82 100644 --- a/mysql-test/include/maria_empty_logs.inc +++ b/mysql-test/include/maria_empty_logs.inc @@ -15,48 +15,48 @@ EOF if (!$mel_keep_control_file) { - remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control; + remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log_control; } -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000001; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000001; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000002; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000002; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000003; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000003; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000004; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000004; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000005; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000005; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000006; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000006; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000007; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000007; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000008; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000008; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000009; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000009; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000010; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000010; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000011; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000011; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000012; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000012; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000013; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000013; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000014; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000014; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000015; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000015; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000016; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000016; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000017; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000017; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000018; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000018; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000019; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000019; -- error 0,1 -remove_file $MYSQLTEST_VARDIR/master-data/maria_log.00000020; +remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log.00000020; # hope there are not more than these logs... -- error 0,1 diff --git a/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc b/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc index 2ca6fb07808..369f5eec927 100644 --- a/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc +++ b/mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc @@ -30,6 +30,6 @@ let $mms_copy=0; -- error 0,1 remove_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control; -copy_file $MYSQLTEST_VARDIR/master-data/maria_log_control $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control; +copy_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log_control $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control; connection default; diff --git a/mysql-test/include/maria_verify_recovery.inc b/mysql-test/include/maria_verify_recovery.inc index 48d799162a4..867479ba127 100644 --- a/mysql-test/include/maria_verify_recovery.inc +++ b/mysql-test/include/maria_verify_recovery.inc @@ -55,8 +55,8 @@ if ($mvr_restore_old_snapshot) # also copy back control file, to force recovery to start from an early # point, ignoring further checkpoints. -- error 0,1 - remove_file $MYSQLTEST_VARDIR/master-data/maria_log_control; - copy_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control $MYSQLTEST_VARDIR/master-data/maria_log_control; + remove_file $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log_control; + copy_file $MYSQLTEST_VARDIR/tmp/mms_for_$mms_purpose.maria_log_control $MYSQLTEST_VARDIR/master-data/$MARIA_LOG/maria_log_control; } --echo * recovery happens diff --git a/mysql-test/t/maria-recovery-master.opt b/mysql-test/t/maria-recovery-master.opt index d09f57dc35d..acfa03da2d5 100644 --- a/mysql-test/t/maria-recovery-master.opt +++ b/mysql-test/t/maria-recovery-master.opt @@ -1,2 +1,2 @@ ---skip-stack-trace --skip-core-file --loose-debug-on=1 +--skip-stack-trace --skip-core-file --loose-debug-on=1 --maria-log-dir-path=../tmp diff --git a/mysql-test/t/maria-recovery.test b/mysql-test/t/maria-recovery.test index 116a5476d46..e9d13f1f819 100644 --- a/mysql-test/t/maria-recovery.test +++ b/mysql-test/t/maria-recovery.test @@ -6,6 +6,7 @@ --source include/have_maria.inc set global maria_log_file_size=4294967295; +let $MARIA_LOG=../tmp; --disable_warnings drop database if exists mysqltest; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 9d799031eb2..935daea33d6 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -128,6 +128,13 @@ static MYSQL_SYSVAR_BOOL(page_checksum, maria_page_checksums, 0, "Maintain page checksums (can be overridden per table " "with PAGE_CHECKSUM clause in CREATE TABLE)", 0, 0, 1); +/* It is only command line argument */ +static MYSQL_SYSVAR_STR(log_dir_path, maria_data_root, + PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_RQCMDARG, + "Path to the directory where to store transactional log", + NULL, NULL, mysql_real_data_home); + + static MYSQL_SYSVAR_ULONG(log_file_size, log_file_size, PLUGIN_VAR_RQCMDARG, "Limit for transaction log size", @@ -2756,7 +2763,6 @@ static int ha_maria_init(void *p) /* TODO: decide if we support Maria being used for log tables */ maria_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES; bzero(maria_log_pagecache, sizeof(*maria_log_pagecache)); - maria_data_root= mysql_real_data_home; maria_tmpdir= &mysql_tmpdir_list; /* For REDO */ res= maria_init() || ma_control_file_create_or_open() || !init_pagecache(maria_pagecache, @@ -2856,6 +2862,7 @@ static struct st_mysql_sys_var* system_variables[]= { MYSQL_SYSVAR(block_size), MYSQL_SYSVAR(checkpoint_interval), MYSQL_SYSVAR(page_checksum), + MYSQL_SYSVAR(log_dir_path), MYSQL_SYSVAR(log_file_size), MYSQL_SYSVAR(log_purge_type), MYSQL_SYSVAR(max_sort_file_size), @@ -2895,6 +2902,7 @@ static void update_log_file_size(MYSQL_THD thd, *(ulong *)var_ptr= size; } + static SHOW_VAR status_variables[]= { {"Maria_pagecache_blocks_not_flushed", (char*) &maria_pagecache_var.global_blocks_changed, SHOW_LONG_NOFLUSH}, {"Maria_pagecache_blocks_unused", (char*) &maria_pagecache_var.blocks_unused, SHOW_LONG_NOFLUSH}, diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 21e2262c4a9..9cde974d581 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -2444,7 +2444,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) } } file->is_sync= 0; - if (my_pwrite(file->handler.file, (char*) buffer->buffer, + if (my_pwrite(file->handler.file, buffer->buffer, buffer->size, LSN_OFFSET(buffer->offset), log_write_flags)) { @@ -2905,7 +2905,7 @@ restart: buffer= (uchar*) pagecache_read(log_descriptor.pagecache, &file->handler, LSN_OFFSET(addr) / TRANSLOG_PAGE_SIZE, - 3, (direct_link ? NULL : (char*) buffer), + 3, (direct_link ? NULL : buffer), PAGECACHE_PLAIN_PAGE, (direct_link ? PAGECACHE_LOCK_READ : @@ -5024,7 +5024,7 @@ static void translog_relative_LSN_encode(struct st_translog_parts *parts, We write the result in backward direction with no special sense or tricks both directions are equal in complicity */ - for (src_ptr= buffer + lsns_len - LSN_STORE_SIZE; + for (src_ptr= ((uchar*) buffer) + lsns_len - LSN_STORE_SIZE; src_ptr >= (uchar*) buffer; src_ptr-= LSN_STORE_SIZE) { @@ -8300,7 +8300,7 @@ static void dump_datapage(uchar *buffer) static void dump_page(uchar *buffer) { printf("Page by offset %lld\n", opt_offset); - if (strncmp(maria_trans_file_magic, buffer, + if (strncmp((char*)maria_trans_file_magic, (char*)buffer, sizeof(maria_trans_file_magic)) == 0) { dump_header_page(buffer); diff --git a/storage/maria/ma_static.c b/storage/maria/ma_static.c index cdda3d5dd7f..07f593d5be2 100644 --- a/storage/maria/ma_static.c +++ b/storage/maria/ma_static.c @@ -51,7 +51,7 @@ PAGECACHE *maria_pagecache= &maria_pagecache_var; PAGECACHE maria_log_pagecache_var; PAGECACHE *maria_log_pagecache= &maria_log_pagecache_var; MY_TMPDIR *maria_tmpdir; /* Tempdir for redo */ -const char *maria_data_root; +char *maria_data_root; /** @brief when transactionality does not matter we can use this transaction diff --git a/storage/maria/ma_test1.c b/storage/maria/ma_test1.c index a23d37a82af..dbad1c8e11a 100644 --- a/storage/maria/ma_test1.c +++ b/storage/maria/ma_test1.c @@ -24,7 +24,7 @@ #include "trnman.h" extern PAGECACHE *maria_log_pagecache; -extern const char *maria_data_root; +extern char *maria_data_root; #define MAX_REC_LENGTH 1024 diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index b0d9f913ce3..5d21355db91 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -725,7 +725,7 @@ extern uchar maria_file_magic[], maria_pack_file_magic[]; extern uchar maria_uuid[MY_UUID_SIZE]; extern uint maria_read_vec[], maria_readnext_vec[]; extern uint maria_quick_table_bits; -extern const char *maria_data_root; +extern char *maria_data_root; extern uchar maria_zero_string[]; extern my_bool maria_inited; diff --git a/storage/maria/maria_read_log.c b/storage/maria/maria_read_log.c index 21de2f07381..8dbef6936ba 100644 --- a/storage/maria/maria_read_log.c +++ b/storage/maria/maria_read_log.c @@ -45,9 +45,9 @@ int main(int argc, char **argv) load_defaults("my", load_default_groups, &argc, &argv); default_argv= argv; + maria_data_root= (char *)"."; get_options(&argc, &argv); - maria_data_root= "."; maria_in_recovery= TRUE; if (maria_init()) @@ -171,6 +171,10 @@ static struct my_option my_long_options[] = {"display-only", 'd', "display brief info read from records' header", (uchar **) &opt_display_only, (uchar **) &opt_display_only, 0, GET_BOOL, NO_ARG,0, 0, 0, 0, 0, 0}, + {"maria_log_dir_path", 'l', + "Path to the directory where to store transactional log", + (uchar **) &maria_data_root, (uchar **) &maria_data_root, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "page_buffer_size", 'P', "", (uchar**) &opt_page_buffer_size, (uchar**) &opt_page_buffer_size, 0, GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, @@ -224,7 +228,7 @@ static void usage(void) "test scripts that tries to compare files before and after recovery."); #endif VOID(printf("\nUsage: %s OPTIONS\n", my_progname_short)); - puts("You need to use one of -o or -a"); + puts("You need to use one of -d or -a"); my_print_help(my_long_options); print_defaults("my", load_default_groups); my_print_variables(my_long_options);