
#At lp:maria based on revid:monty@mysql.com-20100811213315-npkq331wv35boj99 2903 Michael Widenius 2010-08-12 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 modified: storage/maria/ma_bitmap.c storage/maria/ma_check.c storage/maria/maria_chk.c storage/maria/maria_read_log.c per-file messages: 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) === modified file 'storage/maria/ma_bitmap.c' --- a/storage/maria/ma_bitmap.c 2010-08-10 21:58:08 +0000 +++ b/storage/maria/ma_bitmap.c 2010-08-12 16:46:36 +0000 @@ -2142,12 +2142,12 @@ void _ma_bitmap_flushable(MARIA_HA *info 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 } 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 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 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) === modified file 'storage/maria/ma_check.c' --- a/storage/maria/ma_check.c 2010-08-10 21:58:08 +0000 +++ b/storage/maria/ma_check.c 2010-08-12 16:46:36 +0000 @@ -1930,7 +1930,7 @@ static int check_block_record(HA_CHECK * _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; === modified file 'storage/maria/maria_chk.c' --- a/storage/maria/maria_chk.c 2010-08-10 21:58:08 +0000 +++ b/storage/maria/maria_chk.c 2010-08-12 16:46:36 +0000 @@ -1252,7 +1252,7 @@ static int maria_chk(HA_CHECK *param, ch } 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", === modified file 'storage/maria/maria_read_log.c' --- a/storage/maria/maria_read_log.c 2010-08-10 21:58:08 +0000 +++ b/storage/maria/maria_read_log.c 2010-08-12 16:46:36 +0000 @@ -33,7 +33,7 @@ static my_bool opt_display_only, opt_app 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,8 +104,16 @@ int main(int argc, char **argv) { fprintf(stdout, "The transaction log is empty\n"); } - fprintf(stdout, "The transaction log starts from lsn (%lu,0x%lx)\n", - LSN_IN_PARTS(lsn)); + 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)); if (opt_start_from_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 },