Commit f134f91f authored by unknown's avatar unknown

Flush status differentiation between error and skipping pinned pages.


storage/maria/ma_checkpoint.c:
  React only on errors during the flush.
parent 1bc5e3b9
...@@ -673,8 +673,7 @@ pthread_handler_t ma_checkpoint_background(void *arg) ...@@ -673,8 +673,7 @@ pthread_handler_t ma_checkpoint_background(void *arg)
dfile, FLUSH_KEEP_LAZY, dfile, FLUSH_KEEP_LAZY,
filter_flush_data_file_evenly, filter_flush_data_file_evenly,
&filter_param); &filter_param);
/* note that it may just be a pinned page */ if (unlikely(res & PCFLUSH_ERROR))
if (unlikely(res))
fprintf(stderr, "Maria engine: warning - background page flush" fprintf(stderr, "Maria engine: warning - background page flush"
" failed\n"); " failed\n");
if (filter_param.max_pages == 0) /* bunch all flushed, sleep */ if (filter_param.max_pages == 0) /* bunch all flushed, sleep */
...@@ -696,7 +695,7 @@ pthread_handler_t ma_checkpoint_background(void *arg) ...@@ -696,7 +695,7 @@ pthread_handler_t ma_checkpoint_background(void *arg)
dfile, FLUSH_KEEP_LAZY, dfile, FLUSH_KEEP_LAZY,
filter_flush_data_file_evenly, filter_flush_data_file_evenly,
&filter_param); &filter_param);
if (unlikely(res)) if (unlikely(res & PCFLUSH_ERROR))
fprintf(stderr, "Maria engine: warning - background page flush" fprintf(stderr, "Maria engine: warning - background page flush"
" failed\n"); " failed\n");
if (filter_param.max_pages == 0) /* bunch all flushed, sleep */ if (filter_param.max_pages == 0) /* bunch all flushed, sleep */
...@@ -1149,20 +1148,16 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon) ...@@ -1149,20 +1148,16 @@ static int collect_tables(LEX_STRING *str, LSN checkpoint_start_log_horizon)
flushed, as the REDOs about it will be skipped, it will wrongly not be flushed, as the REDOs about it will be skipped, it will wrongly not be
recovered. If bitmap pages had a rec_lsn it would be different. recovered. If bitmap pages had a rec_lsn it would be different.
*/ */
/**
@todo we ignore the error because it may be just due a pinned page;
we should rather fix the function below to distinguish between
pinned page and write error. Then we can turn the warning into an
error.
*/
if (((filter_param.is_data_file= TRUE), if (((filter_param.is_data_file= TRUE),
flush_pagecache_blocks_with_filter(maria_pagecache, (flush_pagecache_blocks_with_filter(maria_pagecache,
&dfile, FLUSH_KEEP, &dfile, FLUSH_KEEP,
filter, &filter_param)) || filter, &filter_param) &
PCFLUSH_ERROR)) ||
((filter_param.is_data_file= FALSE), ((filter_param.is_data_file= FALSE),
flush_pagecache_blocks_with_filter(maria_pagecache, (flush_pagecache_blocks_with_filter(maria_pagecache,
&kfile, FLUSH_KEEP, &kfile, FLUSH_KEEP,
filter, &filter_param))) filter, &filter_param) &
PCFLUSH_ERROR)))
fprintf(stderr, "Maria engine: warning - checkpoint page flush" fprintf(stderr, "Maria engine: warning - checkpoint page flush"
" failed\n"); /** @todo improve */ " failed\n"); /** @todo improve */
/* /*
......
...@@ -3512,21 +3512,37 @@ static int cmp_sec_link(PAGECACHE_BLOCK_LINK **a, PAGECACHE_BLOCK_LINK **b) ...@@ -3512,21 +3512,37 @@ static int cmp_sec_link(PAGECACHE_BLOCK_LINK **a, PAGECACHE_BLOCK_LINK **b)
} }
/* /**
Flush a portion of changed blocks to disk, @brief Flush a portion of changed blocks to disk, free used blocks
free used blocks if requested if requested
@param pagecache This page cache reference.
@param file File which should be flushed
@param cache Beginning of array of the block.
@param end Reference to the block after last in the array.
@param flush_type Type of the flush.
@param first_errno Where to store first errno of the flush.
@return Operation status
@retval PCFLUSH_OK OK
@retval PCFLUSH_ERROR There was errors during the flush process.
@retval PCFLUSH_PINNED Pinned blocks was met and skipped.
@retval PCFLUSH_PINNED_AND_ERROR PCFLUSH_ERROR and PCFLUSH_PINNED.
*/ */
static int flush_cached_blocks(PAGECACHE *pagecache, static int flush_cached_blocks(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
PAGECACHE_BLOCK_LINK **cache, PAGECACHE_BLOCK_LINK **cache,
PAGECACHE_BLOCK_LINK **end, PAGECACHE_BLOCK_LINK **end,
enum flush_type type) enum flush_type type,
int *first_errno)
{ {
int rc= PCFLUSH_OK;
int error; int error;
int last_errno= 0;
uint count= (uint) (end-cache); uint count= (uint) (end-cache);
DBUG_ENTER("flush_cached_blocks"); DBUG_ENTER("flush_cached_blocks");
*first_errno= 0;
/* Don't lock the cache during the flush */ /* Don't lock the cache during the flush */
pagecache_pthread_mutex_unlock(&pagecache->cache_lock); pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
...@@ -3551,7 +3567,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache, ...@@ -3551,7 +3567,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
PCBLOCK_INFO(block); PCBLOCK_INFO(block);
/* undo the mark put by flush_pagecache_blocks_int(): */ /* undo the mark put by flush_pagecache_blocks_int(): */
block->status&= ~PCBLOCK_IN_FLUSH; block->status&= ~PCBLOCK_IN_FLUSH;
last_errno= -1; rc|= PCFLUSH_PINNED;
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
continue; continue;
} }
...@@ -3592,8 +3608,8 @@ static int flush_cached_blocks(PAGECACHE *pagecache, ...@@ -3592,8 +3608,8 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
if (error) if (error)
{ {
block->status|= PCBLOCK_ERROR; block->status|= PCBLOCK_ERROR;
if (!last_errno) if (!*first_errno)
last_errno= errno ? errno : -1; *first_errno= errno ? errno : -1;
} }
#ifdef THREAD #ifdef THREAD
/* /*
...@@ -3618,7 +3634,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache, ...@@ -3618,7 +3634,7 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
} }
} }
DBUG_RETURN(last_errno); DBUG_RETURN(rc);
} }
...@@ -3646,8 +3662,10 @@ static int flush_cached_blocks(PAGECACHE *pagecache, ...@@ -3646,8 +3662,10 @@ static int flush_cached_blocks(PAGECACHE *pagecache,
this situation. this situation.
@return Operation status @return Operation status
@retval 0 OK @retval PCFLUSH_OK OK
@retval 1 Error @retval PCFLUSH_ERROR There was errors during the flush process.
@retval PCFLUSH_PINNED Pinned blocks was met and skipped.
@retval PCFLUSH_PINNED_AND_ERROR PCFLUSH_ERROR and PCFLUSH_PINNED.
*/ */
static int flush_pagecache_blocks_int(PAGECACHE *pagecache, static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
...@@ -3658,6 +3676,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, ...@@ -3658,6 +3676,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
{ {
PAGECACHE_BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache; PAGECACHE_BLOCK_LINK *cache_buff[FLUSH_CACHE],**cache;
int last_errno= 0; int last_errno= 0;
int rc= PCFLUSH_OK;
DBUG_ENTER("flush_pagecache_blocks_int"); DBUG_ENTER("flush_pagecache_blocks_int");
DBUG_PRINT("enter",("file: %d blocks_used: %lu blocks_changed: %lu", DBUG_PRINT("enter",("file: %d blocks_used: %lu blocks_changed: %lu",
file->file, pagecache->blocks_used, pagecache->blocks_changed)); file->file, pagecache->blocks_used, pagecache->blocks_changed));
...@@ -3818,8 +3837,9 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, ...@@ -3818,8 +3837,9 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
This happens only if there is not enough This happens only if there is not enough
memory for the big block memory for the big block
*/ */
if ((error= flush_cached_blocks(pagecache, file, cache, if ((rc|= flush_cached_blocks(pagecache, file, cache,
end,type))) end, type, &error)) &
PCFLUSH_ERROR)
last_errno=error; last_errno=error;
DBUG_PRINT("info", ("restarting...")); DBUG_PRINT("info", ("restarting..."));
/* /*
...@@ -3853,7 +3873,8 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, ...@@ -3853,7 +3873,8 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
} }
if (pos != cache) if (pos != cache)
{ {
if ((error= flush_cached_blocks(pagecache, file, cache, pos, type))) if ((rc|= flush_cached_blocks(pagecache, file, cache, pos, type,
&error)) & PCFLUSH_ERROR)
last_errno= error; last_errno= error;
} }
/* Wait until list of blocks in switch is empty */ /* Wait until list of blocks in switch is empty */
...@@ -3931,8 +3952,8 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, ...@@ -3931,8 +3952,8 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
if (cache != cache_buff) if (cache != cache_buff)
my_free((uchar*) cache, MYF(0)); my_free((uchar*) cache, MYF(0));
if (last_errno) if (last_errno)
errno=last_errno; /* Return first error */ errno= last_errno; /* Return first error */
DBUG_RETURN(last_errno != 0); DBUG_RETURN(rc);
} }
...@@ -3949,8 +3970,10 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache, ...@@ -3949,8 +3970,10 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
the block will be passed too. the block will be passed too.
@return Operation status @return Operation status
@retval 0 OK @retval PCFLUSH_OK OK
@retval 1 Error @retval PCFLUSH_ERROR There was errors during the flush process.
@retval PCFLUSH_PINNED Pinned blocks was met and skipped.
@retval PCFLUSH_PINNED_AND_ERROR PCFLUSH_ERROR and PCFLUSH_PINNED.
*/ */
int flush_pagecache_blocks_with_filter(PAGECACHE *pagecache, int flush_pagecache_blocks_with_filter(PAGECACHE *pagecache,
......
...@@ -243,6 +243,20 @@ extern void pagecache_unpin(PAGECACHE *pagecache, ...@@ -243,6 +243,20 @@ extern void pagecache_unpin(PAGECACHE *pagecache,
extern void pagecache_unpin_by_link(PAGECACHE *pagecache, extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_BLOCK_LINK *link, PAGECACHE_BLOCK_LINK *link,
LSN lsn); LSN lsn);
/* Results of flush operation (bit field in fact) */
/* The flush is done. */
#define PCFLUSH_OK 0
/* There was errors during the flush process. */
#define PCFLUSH_ERROR 1
/* Pinned blocks was met and skipped. */
#define PCFLUSH_PINNED 2
/* PCFLUSH_ERROR and PCFLUSH_PINNED. */
#define PCFLUSH_PINNED_AND_ERROR (PCFLUSH_ERROR|PCFLUSH_PINNED)
#define flush_pagecache_blocks(A,B,C) \ #define flush_pagecache_blocks(A,B,C) \
flush_pagecache_blocks_with_filter(A,B,C,NULL,NULL) flush_pagecache_blocks_with_filter(A,B,C,NULL,NULL)
extern int flush_pagecache_blocks_with_filter(PAGECACHE *keycache, extern int flush_pagecache_blocks_with_filter(PAGECACHE *keycache,
......
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