Commit 6bbb0b57 authored by Michael Widenius's avatar Michael Widenius

Added option --start-from-checkpoint to maria_read_log

Print out checked file names in maria_check -s (unless you use a second -s)
Some trivial optimizations

storage/maria/ma_bitmap.c:
  Trivial optimizations:
  - Combine common code (to be able to remove duplicate mutex_lock call)
  - Move setting of thread specific variables outside of mutex
storage/maria/ma_check.c:
  Fixed wrong argument to printf
storage/maria/maria_chk.c:
  Print out checked table names unless -s -s
storage/maria/maria_read_log.c:
  Added option --start-from-checkpoint (to help find bugs in checkpoints)
parent 2d7b9ac7
......@@ -2142,12 +2142,12 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
DBUG_VOID_RETURN;
bitmap= &share->bitmap;
pthread_mutex_lock(&bitmap->bitmap_lock);
if (non_flushable_inc == -1)
{
pthread_mutex_lock(&bitmap->bitmap_lock);
DBUG_ASSERT((int) bitmap->non_flushable > 0);
DBUG_ASSERT(info->non_flushable_state == 1);
info->non_flushable_state= 0;
if (--bitmap->non_flushable == 0)
{
/*
......@@ -2164,11 +2164,11 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
}
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
pthread_mutex_unlock(&bitmap->bitmap_lock);
info->non_flushable_state= 0;
DBUG_VOID_RETURN;
}
DBUG_ASSERT(non_flushable_inc == 1);
DBUG_ASSERT(info->non_flushable_state == 0);
pthread_mutex_lock(&bitmap->bitmap_lock);
while (unlikely(bitmap->flush_all_requested))
{
/*
......@@ -2186,9 +2186,9 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
pthread_cond_wait(&bitmap->bitmap_cond, &bitmap->bitmap_lock);
}
bitmap->non_flushable++;
info->non_flushable_state= 1;
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable));
pthread_mutex_unlock(&bitmap->bitmap_lock);
info->non_flushable_state= 1;
DBUG_VOID_RETURN;
}
......@@ -2217,6 +2217,8 @@ void _ma_bitmap_flushable(MARIA_HA *info, int non_flushable_inc)
Note that we may have 'filler blocks' that are used to split a block
in half; These can be recognized by that they have page_count == 0.
This code also reverse the effect of ma_bitmap_flushable(.., 1);
RETURN
0 ok
1 error (Couldn't write or read bitmap page)
......
......@@ -1930,7 +1930,7 @@ static int check_block_record(HA_CHECK *param, MARIA_HA *info, int extend,
_ma_check_print_error(param,
"Page %9s: Wrong data in bitmap. Page_type: "
"%d full: %d empty_space: %u Bitmap-bits: %d",
llstr(page, llbuff), full_dir, page_type,
llstr(page, llbuff), page_type, full_dir,
empty_space, bitmap_pattern);
if (param->err_count++ > MAXERR || !(param->testflag & T_VERBOSE))
goto err;
......
......@@ -1252,7 +1252,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
}
else if ((param->testflag & T_CHECK) || !(param->testflag & T_AUTO_INC))
{
if (!(param->testflag & T_SILENT) || param->testflag & T_INFO)
if (!(param->testflag & T_VERY_SILENT) || param->testflag & T_INFO)
printf("Checking MARIA file: %s\n",filename);
if (!(param->testflag & T_SILENT))
printf("Data records: %7s Deleted blocks: %7s\n",
......
......@@ -33,7 +33,7 @@ static my_bool opt_display_only, opt_apply, opt_apply_undo, opt_silent;
static my_bool opt_check;
static const char *opt_tmpdir;
static ulong opt_page_buffer_size;
static ulonglong opt_start_from_lsn, opt_end_lsn;
static ulonglong opt_start_from_lsn, opt_end_lsn, opt_start_from_checkpoint;
static MY_TMPDIR maria_chk_tmpdir;
......@@ -94,7 +94,6 @@ int main(int argc, char **argv)
if (opt_display_only)
printf("You are using --display-only, NOTHING will be written to disk\n");
/* LSN could be also --start-from-lsn=# */
lsn= translog_first_lsn_in_log();
if (lsn == LSN_ERROR)
{
......@@ -105,6 +104,14 @@ int main(int argc, char **argv)
{
fprintf(stdout, "The transaction log is empty\n");
}
if (opt_start_from_checkpoint && !opt_start_from_lsn &&
last_checkpoint_lsn != LSN_IMPOSSIBLE)
{
lsn= LSN_IMPOSSIBLE; /* LSN set in maria_apply_log() */
fprintf(stdout, "Starting from checkpoint (%lu,0x%lx)\n",
LSN_IN_PARTS(last_checkpoint_lsn));
}
else
fprintf(stdout, "The transaction log starts from lsn (%lu,0x%lx)\n",
LSN_IN_PARTS(lsn));
......@@ -183,7 +190,7 @@ static struct my_option my_long_options[] =
{"help", '?', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"display-only", 'd', "display brief info read from records' header",
(uchar **) &opt_display_only, (uchar **) &opt_display_only, 0, GET_BOOL,
&opt_display_only, &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",
......@@ -197,6 +204,9 @@ static struct my_option my_long_options[] =
{ "start-from-lsn", 'o', "Start reading log from this lsn",
&opt_start_from_lsn, &opt_start_from_lsn,
0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 0, 0, 0, 0 },
{"start-from-checkpoint", 'C', "Start applying from last checkpoint",
&opt_start_from_checkpoint, &opt_start_from_checkpoint, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "end-lsn", 'e', "Stop applying at this lsn. If end-lsn is used, UNDO:s "
"will not be applied", &opt_end_lsn, &opt_end_lsn,
0, GET_ULL, REQUIRED_ARG, 0, 0, ~(longlong) 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