Commit e5428802 authored by unknown's avatar unknown

A new option for maria_chk: --zerofill-keep-lsn. This will be used

by ma_test_recovery.pl when it happens that Recovery does not recreate
pages exactly as they were at first run: this option will help us
verify that the differences are in unimportant page pieces (those pieces
will be zeroed by --zerofill-keep-lsn, but not the important LSNs).


include/myisamchk.h:
  new zerofill flag for maria_chk
storage/maria/ma_check.c:
  If T_ZEROFILL_KEEP_LSN, we don't zero out LSNs of data/index pages.
  Then the table is not movable. We still mark it zerofilled, it helps
  to know what was last done to the table.
storage/maria/maria_chk.c:
  New option --zerofill-keep-lsn
parent 08c674ee
......@@ -60,6 +60,7 @@
#define T_WAIT_FOREVER (1L << 30)
#define T_WRITE_LOOP ((ulong) 1L << 31)
#define T_ZEROFILL ((ulonglong) 1L << 32)
#define T_ZEROFILL_KEEP_LSN ((ulonglong) 1L << 33)
/** If repair should not bump create_rename_lsn */
#define T_NO_CREATE_RENAME_LSN ((ulonglong) 1L << 33)
......
......@@ -2952,7 +2952,8 @@ static my_bool maria_zerofill_index(HA_CHECK *param, MARIA_HA *info,
my_off_t pos;
my_off_t key_file_length= share->state.state.key_file_length;
uint block_size= share->block_size;
my_bool transactional= share->base.born_transactional;
my_bool zero_lsn= share->base.born_transactional &&
!(param->testflag & T_ZEROFILL_KEEP_LSN);
DBUG_ENTER("maria_zerofill_index");
if (!(param->testflag & T_SILENT))
......@@ -2979,7 +2980,7 @@ static my_bool maria_zerofill_index(HA_CHECK *param, MARIA_HA *info,
llstr(pos, llbuff), my_errno);
DBUG_RETURN(1);
}
if (transactional)
if (zero_lsn)
bzero(buff, LSN_SIZE);
length= _ma_get_page_used(share, buff);
/* Skip mailformed blocks */
......@@ -3021,6 +3022,7 @@ static my_bool maria_zerofill_data(HA_CHECK *param, MARIA_HA *info,
pgcache_page_no_t page;
uint block_size= share->block_size;
MARIA_FILE_BITMAP *bitmap= &share->bitmap;
my_bool zero_lsn= !(param->testflag & T_ZEROFILL_KEEP_LSN);
DBUG_ENTER("maria_zerofill_data");
/* This works only with BLOCK_RECORD files */
......@@ -3055,16 +3057,23 @@ static my_bool maria_zerofill_data(HA_CHECK *param, MARIA_HA *info,
page_type= buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK;
switch ((enum en_page_type) page_type) {
case UNALLOCATED_PAGE:
bzero(buff, block_size);
if (zero_lsn)
bzero(buff, block_size);
else
bzero(buff + LSN_SIZE, block_size - LSN_SIZE);
break;
case BLOB_PAGE:
if (_ma_bitmap_get_page_bits(info, bitmap, page) == 0)
{
/* Unallocated page */
bzero(buff, block_size);
if (zero_lsn)
bzero(buff, block_size);
else
bzero(buff + LSN_SIZE, block_size - LSN_SIZE);
}
else
bzero(buff, LSN_SIZE);
if (zero_lsn)
bzero(buff, LSN_SIZE);
break;
case HEAD_PAGE:
case TAIL_PAGE:
......@@ -3073,7 +3082,8 @@ static my_bool maria_zerofill_data(HA_CHECK *param, MARIA_HA *info,
uint offset, dir_start;
uchar *dir;
bzero(buff, LSN_SIZE);
if (zero_lsn)
bzero(buff, LSN_SIZE);
if (max_entry != 0)
{
dir= dir_entry_pos(buff, block_size, max_entry - 1);
......@@ -3123,7 +3133,8 @@ static my_bool maria_zerofill_data(HA_CHECK *param, MARIA_HA *info,
int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name)
{
my_bool error, reenable_logging;
my_bool error, reenable_logging,
zero_lsn= !(param->testflag & T_ZEROFILL_KEEP_LSN);
DBUG_ENTER("maria_zerofill");
if ((reenable_logging= info->s->now_transactional))
_ma_tmp_disable_logging_for_table(info, 0);
......@@ -3132,11 +3143,12 @@ int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name)
_ma_set_uuid(info, 0))))
{
/*
Mark that table is movable and that we have done zerofill of data and
index
Mark that we have done zerofill of data and index. If we zeroed pages'
LSN, table is movable.
*/
info->s->state.changed&= ~(STATE_NOT_ZEROFILLED | STATE_NOT_MOVABLE |
STATE_MOVED);
info->s->state.changed&= ~STATE_NOT_ZEROFILLED;
if (zero_lsn)
info->s->state.changed&= ~(STATE_NOT_MOVABLE | STATE_MOVED);
/* Ensure state are flushed to disk */
info->update= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
}
......
......@@ -183,7 +183,7 @@ enum options_mc {
OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN,
OPT_FT_MAX_WORD_LEN, OPT_FT_STOPWORD_FILE,
OPT_MAX_RECORD_LENGTH, OPT_AUTO_CLOSE, OPT_STATS_METHOD, OPT_TRANSACTION_LOG,
OPT_SKIP_SAFEMALLOC
OPT_SKIP_SAFEMALLOC, OPT_ZEROFILL_KEEP_LSN
};
static struct my_option my_long_options[] =
......@@ -375,6 +375,12 @@ static struct my_option my_long_options[] =
{ "zerofill", 'z',
"Fill empty space in data and index files with zeroes",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
{ "zerofill-keep-lsn", OPT_ZEROFILL_KEEP_LSN,
"Like --zerofill but does not zero out LSN of data/index pages;"
" used only for testing and debugging",
#endif
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
......@@ -505,7 +511,13 @@ static void usage(void)
(It may be VERY slow to do a sort the first time!).\n\
-b, --block-search=#\n\
Find a record, a block at given offset belongs to.\n\
-z, --zerofill Fill empty space in data and index files with zeroes.");
-z, --zerofill Fill empty space in data and index files with zeroes"
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
"\n\
--zerofill-keep-lsn Like --zerofill but does not zero out LSN of\n\
data/index pages; used only for testing and debugging"
#endif
".");
print_defaults("my", load_default_groups);
my_print_variables(my_long_options);
......@@ -778,6 +790,14 @@ get_one_option(int optid,
else
check_param.testflag|= T_ZEROFILL;
break;
#ifdef IDENTICAL_PAGES_AFTER_RECOVERY
case OPT_ZEROFILL_KEEP_LSN:
if (argument == disabled_my_option)
check_param.testflag&= ~(T_ZEROFILL_KEEP_LSN | T_ZEROFILL);
else
check_param.testflag|= (T_ZEROFILL_KEEP_LSN | T_ZEROFILL);
break;
#endif
case 'H':
my_print_help(my_long_options);
exit(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