From b7158601d35456fde4167fe44dcf505495b045af Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 10 Sep 2010 02:42:12 +0300 Subject: [PATCH] Fixed bug LP#605798 "wrong data in bitmap" after recovery. Extend remove_function_from_trace.pl to work with many threads (patch from Sergei) dbug/remove_function_from_trace.pl: Extend remove_function_from_trace.pl to work with many threads (patch from Sergei) storage/maria/ma_bitmap.c: Added marker that table had changed since last checkpoint. This ensures that we will flush all bitmap pages from cache at checkpoint. This fixes bug LP#605798 "wrong data in bitmap" after recovery. storage/maria/ma_check.c: Cleaned up error output storage/maria/ma_recovery.c: Cleaned up error output storage/maria/maria_def.h: Added changed_not_flushed --- dbug/remove_function_from_trace.pl | 11 +++++------ storage/maria/ma_bitmap.c | 9 ++++++++- storage/maria/ma_check.c | 2 +- storage/maria/ma_recovery.c | 6 ++++++ storage/maria/maria_def.h | 3 ++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dbug/remove_function_from_trace.pl b/dbug/remove_function_from_trace.pl index 1da9e25f9ba..380df168caf 100755 --- a/dbug/remove_function_from_trace.pl +++ b/dbug/remove_function_from_trace.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl - die <) { - print unless $skip; + ($thd) = /^(T@\d+)/; + print unless $skip{$thd}; next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o; if ($2 eq '>') { - $skip=$1.$3 unless $skip; + $skip{$thd}=$1.$3 unless $skip{$thd}; next; } - next if $skip ne $1.$3; - $skip=''; + next if $skip{$thd} ne $1.$3; + delete $skip{$thd}; print; } diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index ff23c408931..4f37d7b9a1f 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -147,6 +147,12 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share, DBUG_ASSERT(bitmap->file.write_callback != 0); DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable)); + /* + Mark that a bitmap page has been written to page cache and we have + to flush it during checkpoint. + */ + bitmap->changed_not_flushed= 1; + if ((bitmap->non_flushable == 0) #ifdef WRONG_BITMAP_FLUSH || 1 @@ -347,7 +353,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share) MARIA_FILE_BITMAP *bitmap= &share->bitmap; DBUG_ENTER("_ma_bitmap_flush_all"); pthread_mutex_lock(&bitmap->bitmap_lock); - if (bitmap->changed) + if (bitmap->changed || bitmap->changed_not_flushed) { bitmap->flush_all_requested= TRUE; #ifndef WRONG_BITMAP_FLUSH @@ -384,6 +390,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share) &bitmap->pages_covered) & PCFLUSH_PINNED_AND_ERROR) res= TRUE; + bitmap->changed_not_flushed= FALSE; bitmap->flush_all_requested= FALSE; /* Some well-behaved threads may be waiting for flush_all_requested to diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index fa1933913d4..ed3a7a46344 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -1760,7 +1760,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record, _ma_check_print_error(param, "Page %9s: Row: %3d has an extent with " "wrong information in bitmap: " - "Page %9s Page_type: %d Bitmap: %d", + "Page: %9s Page_type: %d Bitmap: %d", llstr(page, llbuff), row, llstr(extent_page, llbuff2), page_type, bitmap_pattern); diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 7442bbef1a0..b4fe96ae168 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -332,6 +332,8 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn, if (end_lsn != LSN_IMPOSSIBLE) { abort_message_printed= 1; + if (!trace_file) + fputc('\n', stderr); my_message(HA_ERR_INITIALIZATION, "Maria recovery aborted as end_lsn/end of file was reached", MYF(0)); @@ -502,9 +504,13 @@ end: } if (error && !abort_message_printed) + { + if (!trace_file) + fputc('\n', stderr); my_message(HA_ERR_INITIALIZATION, "Maria recovery failed. Please run maria_chk -r on all maria " "tables and delete all maria_log.######## files", MYF(0)); + } procent_printed= 0; /* We don't cleanly close tables if we hit some error (may corrupt them by diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index 28f2fd8638d..6be34aae98c 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -244,7 +244,8 @@ typedef struct st_maria_file_bitmap uchar *map; pgcache_page_no_t page; /* Page number for current bitmap */ uint used_size; /* Size of bitmap head that is not 0 */ - my_bool changed; /* 1 if page needs to be flushed */ + my_bool changed; /* 1 if page needs to be written */ + my_bool changed_not_flushed; /* 1 if some bitmap is not flushed */ my_bool flush_all_requested; /**< If _ma_bitmap_flush_all waiting */ uint non_flushable; /**< 0 if bitmap and log are in sync */ PAGECACHE_FILE file; /* datafile where bitmap is stored */