Commit 0f3d4b2f authored by Michael Widenius's avatar Michael Widenius

Fixed bug that 'maria_read_log -a' didn't set max_trid when reparing tables.

Fixed bug in Aria when replacing short keys with long keys and a key tree both overflow and underflow at same time.
Fixed several bugs when generating recovery logs when using RGQ with replacing long keys with short keys and vice versa.
Lots of new DBUG_ASSERT()'s
Added more information to recovery log to make it easier to know from where log entry orginated.
Introduced MARIA_PAGE->org_size that tells what the size of the page was in last log entry. This allows us to find out if all key changes for index page was logged.
Small code cleanups:
- Introduced _ma_log_key_changes() to log crc of key page changes
- Added share->max_index_block_size as max size of data one can put in key block (block_size - KEYPAGE_CHECKSUM_SIZE)
  This will later simplify adding a directory to index pages.
- Write page number instead of page postition to DBUG log



mysql-test/lib/v1/mysql-test-run.pl:
  Use --general-log instead of --log to disable warning when using RQG
sql/mysqld.cc:
  If we have already sent ok to client when we get an error, log this to stderr
  Don't disable option --log-output if CSV engine is not supported.
storage/maria/ha_maria.cc:
  Log queries to recovery log also in LOCK TABLES
storage/maria/ma_check.c:
  If param->max_trid is set, use this value instead of max_trid_in_system().
  This is used by recovery to set max_trid to max seen trid so far.
  keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE -> max_index_block_size (Style optimization)
storage/maria/ma_delete.c:
  Mark tables crashed early
  Write page number instead of page position to debug log.
  Added parameter to ma_log_delete() and ma_log_prefix() that is logged so that we can find where wrong log entries where generated.
  Fixed bug where a page was not proplerly written when same key tree had both an overflow and underflow when deleting a key.
  keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE => max_index_block_size (Style optimization)
  ma_log_delete() now has extra parameter of how many bytes from end of page should be appended to log for page (for page overflows)
storage/maria/ma_key_recover.c:
  Added extra parameter to ma_log_prefix() to indicate what caused log entry.
  Update MARIA_PAGE->org_size when logging info about page.
  Much more DBUG_ASSERT()'s.
  Fix some bugs in maria_log_add() to handle page overflows.
  Added _ma_log_key_changes() to log crc of key page changes.
  If EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES is defines, log the resulting pages to log so one can trivally
  see how the resulting page should have looked like (for errors in CRC values)
storage/maria/ma_key_recover.h:
  Added _ma_log_key_changes() which is only called if EXTRA_DEBUG_KEY_CHANGES is defined.
  Updated function prototypes.
storage/maria/ma_loghandler.h:
  Added more values to en_key_debug, to get more exact location where things went wrong when logging to recovery log.
storage/maria/ma_open.c:
  Initialize share->max_index_block_size
storage/maria/ma_page.c:
  Added updating and testing of MARIA_PAGE->org_size
  Write page number instead of page postition to DBUG log
  Generate error if we read page with wrong data.
  Removed wrong assert: key_del_current != share->state.key_del.
  Simplify _ma_log_compact_keypage()
storage/maria/ma_recovery.c:
  Set param.max_trid to max seen trid before running repair table (used for alter table to create index)
storage/maria/ma_rt_key.c:
  Update call to _ma_log_delete()
storage/maria/ma_rt_split.c:
  Use _ma_log_key_changes()
  Update MARIA_PAGE->org_size
storage/maria/ma_unique.c:
  Remove casts
storage/maria/ma_write.c:
  keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE => share->max_index_block_length.
  Updated calls to _ma_log_prefix()
  Changed code to use _ma_log_key_changes()
  Update ma_page->org_size
  Fixed bug in _ma_log_split() for pages that overflow
  Added KEY_OP_DEBUG logging to functions
  Log KEYPAGE_FLAG in all log entries
storage/maria/maria_def.h:
  Added SHARE->max_index_block_size
  Added MARIA_PAGE->org_size
storage/maria/trnman.c:
  Reset flags for new transaction.
