Commit b7158601 authored by Michael Widenius's avatar Michael Widenius

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
parent 6f59c41d
#!/usr/bin/perl #!/usr/bin/perl
die <<EEE unless @ARGV; die <<EEE unless @ARGV;
Usage: $0 func1 [func2 [ ...] ] Usage: $0 func1 [func2 [ ...] ]
...@@ -11,16 +10,16 @@ DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function. ...@@ -11,16 +10,16 @@ DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function.
EEE EEE
$re=join('|', @ARGV); $re=join('|', @ARGV);
$skip='';
while(<STDIN>) { while(<STDIN>) {
print unless $skip; ($thd) = /^(T@\d+)/;
print unless $skip{$thd};
next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o; next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o;
if ($2 eq '>') { if ($2 eq '>') {
$skip=$1.$3 unless $skip; $skip{$thd}=$1.$3 unless $skip{$thd};
next; next;
} }
next if $skip ne $1.$3; next if $skip{$thd} ne $1.$3;
$skip=''; delete $skip{$thd};
print; print;
} }
...@@ -147,6 +147,12 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share, ...@@ -147,6 +147,12 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share,
DBUG_ASSERT(bitmap->file.write_callback != 0); DBUG_ASSERT(bitmap->file.write_callback != 0);
DBUG_PRINT("info", ("bitmap->non_flushable: %u", bitmap->non_flushable)); 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) if ((bitmap->non_flushable == 0)
#ifdef WRONG_BITMAP_FLUSH #ifdef WRONG_BITMAP_FLUSH
|| 1 || 1
...@@ -347,7 +353,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share) ...@@ -347,7 +353,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share)
MARIA_FILE_BITMAP *bitmap= &share->bitmap; MARIA_FILE_BITMAP *bitmap= &share->bitmap;
DBUG_ENTER("_ma_bitmap_flush_all"); DBUG_ENTER("_ma_bitmap_flush_all");
pthread_mutex_lock(&bitmap->bitmap_lock); pthread_mutex_lock(&bitmap->bitmap_lock);
if (bitmap->changed) if (bitmap->changed || bitmap->changed_not_flushed)
{ {
bitmap->flush_all_requested= TRUE; bitmap->flush_all_requested= TRUE;
#ifndef WRONG_BITMAP_FLUSH #ifndef WRONG_BITMAP_FLUSH
...@@ -384,6 +390,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share) ...@@ -384,6 +390,7 @@ my_bool _ma_bitmap_flush_all(MARIA_SHARE *share)
&bitmap->pages_covered) & &bitmap->pages_covered) &
PCFLUSH_PINNED_AND_ERROR) PCFLUSH_PINNED_AND_ERROR)
res= TRUE; res= TRUE;
bitmap->changed_not_flushed= FALSE;
bitmap->flush_all_requested= FALSE; bitmap->flush_all_requested= FALSE;
/* /*
Some well-behaved threads may be waiting for flush_all_requested to Some well-behaved threads may be waiting for flush_all_requested to
......
...@@ -1760,7 +1760,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record, ...@@ -1760,7 +1760,7 @@ static my_bool check_head_page(HA_CHECK *param, MARIA_HA *info, uchar *record,
_ma_check_print_error(param, _ma_check_print_error(param,
"Page %9s: Row: %3d has an extent with " "Page %9s: Row: %3d has an extent with "
"wrong information in bitmap: " "wrong information in bitmap: "
"Page %9s Page_type: %d Bitmap: %d", "Page: %9s Page_type: %d Bitmap: %d",
llstr(page, llbuff), row, llstr(page, llbuff), row,
llstr(extent_page, llbuff2), llstr(extent_page, llbuff2),
page_type, bitmap_pattern); page_type, bitmap_pattern);
......
...@@ -332,6 +332,8 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn, ...@@ -332,6 +332,8 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
if (end_lsn != LSN_IMPOSSIBLE) if (end_lsn != LSN_IMPOSSIBLE)
{ {
abort_message_printed= 1; abort_message_printed= 1;
if (!trace_file)
fputc('\n', stderr);
my_message(HA_ERR_INITIALIZATION, my_message(HA_ERR_INITIALIZATION,
"Maria recovery aborted as end_lsn/end of file was reached", "Maria recovery aborted as end_lsn/end of file was reached",
MYF(0)); MYF(0));
...@@ -502,9 +504,13 @@ end: ...@@ -502,9 +504,13 @@ end:
} }
if (error && !abort_message_printed) if (error && !abort_message_printed)
{
if (!trace_file)
fputc('\n', stderr);
my_message(HA_ERR_INITIALIZATION, my_message(HA_ERR_INITIALIZATION,
"Maria recovery failed. Please run maria_chk -r on all maria " "Maria recovery failed. Please run maria_chk -r on all maria "
"tables and delete all maria_log.######## files", MYF(0)); "tables and delete all maria_log.######## files", MYF(0));
}
procent_printed= 0; procent_printed= 0;
/* /*
We don't cleanly close tables if we hit some error (may corrupt them by We don't cleanly close tables if we hit some error (may corrupt them by
......
...@@ -244,7 +244,8 @@ typedef struct st_maria_file_bitmap ...@@ -244,7 +244,8 @@ typedef struct st_maria_file_bitmap
uchar *map; uchar *map;
pgcache_page_no_t page; /* Page number for current bitmap */ pgcache_page_no_t page; /* Page number for current bitmap */
uint used_size; /* Size of bitmap head that is not 0 */ 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 */ my_bool flush_all_requested; /**< If _ma_bitmap_flush_all waiting */
uint non_flushable; /**< 0 if bitmap and log are in sync */ uint non_flushable; /**< 0 if bitmap and log are in sync */
PAGECACHE_FILE file; /* datafile where bitmap is stored */ PAGECACHE_FILE file; /* datafile where bitmap is stored */
......
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