Commit 6ab5a8ac authored by Michael Widenius's avatar Michael Widenius

Fixed valgrind errors and compiler warnings discovered by buildbot

More DBUG_ASSERT() to discover errors earlier
More checking of BLOCK structures in Aria.
Fixed crashing bug in Aria when doing UPDATE of several records in same block when doing table scan.

storage/federatedx/ha_federatedx.cc:
  Added missing delete_dynamic(); This fixes the valgrind warnings about lost memory discovered by buildbot.
storage/maria/ma_blockrec.c:
  Added debugging helper function _ma_print_block_info() to print block structure.
  Changed arguments to _ma_print_directory() so it can be called by _ma_print_block_info()
  check_directory() now also checks that empty_space on block is calculated correctly.
  Added some local variables to get more information about what happend when things crash.
  Fixed crashing bug when doing UPDATE of several records in same block when doing table scan.
storage/maria/ma_key_recover.c:
  Simple optimization (don't call bmove_upp() if not needed); This could happen during page split.
storage/maria/ma_recovery.c:
  Fixed compiler warning
storage/maria/ma_test2.c:
  Run test without syncing to disk. (Not needed for this test)
storage/maria/ma_write.c:
  More comments.
  Added DBUG_ASSERT() to find wrong log entires, like the one reported at LP#616344, during log file creation.
storage/maria/unittest/ma_test_recovery.pl:
  Added extra -s to maria_chk to get it more silent.
  This fixes that ma_test_all.sh works again.
parent 909e4eb0
......@@ -1791,6 +1791,8 @@ int ha_federatedx::close(void)
/* free the result set */
reset();
delete_dynamic(&results);
/* Disconnect from mysql */
if (!thd || !(txn= get_txn(thd, true)))
{
......
This diff is collapsed.
......@@ -923,7 +923,7 @@ uint _ma_apply_redo_index(MARIA_HA *info,
if (length < 0)
bmove(buff + page_offset, buff + page_offset - length,
page_length - page_offset + length);
else
else if (page_length != page_offset)
bmove_upp(buff + page_length + length, buff + page_length,
page_length - page_offset);
page_length+= length;
......
......@@ -494,8 +494,10 @@ int maria_apply_log(LSN from_lsn, LSN end_lsn,
}
else if (!error && max_trid_in_control_file != max_long_trid)
{
/* Set max trid in log file so that one can run maria_chk on the tables */
max_trid_in_control_file= trnman_get_max_trid();
/*
maria_end() will set max trid in log file so that one can run
maria_chk on the tables
*/
maria_recovery_changed_data= 1;
}
......@@ -3186,7 +3188,7 @@ static LSN parse_checkpoint_record(LSN lsn)
page_id, rec_lsn, next_dirty_page_in_pool++))
return LSN_ERROR;
if (maria_recovery_verbose)
tprint(tracef, "%8u %8u %12lu %u,0x%lx\n", (uint) table_id,
tprint(tracef, "%8u %8u %12lu %lu,0x%lx\n", (uint) table_id,
(uint) is_index, (ulong) page_id, LSN_IN_PARTS(rec_lsn));
set_if_smaller(minimum_rec_lsn_of_dirty_pages, rec_lsn);
}
......
......@@ -83,6 +83,9 @@ int main(int argc, char *argv[])
if (! async_io)
my_disable_async_io=1;
/* If we sync or not have no affect on this test */
my_disable_sync= 1;
maria_data_root= (char *)".";
/* Maria requires that we always have a page cache */
if (maria_init() ||
......@@ -351,7 +354,10 @@ int main(int argc, char *argv[])
key3[atoi((char*) read_record+keyinfo[2].seg[0].start)]=0;
}
else
{
puts("Warning: Skipping delete test because no dupplicate keys");
break;
}
}
if (testflag == 3)
goto end;
......
......@@ -1973,6 +1973,21 @@ my_bool _ma_log_change(MARIA_PAGE *ma_page, const uchar *key_pos, uint length,
/**
@brief Write log entry for page splitting
@fn _ma_log_split()
@param
ma_page Page that is changed
org_length Original length of page
new_length New length of page
key_pos Where key is inserted on page (may be 0 if no key)
key_length Number of bytes changed at key_pos
move_length Number of bytes moved at key_pos to make room for key
prefix_or_suffix KEY_OP_NONE Ignored
KEY_OP_ADD_PREFIX Add data to start of page
KEY_OP_ADD_SUFFIX Add data to end of page
data What data was added
data_length Number of bytes added first or last
changed_length Number of bytes changed first or last.
@note
Write log entry for page that has got a key added to the page under
one and only one of the following senarios:
......@@ -1980,9 +1995,6 @@ my_bool _ma_log_change(MARIA_PAGE *ma_page, const uchar *key_pos, uint length,
- Data is added to end of page
- Data added at front of page
@param prefix_or_suffix KEY_OP_NONE Ignored
KEY_OP_ADD_PREFIX Add data to start of page
KEY_OP_ADD_SUFFIX Add data to end of page
*/
......@@ -2005,6 +2017,8 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page,
DBUG_PRINT("enter", ("page: %lu org_length: %u new_length: %u",
(ulong) ma_page->pos, org_length, new_length));
DBUG_ASSERT(changed_length >= data_length);
log_pos= log_data + FILEID_STORE_SIZE;
page= ma_page->pos / info->s->block_size;
page_store(log_pos, page);
......@@ -2027,6 +2041,7 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page,
log_pos+= 3;
translog_parts= 1;
extra_length= 0;
DBUG_ASSERT(data_length == 0);
}
else
{
......@@ -2046,10 +2061,13 @@ static my_bool _ma_log_split(MARIA_PAGE *ma_page,
log_pos[0]= KEY_OP_DEL_SUFFIX;
int2store(log_pos + 1, diff);
log_pos+= 3;
DBUG_ASSERT(data_length == 0); /* Page is shortened */
DBUG_ASSERT(offset <= org_length - diff);
}
else
{
DBUG_ASSERT(new_length == org_length + move_length + data_length);
DBUG_ASSERT(offset <= org_length);
}
log_pos[0]= KEY_OP_OFFSET;
......
......@@ -300,7 +300,7 @@ sub check_table_is_same
$com.= "| grep -v \"file length\" | grep -v \"LSNs:\" | grep -v \"UUID:\" > $tmp/maria_chk_message.txt 2>&1";
$res= `$com`;
print MY_LOG $res;
$res= `$maria_exe_path/maria_chk$suffix -s -e --read-only $table`;
$res= `$maria_exe_path/maria_chk$suffix -ss -e --read-only $table`;
print MY_LOG $res;
$checksum2= `$maria_exe_path/maria_chk$suffix -dss $table`;
if ("$checksum" ne "$checksum2")
......@@ -415,7 +415,7 @@ sub physical_cmp
# save original tables to restore them later
copy("$table.MAD", "$tmp/before_zerofill$table_no.MAD") || die();
copy("$table.MAI", "$tmp/before_zerofill$table_no.MAI") || die();
$com= "$maria_exe_path/maria_chk$suffix -s --zerofill-keep-lsn $table";
$com= "$maria_exe_path/maria_chk$suffix -ss --zerofill-keep-lsn $table";
$res= `$com`;
print MY_LOG $res;
$table_no= $table_no + 1;
......
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