parent ad6d95d3
...@@ -2959,7 +2959,7 @@ sub run_benchmarks ($) { ...@@ -2959,7 +2959,7 @@ sub run_benchmarks ($) {
if ( ! $benchmark ) if ( ! $benchmark )
{ {
mtr_add_arg($args, "--log"); mtr_add_arg($args, "--general-log");
mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", ""); mtr_run("$glob_mysql_bench_dir/run-all-tests", $args, "", "", "", "");
# FIXME check result code?! # FIXME check result code?!
} }
......
...@@ -3070,7 +3070,19 @@ int my_message_sql(uint error, const char *str, myf MyFlags) ...@@ -3070,7 +3070,19 @@ int my_message_sql(uint error, const char *str, myf MyFlags)
} }
else else
{ {
if (! thd->main_da.is_error()) // Return only first message if (thd->main_da.is_ok())
{
/*
Client has already got ok packet; Write message to error log.
This could happen if we get an error in implicit commit.
This should never happen in normal operation, so lets
assert here in debug builds.
*/
DBUG_ASSERT(0);
func= sql_print_error;
MyFlags|= ME_NOREFRESH;
}
else if (! thd->main_da.is_error()) // Return only first message
{ {
thd->main_da.set_error_status(thd, error, str); thd->main_da.set_error_status(thd, error, str);
} }
...@@ -4185,7 +4197,6 @@ a file name for --log-bin-index option", opt_binlog_index_name); ...@@ -4185,7 +4197,6 @@ a file name for --log-bin-index option", opt_binlog_index_name);
unireg_abort(1); unireg_abort(1);
} }
#ifdef WITH_CSV_STORAGE_ENGINE
if (opt_bootstrap) if (opt_bootstrap)
log_output_options= LOG_FILE; log_output_options= LOG_FILE;
else else
...@@ -4219,10 +4230,6 @@ a file name for --log-bin-index option", opt_binlog_index_name); ...@@ -4219,10 +4230,6 @@ a file name for --log-bin-index option", opt_binlog_index_name);
logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE, logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE,
opt_log ? log_output_options:LOG_NONE); opt_log ? log_output_options:LOG_NONE);
} }
#else
logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE,
opt_log ? LOG_FILE:LOG_NONE);
#endif
/* /*
Check that the default storage engine is actually available. Check that the default storage engine is actually available.
...@@ -6297,13 +6304,11 @@ each time the SQL thread starts.", ...@@ -6297,13 +6304,11 @@ each time the SQL thread starts.",
"Log some extra information to update log. Please note that this option " "Log some extra information to update log. Please note that this option "
"is deprecated; see --log-short-format option.", "is deprecated; see --log-short-format option.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef WITH_CSV_STORAGE_ENGINE
{"log-output", OPT_LOG_OUTPUT, {"log-output", OPT_LOG_OUTPUT,
"Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, " "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, "
"FILE or NONE.", "FILE or NONE.",
&log_output_str, &log_output_str, 0, &log_output_str, &log_output_str, 0,
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES, {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES,
"Log queries that are executed without benefit of any index to the slow log if it is open.", "Log queries that are executed without benefit of any index to the slow log if it is open.",
&opt_log_queries_not_using_indexes, &opt_log_queries_not_using_indexes, &opt_log_queries_not_using_indexes, &opt_log_queries_not_using_indexes,
...@@ -8631,7 +8636,6 @@ mysqld_get_one_option(int optid, ...@@ -8631,7 +8636,6 @@ mysqld_get_one_option(int optid,
WARN_DEPRECATED(NULL, "7.0", "--log_slow_queries", "'--slow_query_log'/'--log-slow-file'"); WARN_DEPRECATED(NULL, "7.0", "--log_slow_queries", "'--slow_query_log'/'--log-slow-file'");
opt_slow_log= 1; opt_slow_log= 1;
break; break;
#ifdef WITH_CSV_STORAGE_ENGINE
case OPT_LOG_OUTPUT: case OPT_LOG_OUTPUT:
{ {
if (!argument || !argument[0]) if (!argument || !argument[0])
...@@ -8649,7 +8653,6 @@ mysqld_get_one_option(int optid, ...@@ -8649,7 +8653,6 @@ mysqld_get_one_option(int optid,
} }
break; break;
} }
#endif
case OPT_EVENT_SCHEDULER: case OPT_EVENT_SCHEDULER:
#ifndef HAVE_EVENT_SCHEDULER #ifndef HAVE_EVENT_SCHEDULER
sql_perror("Event scheduler is not supported in embedded build."); sql_perror("Event scheduler is not supported in embedded build.");
......
...@@ -750,8 +750,11 @@ static int maria_create_trn_for_mysql(MARIA_HA *info) ...@@ -750,8 +750,11 @@ static int maria_create_trn_for_mysql(MARIA_HA *info)
thd->query_length()); thd->query_length());
} }
else else
{
DBUG_PRINT("info", ("lock_type: %d trnman_flags: %u", DBUG_PRINT("info", ("lock_type: %d trnman_flags: %u",
info->lock_type, trnman_get_flags(trn))); /* QQ */ info->lock_type, trnman_get_flags(trn)));
}
#endif #endif
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -2347,6 +2350,12 @@ int ha_maria::extra(enum ha_extra_function operation) ...@@ -2347,6 +2350,12 @@ int ha_maria::extra(enum ha_extra_function operation)
int ha_maria::reset(void) int ha_maria::reset(void)
{ {
if (file->trn)
{
TRN *trn= file->trn;
/* Next statement is a new statement. Ensure it's logged */
trnman_set_flags(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED);
}
return maria_reset(file); return maria_reset(file);
} }
......
...@@ -136,11 +136,13 @@ void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info) ...@@ -136,11 +136,13 @@ void maria_chk_init_for_check(HA_CHECK *param, MARIA_HA *info)
Set up transaction handler so that we can see all rows. When rows is read Set up transaction handler so that we can see all rows. When rows is read
we will check the found id against param->max_tried we will check the found id against param->max_tried
*/ */
if (param->max_trid == 0)
{
if (!ma_control_file_inited()) if (!ma_control_file_inited())
param->max_trid= 0; /* Give warning for first trid found */ param->max_trid= 0; /* Give warning for first trid found */
else else
param->max_trid= max_trid_in_system(); param->max_trid= max_trid_in_system();
}
maria_ignore_trids(info); maria_ignore_trids(info);
} }
...@@ -867,7 +869,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, ...@@ -867,7 +869,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
llstr(anc_page->pos, llbuff)); llstr(anc_page->pos, llbuff));
} }
if (anc_page->size > (uint) keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE) if (anc_page->size > share->max_index_block_size)
{ {
_ma_check_print_error(param, _ma_check_print_error(param,
"Page at %s has impossible (too big) pagelength", "Page at %s has impossible (too big) pagelength",
...@@ -2325,11 +2327,13 @@ static int initialize_variables_for_repair(HA_CHECK *param, ...@@ -2325,11 +2327,13 @@ static int initialize_variables_for_repair(HA_CHECK *param,
} }
/* Set up transaction handler so that we can see all rows */ /* Set up transaction handler so that we can see all rows */
if (param->max_trid == 0)
{
if (!ma_control_file_inited()) if (!ma_control_file_inited())
param->max_trid= 0; /* Give warning for first trid found */ param->max_trid= 0; /* Give warning for first trid found */
else else
param->max_trid= max_trid_in_system(); param->max_trid= max_trid_in_system();
}
maria_ignore_trids(info); maria_ignore_trids(info);
/* Don't write transid's during repair */ /* Don't write transid's during repair */
maria_versioning(info, 0); maria_versioning(info, 0);
...@@ -5609,7 +5613,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, ...@@ -5609,7 +5613,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param,
a_length+=t_length; a_length+=t_length;
_ma_store_page_used(share, anc_buff, a_length); _ma_store_page_used(share, anc_buff, a_length);
key_block->end_pos+=t_length; key_block->end_pos+=t_length;
if (a_length <= (uint) (keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE)) if (a_length <= share->max_index_block_size)
{ {
MARIA_KEY tmp_key2; MARIA_KEY tmp_key2;
tmp_key2.data= key_block->lastkey; tmp_key2.data= key_block->lastkey;
......
This diff is collapsed.
This diff is collapsed.
...@@ -64,17 +64,26 @@ extern my_bool write_hook_for_undo_key_delete(enum translog_record_type type, ...@@ -64,17 +64,26 @@ extern my_bool write_hook_for_undo_key_delete(enum translog_record_type type,
TRN *trn, MARIA_HA *tbl_info, TRN *trn, MARIA_HA *tbl_info,
LSN *lsn, void *hook_arg); LSN *lsn, void *hook_arg);
my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length); my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length,
enum en_key_debug debug_marker);
my_bool _ma_log_suffix(MARIA_PAGE *page, uint org_length, my_bool _ma_log_suffix(MARIA_PAGE *page, uint org_length,
uint new_length); uint new_length);
my_bool _ma_log_add(MARIA_PAGE *page, uint buff_length, uchar *key_pos, my_bool _ma_log_add(MARIA_PAGE *page, uint buff_length, uchar *key_pos,
uint changed_length, int move_length, uint changed_length, int move_length,
my_bool handle_overflow); my_bool handle_overflow);
my_bool _ma_log_delete(MARIA_PAGE *page, const uchar *key_pos, my_bool _ma_log_delete(MARIA_PAGE *page, const uchar *key_pos,
uint changed_length, uint move_length); uint changed_length, uint move_length,
uint append_length, enum en_key_debug debug_marker);
my_bool _ma_log_change(MARIA_PAGE *page, const uchar *key_pos, uint length, my_bool _ma_log_change(MARIA_PAGE *page, const uchar *key_pos, uint length,
enum en_key_debug debug_marker); enum en_key_debug debug_marker);
my_bool _ma_log_new(MARIA_PAGE *page, my_bool root_page); my_bool _ma_log_new(MARIA_PAGE *page, my_bool root_page);
#ifdef EXTRA_DEBUG_KEY_CHANGES
void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array,
uchar *log_pos, uint *changed_length,
uint *translog_parts);
#else
void _ma_log_key_changes(A,B,C,D,E)
#endif
uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn, uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn,
const uchar *header, uint length); const uchar *header, uint length);
......
...@@ -172,13 +172,24 @@ enum en_key_op ...@@ -172,13 +172,24 @@ enum en_key_op
enum en_key_debug enum en_key_debug
{ {
KEY_OP_DEBUG_RTREE_COMBINE, KEY_OP_DEBUG_RTREE_COMBINE, /* 0 */
KEY_OP_DEBUG_RTREE_SPLIT, KEY_OP_DEBUG_RTREE_SPLIT, /* 1 */
KEY_OP_DEBUG_RTREE_SET_KEY, KEY_OP_DEBUG_RTREE_SET_KEY, /* 2 */
KEY_OP_DEBUG_FATHER_CHANGED_1, KEY_OP_DEBUG_FATHER_CHANGED_1, /* 3 */
KEY_OP_DEBUG_FATHER_CHANGED_2, KEY_OP_DEBUG_FATHER_CHANGED_2, /* 4 */
KEY_OP_DEBUG_LOG_SPLIT, KEY_OP_DEBUG_LOG_SPLIT, /* 5 */
KEY_OP_DEBUG_LOG_ADD KEY_OP_DEBUG_LOG_ADD, /* 6 */
KEY_OP_DEBUG_LOG_PREFIX_1, /* 7 */
KEY_OP_DEBUG_LOG_PREFIX_2, /* 8 */
KEY_OP_DEBUG_LOG_PREFIX_3, /* 9 */
KEY_OP_DEBUG_LOG_PREFIX_4, /* 10 */
KEY_OP_DEBUG_LOG_PREFIX_5, /* 11 */
KEY_OP_DEBUG_LOG_DEL_CHANGE_1, /* 12 */
KEY_OP_DEBUG_LOG_DEL_CHANGE_2, /* 13 */
KEY_OP_DEBUG_LOG_DEL_CHANGE_3, /* 14 */
KEY_OP_DEBUG_LOG_DEL_CHANGE_RT, /* 15 */
KEY_OP_DEBUG_LOG_DEL_PREFIX, /* 16 */
KEY_OP_DEBUG_LOG_MIDDLE /* 17 */
}; };
......
...@@ -550,6 +550,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -550,6 +550,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
strmov(share->open_file_name.str, name); strmov(share->open_file_name.str, name);
share->block_size= share->base.block_size; /* Convenience */ share->block_size= share->base.block_size; /* Convenience */
share->max_index_block_size= share->block_size - KEYPAGE_CHECKSUM_SIZE;
{ {
HA_KEYSEG *pos=share->keyparts; HA_KEYSEG *pos=share->keyparts;
uint32 ftkey_nr= 1; uint32 ftkey_nr= 1;
......
...@@ -59,6 +59,7 @@ void _ma_page_setup(MARIA_PAGE *page, MARIA_HA *info, ...@@ -59,6 +59,7 @@ void _ma_page_setup(MARIA_PAGE *page, MARIA_HA *info,
page->buff= buff; page->buff= buff;
page->pos= pos; page->pos= pos;
page->size= _ma_get_page_used(share, buff); page->size= _ma_get_page_used(share, buff);
page->org_size= page->size;
page->flag= _ma_get_keypage_flag(share, buff); page->flag= _ma_get_keypage_flag(share, buff);
page->node= ((page->flag & KEYPAGE_FLAG_ISNOD) ? page->node= ((page->flag & KEYPAGE_FLAG_ISNOD) ?
share->base.key_reflength : 0); share->base.key_reflength : 0);
...@@ -68,7 +69,7 @@ void _ma_page_setup(MARIA_PAGE *page, MARIA_HA *info, ...@@ -68,7 +69,7 @@ void _ma_page_setup(MARIA_PAGE *page, MARIA_HA *info,
void page_cleanup(MARIA_SHARE *share, MARIA_PAGE *page) void page_cleanup(MARIA_SHARE *share, MARIA_PAGE *page)
{ {
uint length= page->size; uint length= page->size;
DBUG_ASSERT(length <= block_size - KEYPAGE_CHECKSUM_SIZE); DBUG_ASSERT(length <= share->max_index_block_size);
bzero(page->buff + length, share->block_size - length); bzero(page->buff + length, share->block_size - length);
} }
#endif #endif
...@@ -103,7 +104,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, ...@@ -103,7 +104,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info,
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
uint block_size= share->block_size; uint block_size= share->block_size;
DBUG_ENTER("_ma_fetch_keypage"); DBUG_ENTER("_ma_fetch_keypage");
DBUG_PRINT("enter",("pos: %ld", (long) pos)); DBUG_PRINT("enter",("page: %lu", (ulong) (pos / block_size)));
tmp= pagecache_read(share->pagecache, &share->kfile, tmp= pagecache_read(share->pagecache, &share->kfile,
(pgcache_page_no_t) (pos / block_size), level, buff, (pgcache_page_no_t) (pos / block_size), level, buff,
...@@ -142,6 +143,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, ...@@ -142,6 +143,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info,
page->buff= tmp; page->buff= tmp;
page->pos= pos; page->pos= pos;
page->size= _ma_get_page_used(share, tmp); page->size= _ma_get_page_used(share, tmp);
page->org_size= page->size; /* For debugging */
page->flag= _ma_get_keypage_flag(share, tmp); page->flag= _ma_get_keypage_flag(share, tmp);
page->node= ((page->flag & KEYPAGE_FLAG_ISNOD) ? page->node= ((page->flag & KEYPAGE_FLAG_ISNOD) ?
share->base.key_reflength : 0); share->base.key_reflength : 0);
...@@ -149,7 +151,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, ...@@ -149,7 +151,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info,
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
{ {
uint page_size= page->size; uint page_size= page->size;
if (page_size < 4 || page_size > block_size || if (page_size < 4 || page_size > share->max_index_block_size ||
_ma_get_keynr(share, tmp) != keyinfo->key_nr) _ma_get_keynr(share, tmp) != keyinfo->key_nr)
{ {
DBUG_PRINT("error",("page %lu had wrong page length: %u keynr: %u", DBUG_PRINT("error",("page %lu had wrong page length: %u keynr: %u",
...@@ -159,7 +161,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info, ...@@ -159,7 +161,7 @@ my_bool _ma_fetch_keypage(MARIA_PAGE *page, MARIA_HA *info,
info->last_keypage = HA_OFFSET_ERROR; info->last_keypage = HA_OFFSET_ERROR;
maria_print_error(share, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
my_errno= HA_ERR_CRASHED; my_errno= HA_ERR_CRASHED;
tmp= 0; DBUG_RETURN(1);
} }
} }
#endif #endif
...@@ -179,6 +181,13 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, ...@@ -179,6 +181,13 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock,
MARIA_PINNED_PAGE page_link; MARIA_PINNED_PAGE page_link;
DBUG_ENTER("_ma_write_keypage"); DBUG_ENTER("_ma_write_keypage");
/*
The following ensures that for transactional tables we have logged
all changes that changes the page size (as the logging code sets
page->org_size)
*/
DBUG_ASSERT(!share->now_transactional || page->size == page->org_size);
#ifdef EXTRA_DEBUG /* Safety check */ #ifdef EXTRA_DEBUG /* Safety check */
{ {
uint page_length, nod_flag; uint page_length, nod_flag;
...@@ -193,7 +202,7 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, ...@@ -193,7 +202,7 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock,
(page->pos & (maria_block_size-1))) (page->pos & (maria_block_size-1)))
{ {
DBUG_PRINT("error",("Trying to write inside key status region: " DBUG_PRINT("error",("Trying to write inside key status region: "
"key_start: %lu length: %lu page: %lu", "key_start: %lu length: %lu page_pos: %lu",
(long) share->base.keystart, (long) share->base.keystart,
(long) share->state.state.key_file_length, (long) share->state.state.key_file_length,
(long) page->pos)); (long) page->pos));
...@@ -201,7 +210,7 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock, ...@@ -201,7 +210,7 @@ my_bool _ma_write_keypage(MARIA_PAGE *page, enum pagecache_page_lock lock,
DBUG_ASSERT(0); DBUG_ASSERT(0);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_PRINT("page",("write page at: %lu",(long) page->pos)); DBUG_PRINT("page",("write page at: %lu",(ulong) (page->pos / block_size)));
DBUG_DUMP("buff", buff, page_length); DBUG_DUMP("buff", buff, page_length);
DBUG_ASSERT(page_length >= share->keypage_header + nod_flag + DBUG_ASSERT(page_length >= share->keypage_header + nod_flag +
page->keyinfo->minlength || maria_in_recovery); page->keyinfo->minlength || maria_in_recovery);
...@@ -274,7 +283,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read) ...@@ -274,7 +283,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read)
enum pagecache_page_lock lock_method; enum pagecache_page_lock lock_method;
enum pagecache_page_pin pin_method; enum pagecache_page_pin pin_method;
DBUG_ENTER("_ma_dispose"); DBUG_ENTER("_ma_dispose");
DBUG_PRINT("enter",("pos: %ld", (long) pos)); DBUG_PRINT("enter",("page: %lu", (ulong) (pos / block_size)));
DBUG_ASSERT(pos % block_size == 0); DBUG_ASSERT(pos % block_size == 0);
(void) _ma_lock_key_del(info, 0); (void) _ma_lock_key_del(info, 0);
...@@ -423,8 +432,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level, ...@@ -423,8 +432,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level,
share->key_del_current= mi_sizekorr(buff+share->keypage_header); share->key_del_current= mi_sizekorr(buff+share->keypage_header);
#ifndef DBUG_OFF #ifndef DBUG_OFF
key_del_current= share->key_del_current; key_del_current= share->key_del_current;
DBUG_ASSERT(key_del_current != share->state.key_del && DBUG_ASSERT((key_del_current != 0) &&
(key_del_current != 0) &&
((key_del_current == HA_OFFSET_ERROR) || ((key_del_current == HA_OFFSET_ERROR) ||
(key_del_current <= (key_del_current <=
(share->state.state.key_file_length - block_size)))); (share->state.state.key_file_length - block_size))));
...@@ -453,32 +461,48 @@ my_off_t _ma_new(register MARIA_HA *info, int level, ...@@ -453,32 +461,48 @@ my_off_t _ma_new(register MARIA_HA *info, int level,
Log compactation of a index page Log compactation of a index page
*/ */
static my_bool _ma_log_compact_keypage(MARIA_HA *info, my_off_t page, static my_bool _ma_log_compact_keypage(MARIA_PAGE *ma_page,
TrID min_read_from) TrID min_read_from)
{ {
LSN lsn; LSN lsn;
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + TRANSID_SIZE]; uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + 7 + TRANSID_SIZE];
uchar *log_pos;
LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1]; LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 1];
MARIA_HA *info= ma_page->info;
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
uint translog_parts, extra_length;
my_off_t page= ma_page->pos;
DBUG_ENTER("_ma_log_compact_keypage"); DBUG_ENTER("_ma_log_compact_keypage");
DBUG_PRINT("enter", ("page: %lu", (ulong) page)); DBUG_PRINT("enter", ("page: %lu", (ulong) (page / share->block_size)));
/* Store address of new root page */ /* Store address of new root page */
page/= share->block_size; page/= share->block_size;
page_store(log_data + FILEID_STORE_SIZE, page); page_store(log_data + FILEID_STORE_SIZE, page);
log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE]= KEY_OP_COMPACT_PAGE; log_pos= log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE;
transid_store(log_data + FILEID_STORE_SIZE + PAGE_STORE_SIZE +1,
min_read_from); log_pos[0]= KEY_OP_COMPACT_PAGE;
transid_store(log_pos + 1, min_read_from);
log_pos+= 1 + TRANSID_SIZE;
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data; log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= sizeof(log_data); log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos -
log_data);
translog_parts= 1;
extra_length= 0;
_ma_log_key_changes(ma_page,
log_array + TRANSLOG_INTERNAL_PARTS + translog_parts,
log_pos, &extra_length, &translog_parts);
/* Remember new page length for future log entires for same page */
ma_page->org_size= ma_page->size;
if (translog_write_record(&lsn, LOGREC_REDO_INDEX, if (translog_write_record(&lsn, LOGREC_REDO_INDEX,
info->trn, info, info->trn, info,
(translog_size_t) sizeof(log_data), log_array[TRANSLOG_INTERNAL_PARTS +
TRANSLOG_INTERNAL_PARTS + 1, log_array, 0].length + extra_length,
log_data, NULL)) TRANSLOG_INTERNAL_PARTS + translog_parts,
log_array, log_data, NULL))
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -526,7 +550,7 @@ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from) ...@@ -526,7 +550,7 @@ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from)
{ {
if (!(page= (*ma_page->keyinfo->skip_key)(&key, 0, 0, page))) if (!(page= (*ma_page->keyinfo->skip_key)(&key, 0, 0, page)))
{ {
DBUG_PRINT("error",("Couldn't find last key: page: 0x%lx", DBUG_PRINT("error",("Couldn't find last key: page_pos: 0x%lx",
(long) page)); (long) page));
maria_print_error(share, HA_ERR_CRASHED); maria_print_error(share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
...@@ -588,7 +612,7 @@ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from) ...@@ -588,7 +612,7 @@ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from)
if (share->now_transactional) if (share->now_transactional)
{ {
if (_ma_log_compact_keypage(info, ma_page->pos, min_read_from)) if (_ma_log_compact_keypage(ma_page, min_read_from))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -545,7 +545,7 @@ static int display_and_apply_record(const LOG_DESC *log_desc, ...@@ -545,7 +545,7 @@ static int display_and_apply_record(const LOG_DESC *log_desc,
if (log_desc->record_execute_in_redo_phase == NULL) if (log_desc->record_execute_in_redo_phase == NULL)
{ {
/* die on all not-yet-handled records :) */ /* die on all not-yet-handled records :) */
DBUG_ASSERT("one more hook" == "to write"); DBUG_ASSERT("one more hook to write" == 0);
return 1; return 1;
} }
if ((error= (*log_desc->record_execute_in_redo_phase)(rec))) if ((error= (*log_desc->record_execute_in_redo_phase)(rec)))
...@@ -1063,6 +1063,7 @@ prototype_redo_exec_hook(REDO_REPAIR_TABLE) ...@@ -1063,6 +1063,7 @@ prototype_redo_exec_hook(REDO_REPAIR_TABLE)
param.isam_file_name= name= info->s->open_file_name.str; param.isam_file_name= name= info->s->open_file_name.str;
param.testflag= uint8korr(rec->header + FILEID_STORE_SIZE); param.testflag= uint8korr(rec->header + FILEID_STORE_SIZE);
param.tmpdir= maria_tmpdir; param.tmpdir= maria_tmpdir;
param.max_trid= max_long_trid;
DBUG_ASSERT(maria_tmpdir); DBUG_ASSERT(maria_tmpdir);
info->s->state.key_map= uint8korr(rec->header + FILEID_STORE_SIZE + 8); info->s->state.key_map= uint8korr(rec->header + FILEID_STORE_SIZE + 8);
......
...@@ -91,7 +91,8 @@ int maria_rtree_delete_key(MARIA_PAGE *page, uchar *key, uint key_length) ...@@ -91,7 +91,8 @@ int maria_rtree_delete_key(MARIA_PAGE *page, uchar *key, uint key_length)
page->size-= key_length_with_nod_flag; page->size-= key_length_with_nod_flag;
page_store_size(share, page); page_store_size(share, page);
if (share->now_transactional && if (share->now_transactional &&
_ma_log_delete(page, key_start, 0, key_length_with_nod_flag)) _ma_log_delete(page, key_start, 0, key_length_with_nod_flag,
0, KEY_OP_DEBUG_LOG_DEL_CHANGE_RT))
return -1; return -1;
return 0; return 0;
} }
......
...@@ -308,7 +308,7 @@ static my_bool _ma_log_rt_split(MARIA_PAGE *page, ...@@ -308,7 +308,7 @@ static my_bool _ma_log_rt_split(MARIA_PAGE *page,
LSN lsn; LSN lsn;
uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + 2 + 1 + 2 + 2 + 7], uchar log_data[FILEID_STORE_SIZE + PAGE_STORE_SIZE + 1 + 2 + 1 + 2 + 2 + 7],
*log_pos; *log_pos;
LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 5]; LEX_CUSTRING log_array[TRANSLOG_INTERNAL_PARTS + 6];
uint translog_parts, extra_length= 0; uint translog_parts, extra_length= 0;
my_off_t page_pos; my_off_t page_pos;
DBUG_ENTER("_ma_log_rt_split"); DBUG_ENTER("_ma_log_rt_split");
...@@ -344,24 +344,11 @@ static my_bool _ma_log_rt_split(MARIA_PAGE *page, ...@@ -344,24 +344,11 @@ static my_bool _ma_log_rt_split(MARIA_PAGE *page,
translog_parts+= 2; translog_parts+= 2;
} }
#ifdef EXTRA_DEBUG_KEY_CHANGES _ma_log_key_changes(page,
{ log_array + TRANSLOG_INTERNAL_PARTS + translog_parts,
int page_length= page->size; log_pos, &extra_length, &translog_parts);
ha_checksum crc; /* Remember new page length for future log entires for same page */
uchar *check_start= log_pos; page->org_size= page->size;
crc= my_checksum(0, page->buff + LSN_STORE_SIZE,
page_length - LSN_STORE_SIZE);
log_pos[0]= KEY_OP_CHECK;
log_pos++;
int2store(log_pos, page_length);
log_pos+= 2;
int4store(log_pos, crc);
log_pos+= 4;
log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].str= check_start;
log_array[TRANSLOG_INTERNAL_PARTS + translog_parts].length= 7;
translog_parts++;
}
#endif
if (translog_write_record(&lsn, LOGREC_REDO_INDEX, if (translog_write_record(&lsn, LOGREC_REDO_INDEX,
info->trn, info, info->trn, info,
......
...@@ -68,8 +68,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record, ...@@ -68,8 +68,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record,
DBUG_ASSERT(info->last_key.data_length == MARIA_UNIQUE_HASH_LENGTH); DBUG_ASSERT(info->last_key.data_length == MARIA_UNIQUE_HASH_LENGTH);
if (_ma_search_next(info, &info->last_key, SEARCH_BIGGER, if (_ma_search_next(info, &info->last_key, SEARCH_BIGGER,
info->s->state.key_root[def->key]) || info->s->state.key_root[def->key]) ||
bcmp((char*) info->last_key.data, (char*) key_buff, bcmp(info->last_key.data, key_buff, MARIA_UNIQUE_HASH_LENGTH))
MARIA_UNIQUE_HASH_LENGTH))
{ {
info->page_changed= 1; /* Can't optimize read next */ info->page_changed= 1; /* Can't optimize read next */
info->cur_row.lastpos= lastpos; info->cur_row.lastpos= lastpos;
......
This diff is collapsed.
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#define SANITY_CHECKS 1 #define SANITY_CHECKS 1
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
#define EXTRA_DEBUG_KEY_CHANGES #define EXTRA_DEBUG_KEY_CHANGES
#define EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES
#endif #endif
#define MAX_NONMAPPED_INSERTS 1000 #define MAX_NONMAPPED_INSERTS 1000
...@@ -361,6 +362,7 @@ typedef struct st_maria_share ...@@ -361,6 +362,7 @@ typedef struct st_maria_share
uint in_trans; /* Number of references by trn */ uint in_trans; /* Number of references by trn */
uint w_locks, r_locks, tot_locks; /* Number of read/write locks */ uint w_locks, r_locks, tot_locks; /* Number of read/write locks */
uint block_size; /* block_size of keyfile & data file*/ uint block_size; /* block_size of keyfile & data file*/
uint max_index_block_size; /* block_size - end_of_page_info */
/* Fixed length part of a packed row in BLOCK_RECORD format */ /* Fixed length part of a packed row in BLOCK_RECORD format */
uint base_length; uint base_length;
myf write_flag; myf write_flag;
...@@ -833,6 +835,7 @@ typedef struct st_maria_page ...@@ -833,6 +835,7 @@ typedef struct st_maria_page
uchar *buff; /* Data for page */ uchar *buff; /* Data for page */
my_off_t pos; /* Disk address to page */ my_off_t pos; /* Disk address to page */
uint size; /* Size of data on page */ uint size; /* Size of data on page */
uint org_size; /* Size of page at read or after log */
uint node; /* 0 or share->base.key_reflength */ uint node; /* 0 or share->base.key_reflength */
uint flag; /* Page flag */ uint flag; /* Page flag */
uint link_offset; uint link_offset;
......
...@@ -363,6 +363,7 @@ TRN *trnman_new_trn(WT_THD *wt) ...@@ -363,6 +363,7 @@ TRN *trnman_new_trn(WT_THD *wt)
trn->used_tables= 0; trn->used_tables= 0;
trn->locked_tables= 0; trn->locked_tables= 0;
trn->flags= 0;
/* /*
only after the following function TRN is considered initialized, only after the following function TRN is considered initialized,
......
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