mariadb/storage/maria/unittest/ma_test_all-t

563 lines
17 KiB
Text
Raw Normal View History

#!/usr/bin/perl -w
#
# Run various unit tests.
#
use Getopt::Long;
$|= 1;
$VER= "1.1";
$opt_version= 0;
$opt_help= 0;
$opt_verbose= 0;
$opt_maria_path= undef();
$opt_valgrind= "valgrind --alignment=8 --leak-check=yes";
$opt_suffix= "";
$opt_silent= "-s";
my $maria_path= $ENV{'maria_path'};
my $my_progname= $0;
$my_progname=~ s/.*[\/]//;
my $runtime_error= 0; # Return 1 if error(s) occur during run
my $NEW_TEST= 0; # Test group separator in an array of tests
run_tests();
####
#### Initialise variables, clean temporary files and run the tests
####
sub run_tests
{
my $nr_tests= 0;
my $flag_exit= 0;
if (!GetOptions("help", "version", "verbose", "maria-path=s",
"valgrind=s", "suffix=s", "silent=s"))
{
$flag_exit= 1;
}
if ($opt_version)
{
print "$my_progname version $VER\n";
exit(0);
}
if (defined($opt_maria_path))
{
$maria_path= $opt_maria_path;
}
if (!defined($maria_path) || !length($maria_path))
{
$maria_path= ".";
}
usage() if ($opt_help || $flag_exit);
#
# clean-up
#
unlink <*.TMD maria_log*>; # Delete temporary files
#
# IMPORTANT: If you modify this file, please read this:
#
# Count total number of tests. Make sure that the functions return
# number of unit tests correctly, e.g. calls to ok(). The last argument
# for each function is a flag counter and will return the number of
# unit tests in each. Please see comments on function ok() at the end.
#
# If you modify any functions or add any new ones, please make sure the
# unit tests are appropriately detected here. A wrong count will
# make the unit test fail during 'make test'. $nr_tests must be right.
#
$nr_tests+= run_check_tests(0, 0, 0, 0, 1) * 4; #
$nr_tests+= run_repair_tests(0, 0, 0, 0, 1) * 4; # called 4 times
$nr_tests+= run_pack_tests(0, 0, 0, 0, 1) * 4; #
$nr_tests+= run_tests_on_warnings_and_errors(0, 0, 0, 1);
$nr_tests+= run_ma_test_recovery(0, 1);
$nr_tests+= run_tests_on_clrs(0, 1);
#
# Run tests
#
if (!$opt_verbose)
{
print "1..$nr_tests\n";
}
else
{
print "Total tests: $nr_tests\n";
}
if ($opt_verbose)
{
print "Running tests with dynamic row format\n"
}
run_check_tests($opt_suffix, $opt_silent, "", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "", $opt_verbose, 0);
if ($opt_verbose)
{
print "\nRunning tests with static row format\n";
}
run_check_tests($opt_suffix, $opt_silent, "-S", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "-S", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "-S", $opt_verbose, 0);
if ($opt_verbose)
{
print "\nRunning tests with block row format\n";
}
run_check_tests($opt_suffix, $opt_silent, "-M", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "-M", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "-M", $opt_verbose, 0);
if ($opt_verbose)
{
print "\nRunning tests with block row format and transactions\n";
}
run_check_tests($opt_suffix, $opt_silent, "-M -T", $opt_verbose, 0);
run_repair_tests($opt_suffix, $opt_silent, "-M -T", $opt_verbose, 0);
run_pack_tests($opt_suffix, $opt_silent, "-M -T", $opt_verbose, 0);
run_tests_on_warnings_and_errors($opt_suffix, $opt_silent, $opt_verbose, 0);
run_ma_test_recovery($opt_verbose, 0);
run_tests_on_clrs($opt_verbose, 0);
exit($runtime_error);
}
####
#### regular tests
####
sub run_check_tests
{
my ($suffix, $silent, $row_type, $verbose, $count)= @_;
my ($i, $nr_tests);
my @ma_test1_opt= ( ["","-se"],
["-N","-se"],
["-P --checksum","-se"],
["-P -N","-se"],
["-B -N -R2","-sm"],
["-a -k 480 --unique","-sm"],
["-a -N -R1 ","-sm"],
["-p","-sm"],
["-p -N --unique","-sm"],
["-p -N --key_length=127 --checksum","-sm"],
["-p -N --key_length=128","-sm"],
["-p --key_length=480","-sm"],
["-a -B","-sm"],
["-a -B --key_length=64 --unique","-sm"],
["-a -B -k 480 --checksum","-sm"],
["-a -B -k 480 -N --unique --checksum","-sm"],
["-a -m","-sm"],
["-a -m -P --unique --checksum","-sm"],
["-a -m -P --key_length=480 --key_cache","-sm"],
["-m -p","-sm"],
["-w --unique","-sm"],
["-a -w --key_length=64 --checksum","-sm"],
["-a -w -N --key_length=480","-sm"],
["-a -w --key_length=480 --checksum","-sm"],
["-a -b -N","-sm"],
["-a -b --key_length=480","-sm"],
["-p -B --key_length=480","-sm"],
["--checksum --unique","-se"],
["--unique","-se"],
["--key_multiple -N -S","-sm"],
["--key_multiple -a -p --key_length=480","-sm"],
["--key_multiple -a -B --key_length=480","-sm"],
["--key_multiple -P -S","-sm"] );
my @ma_test2_opt= ( ["-L -K -W -P","-sm"],
["-L -K -W -P -A","-sm"],
Bugs fixed: - If not in autocommit mode, delete rows one by one so that we can roll back if necessary - bitmap->used_size was not correctly set, which caused bitmap pages to be overwritten - Fixed bug in bitmap handling when allocation tail pages - Ensure we reserve place for directory entry when calculation place for head and tail pages - Fixed wrong value in bitmap->size[0] - Fixed wrong assert in flush_log_for_bitmap - Fixed bug in _ma_bitmap_release_unused() where tail blocks could be wrongly reset - Mark new pages as changed (Required to get repair() to work) - Fixed problem with advancing log horizon pointer within one page bounds - Fixed DBUG_ASSERT() when enable_indexes failes for end_bulk_insert() - Fixed bug in logging of rows with more than one big blob - Fixed DBUG_ASSERTS() in pagecache to allow change of WRITE_LOCK to READ_LOCK in unlock() calls - Flush pagecache when we change from logging to not logging (if not, pagecache code breaks) - Ensure my_errno is set on return from write/delete/update - Fixed bug when using FIELD_SKIP_PRESPACE New features: - mysql_fix_privilege_tables now first uses binaries and scripts from source distribution, then in installed distribution - Fix that optimize works for Maria tables - maria_check --zerofill now also clear freed blob pages - maria_check -di now prints more information about record page utilization Optimizations: - Use pagecache_unlock_by_link() instead of pagecache_write() if possible. (Avoids a memory copy and a find_block) - Simplify code to abort when we found optimal bit pattern - Skip also full head page bit patterns when searching for tail - Increase default repair buffer to 128M for maria_chk and maria_read_log - Increase default sort buffer for maria_chk to 64M - Increase size of sortbuffer and pagecache for mysqld to 64M - VARCHAR/CHAR fields are stored in increasing length order for BLOCK_RECORD tables Better reporting: - Fixed test of error condition for flush (for better error code) - More error messages to mysqld if Maria recovery fails - Always print warning if rows are deleted in repair - Added global function _db_force_flush() that is usable when doing debugging in gdb - Added call to my_debug_put_break_here() in case of some errors (for debugging) - Remove used testfiles in unittest as these was written in different directories depending on from where the test was started This should fix the bugs found when importing a big table with many varchars and one/many blobs to Maria dbug/dbug.c: Added global function _db_force_flush() that is usable when doing debugging in gdbine extra/replace.c: Fixed memory leak include/my_dbug.h: Prototype for _db_force_flush() include/my_global.h: Added stdarg.h as my_sys.h now depends on it. include/my_sys.h: Make my_dbug_put_break_here() a NOP if not DBUG build Added my_printv_error() include/myisamchk.h: Added entry 'lost' to be able to count space that is lost forever mysql-test/r/maria.result: Updated results mysql-test/t/maria.test: Reset autocommit after test New test to check if delete_all_rows is used (verified with --debug) mysys/my_error.c: Added my_printv_error() scripts/mysql_fix_privilege_tables.sh: First use binaries and scripts from source distribution, then in installed distribution This ensures that a development branch doesn't pick up wrong scripts) sql/mysqld.cc: Fix that one can break maria recovery with ^C when debugging sql/sql_class.cc: Removed #ifdef that has no effect (The preceeding DBUG_ASSERT() ensures that the following code will not be exectued) storage/maria/ha_maria.cc: Increase size of sortbuffer and pagecache to 64M Fix that optimize works for Maria tables Fixed DBUG_ASSERT() when enable_indexes failes for end_bulk_insert() If not in autocommit mode, delete rows one by one so that we can roll back if necessary Fixed variable comments storage/maria/ma_bitmap.c: More ASSERTS to detect overwrite of bitmap pages bitmap->used_size was not correctly set, which caused bitmap pages to be overwritten Ensure we reserve place for directory entry when calculation place for head and tail pages bitmap->size[0] should not include space for directory entry Simplify code to abort when we found optimal bit pattern Skip also full head page bit patterns when searching for tail (should speed up some common cases) Fixed bug in allocate_tail() when block->used was not aligned on 6 bytes Fixed wrong assert in flush_log_for_bitmap Fixed bug in _ma_bitmap_release_unused() where tail blocks could be wrongly reset storage/maria/ma_blockrec.c: Ensure my_errno is set on return Fixed not optimal setting of row->min_length if we don't have variable length fields Use pagecache_unlock_by_link() instead of pagecache_write() if possible. (Avoids a memory copy and a find_block) Added DBUG_ASSERT() if we read or write wrong VARCHAR data Added DBUG_ASSERT() to find out if row sizes are calculated wrong Fixed bug in logging of rows with more than one big blob storage/maria/ma_check.c: Disable logging while normal repair is done to avoid logging of index changes Fixed bug that caused CHECKSUM part of key page to be used Fixed that deleted of wrong records also works for BLOCK_RECORD Clear unallocated pages: - BLOB pages are not automaticly cleared on delete, so we need to use the bitmap to know if page is used or not Better error reporting More information about record page utilization Change printing of file position to printing of pages to make output more readable Always print warning if rows are deleted storage/maria/ma_create.c: Calculate share.base_max_pack_length more accurately for BLOCK_RECORD pages (for future) Fixed that FIELD_SKIP_PRESPACE is recorded as FIELD_NORMAL; Fixed bug where fields could be used in wrong order Store FIELD_SKIP_ZERO fields before CHAR and VARCHAR fields (optimization) Store other fields in length order (to get better utilization of head block) storage/maria/ma_delete.c: Ensure my_errno is set on return storage/maria/ma_dynrec.c: Indentation fix storage/maria/ma_locking.c: Set changed if open_count is counted down. (To avoid getting error "client is using or hasn't closed the table properly" with transactional tables storage/maria/ma_loghandler.c: Fixed problem with advancing log horizon pointer within one page bounds (Patch from Sanja) Added more DBUG Indentation fixes storage/maria/ma_open.c: Removed wrong casts storage/maria/ma_page.c: Fixed usage of PAGECACHE_LOCK_WRITE_UNLOCK with _ma_new() Mark new pages as changed (Required to get repair() to work) storage/maria/ma_pagecache.c: Fixed test of error condition for flush Fixed problem when using PAGECACHE_LOCK_WRITE_TO_READ with unlock() Added call to my_debug_put_break_here() in case of errors (for debugging) storage/maria/ma_pagecrc.c: Ensure we get same crc for 32 and 64 bit systems by forcing argument to maria_page_crc to uint32 storage/maria/ma_recovery.c: Call my_printv_error() from eprint() to get critical errors to mysqld log Removed \n from error strings to eprint() to get nicer output in mysqld Added simple test in _ma_reenable_logging_for_table() to not do any work if not needed storage/maria/ma_update.c: Ensure my_errno is set on return storage/maria/ma_write.c: Ensure my_errno is set on return storage/maria/maria_chk.c: Use DEBUGGER_OFF if --debug is not use (to get slightly faster execution for debug binaries) Added option --skip-safemalloc Don't write exponents for rec/key storage/maria/maria_def.h: Increase default repair buffer to 128M for maria_chk and maria_read_log Increase default sort buffer for maria_chk to 64M storage/maria/unittest/Makefile.am: Don't update files automaticly from bitkeeper storage/maria/unittest/ma_pagecache_consist.c: Remove testfile at end storage/maria/unittest/ma_pagecache_single.c: Remove testfile at end storage/maria/unittest/ma_test_all-t: More tests Safer checking if test caused error
2008-01-07 18:54:41 +02:00
["-L -K -W -P -b32768", "-sm"],
["-L -K -W -P -M -T -c -b32768 -t4 -m300", "-sm"],
["-L -K -P -R3 -m50 -b1000000", "-sm"],
["-L -B","-sm"],
["-D -B -c","-sm"],
["-m10000 -e4096 -K","-sm"],
["-m10000 -e8192 -K","-sm"],
["-m10000 -e16384 -E16384 -K -L","-sm"],
Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type Added --zerofill (-z) option to maria_chk (Mostly code from Jani) Added now table states ZEROFILLED and MOVEABLE Set state.changed with new states when things changes include/maria.h: Added maria_zerofill include/myisamchk.h: Added option for zerofill Extend testflag to be 64 to allow for more flags mysql-test/r/create.result: Updated results after merge mysql-test/r/maria.result: Updated results after merge mysys/my_getopt.c: Removed not used variable sql/sql_show.cc: Fixed wrong page type storage/maria/ma_blockrec.c: Renamed compact_page() to ma_compact_block_page() and made it global Always zerofill half filled blob pages Set share.state.changed on REDO storage/maria/ma_blockrec.h: Added _ma_compact_block_page() storage/maria/ma_check.c: Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type This gives the following benefits: - Table is smaller if compressed - All LSN are removed for transactinal tables and this makes them movable between systems Dont set table states of we are using --quick Changed log entry for repair to use 8 bytes for flag storage/maria/ma_delete.c: Simplify code Update state.changed storage/maria/ma_key_recover.c: Update state.changed storage/maria/ma_locking.c: Set uuid for file on first change if it's not set (table was cleared with zerofill) storage/maria/ma_loghandler.c: Updated log entry for REDO_REPAIR_TABLE storage/maria/ma_recovery.c: Updated log entry for REDO_REPAIR_TABLE (flag is now 8 bytes) Set new bits in state.changed storage/maria/ma_test_all.sh: Nicer output storage/maria/ma_test_recovery.expected: Updated results (now states flags are visible) storage/maria/ma_update.c: Update state.changed storage/maria/ma_write.c: Simplify code Set state.changed storage/maria/maria_chk.c: Added option --zerofill Added printing of states for MOVABLE and ZEROFILLED MYD -> MAD MYI -> MAI storage/maria/maria_def.h: Added states STATE_NOT_MOVABLE and STATE_NOT_ZEROFILLED Added prototype for new functions storage/maria/unittest/ma_test_all-t: More tests, including tests for zerofill Removed some not needed 'print' statements storage/maria/unittest/ma_test_loghandler_multithread-t.c: Smaller buffer to not trash devlopment machines totally
2007-12-31 11:55:46 +02:00
["-L -K -W -P -b32768", "-se"],
["-c -b65000","-se"] );
if ($count)
{
$nr_tests= 2; # Number of tests outside loops
for ($i= 0; defined($ma_test1_opt[$i]); $i++) { $nr_tests+=2; }
for ($i= 0; defined($ma_test2_opt[$i]); $i++) { $nr_tests+=2; }
return $nr_tests;
}
for ($i= 0; defined($ma_test1_opt[$i]); $i++)
{
unlink <maria_log_control maria_log.*>;
ok("$maria_path/ma_test1$suffix $silent $ma_test1_opt[$i][0] $row_type",
$verbose, $i + 1);
ok("$maria_path/maria_chk$suffix $ma_test1_opt[$i][1] test1",
$verbose, $i + 1);
}
#
# These tests are outside the loops. Make sure to include them in
# nr_tests manually
#
ok("$maria_path/maria_pack$suffix --force -s test1", $verbose, 0);
ok("$maria_path/maria_chk$suffix -ess test1", $verbose, 0);
for ($i= 0; defined($ma_test2_opt[$i]); $i++)
{
unlink <maria_log_control maria_log.*>;
ok("$maria_path/ma_test2$suffix $silent $ma_test2_opt[$i][0] $row_type",
$verbose, $i + 1);
ok("$maria_path/maria_chk$suffix $ma_test2_opt[$i][1] test2",
$verbose, $i + 1);
}
unlink <maria_log_control maria_log.*>;
return 0;
}
####
#### repair tests
####
sub run_repair_tests()
{
my ($suffix, $silent, $row_type, $verbose, $count)= @_;
my ($i);
my @t= ($NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum $row_type",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix --silent -re --transaction-log test1",
"$maria_path/maria_chk$suffix -rs test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -rqs test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -rs --correct-checksum test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -rqs --correct-checksum test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -ros --correct-checksum test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -rqos --correct-checksum test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -sz test1",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/ma_test2$suffix $silent -c -d1 $row_type",
"$maria_path/maria_chk$suffix -s --parallel-recover test2",
"$maria_path/maria_chk$suffix -se test2",
"$maria_path/maria_chk$suffix -s --parallel-recover --quick test2",
"$maria_path/maria_chk$suffix -se test2",
"$maria_path/ma_test2$suffix $silent -c $row_type",
"$maria_path/maria_chk$suffix -se test2",
"$maria_path/maria_chk$suffix -sr test2",
"$maria_path/maria_chk$suffix -se test2",
"$maria_path/ma_test2$suffix $silent -c -t4 -b32768 $row_type",
"$maria_path/maria_chk$suffix -s --zerofill test1",
"$maria_path/maria_chk$suffix -se test1"
);
return &count_tests(\@t) if ($count);
&run_test_bunch(\@t, $verbose, 0);
return 0;
}
####
#### pack tests
####
sub run_pack_tests()
{
my ($suffix, $silent, $row_type, $verbose, $count)= @_;
my ($i);
my @t= ($NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum $row_type",
"$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -ess test1",
"$maria_path/maria_chk$suffix -rqs test1",
"$maria_path/maria_chk$suffix -es test1",
"$maria_path/maria_chk$suffix -rs test1",
"$maria_path/maria_chk$suffix -es test1",
"$maria_path/maria_chk$suffix -rus test1",
"$maria_path/maria_chk$suffix -es test1",
$NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum $row_type",
"$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -rus --safe-recover test1",
"$maria_path/maria_chk$suffix -es test1",
$NEW_TEST,
"$maria_path/ma_test1$suffix $silent --checksum -S $row_type",
"$maria_path/maria_chk$suffix -se test1",
"$maria_path/maria_chk$suffix -ros test1",
"$maria_path/maria_chk$suffix -rqs test1",
"$maria_path/maria_chk$suffix -se test1",
$NEW_TEST,
"$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -rqs test1",
"$maria_path/maria_chk$suffix -es test1",
"$maria_path/maria_chk$suffix -rus test1",
"$maria_path/maria_chk$suffix -es test1",
$NEW_TEST,
"$maria_path/ma_test2$suffix $silent -c -d1 $row_type",
"$maria_path/maria_chk$suffix -s --parallel-recover test2",
"$maria_path/maria_chk$suffix -se test2",
"$maria_path/maria_chk$suffix -s --unpack --parallel-recover test2",
"$maria_path/maria_chk$suffix -se test2",
"$maria_path/maria_pack$suffix --force -s test1",
"$maria_path/maria_chk$suffix -s --unpack --parallel-recover test2",
"$maria_path/maria_chk$suffix -se test2"
);
return &count_tests(\@t) if ($count);
&run_test_bunch(\@t, $verbose, 0);
return 0;
}
####
#### Tests that gives warnings or errors
####
sub run_tests_on_warnings_and_errors
{
my ($suffix, $silent, $verbose, $count)= @_;
my ($com);
return 9 if ($count); # Number of tests in this function, e.g. calls to ok()
ok("$maria_path/ma_test2$suffix $silent -L -K -W -P -S -R1 -m500",
$verbose, 0);
ok("$maria_path/maria_chk$suffix -sm test2", $verbose, 0);
Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type Added --zerofill (-z) option to maria_chk (Mostly code from Jani) Added now table states ZEROFILLED and MOVEABLE Set state.changed with new states when things changes include/maria.h: Added maria_zerofill include/myisamchk.h: Added option for zerofill Extend testflag to be 64 to allow for more flags mysql-test/r/create.result: Updated results after merge mysql-test/r/maria.result: Updated results after merge mysys/my_getopt.c: Removed not used variable sql/sql_show.cc: Fixed wrong page type storage/maria/ma_blockrec.c: Renamed compact_page() to ma_compact_block_page() and made it global Always zerofill half filled blob pages Set share.state.changed on REDO storage/maria/ma_blockrec.h: Added _ma_compact_block_page() storage/maria/ma_check.c: Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type This gives the following benefits: - Table is smaller if compressed - All LSN are removed for transactinal tables and this makes them movable between systems Dont set table states of we are using --quick Changed log entry for repair to use 8 bytes for flag storage/maria/ma_delete.c: Simplify code Update state.changed storage/maria/ma_key_recover.c: Update state.changed storage/maria/ma_locking.c: Set uuid for file on first change if it's not set (table was cleared with zerofill) storage/maria/ma_loghandler.c: Updated log entry for REDO_REPAIR_TABLE storage/maria/ma_recovery.c: Updated log entry for REDO_REPAIR_TABLE (flag is now 8 bytes) Set new bits in state.changed storage/maria/ma_test_all.sh: Nicer output storage/maria/ma_test_recovery.expected: Updated results (now states flags are visible) storage/maria/ma_update.c: Update state.changed storage/maria/ma_write.c: Simplify code Set state.changed storage/maria/maria_chk.c: Added option --zerofill Added printing of states for MOVABLE and ZEROFILLED MYD -> MAD MYI -> MAI storage/maria/maria_def.h: Added states STATE_NOT_MOVABLE and STATE_NOT_ZEROFILLED Added prototype for new functions storage/maria/unittest/ma_test_all-t: More tests, including tests for zerofill Removed some not needed 'print' statements storage/maria/unittest/ma_test_loghandler_multithread-t.c: Smaller buffer to not trash devlopment machines totally
2007-12-31 11:55:46 +02:00
# ma_test2$suffix $silent -L -K -R1 -m2000 ; Should give error 135\n
# In the following a failure is a success and success is a failure
$com= "$maria_path/ma_test2$suffix $silent -L -K -R1 -m2000 ";
Bugs fixed: - If not in autocommit mode, delete rows one by one so that we can roll back if necessary - bitmap->used_size was not correctly set, which caused bitmap pages to be overwritten - Fixed bug in bitmap handling when allocation tail pages - Ensure we reserve place for directory entry when calculation place for head and tail pages - Fixed wrong value in bitmap->size[0] - Fixed wrong assert in flush_log_for_bitmap - Fixed bug in _ma_bitmap_release_unused() where tail blocks could be wrongly reset - Mark new pages as changed (Required to get repair() to work) - Fixed problem with advancing log horizon pointer within one page bounds - Fixed DBUG_ASSERT() when enable_indexes failes for end_bulk_insert() - Fixed bug in logging of rows with more than one big blob - Fixed DBUG_ASSERTS() in pagecache to allow change of WRITE_LOCK to READ_LOCK in unlock() calls - Flush pagecache when we change from logging to not logging (if not, pagecache code breaks) - Ensure my_errno is set on return from write/delete/update - Fixed bug when using FIELD_SKIP_PRESPACE New features: - mysql_fix_privilege_tables now first uses binaries and scripts from source distribution, then in installed distribution - Fix that optimize works for Maria tables - maria_check --zerofill now also clear freed blob pages - maria_check -di now prints more information about record page utilization Optimizations: - Use pagecache_unlock_by_link() instead of pagecache_write() if possible. (Avoids a memory copy and a find_block) - Simplify code to abort when we found optimal bit pattern - Skip also full head page bit patterns when searching for tail - Increase default repair buffer to 128M for maria_chk and maria_read_log - Increase default sort buffer for maria_chk to 64M - Increase size of sortbuffer and pagecache for mysqld to 64M - VARCHAR/CHAR fields are stored in increasing length order for BLOCK_RECORD tables Better reporting: - Fixed test of error condition for flush (for better error code) - More error messages to mysqld if Maria recovery fails - Always print warning if rows are deleted in repair - Added global function _db_force_flush() that is usable when doing debugging in gdb - Added call to my_debug_put_break_here() in case of some errors (for debugging) - Remove used testfiles in unittest as these was written in different directories depending on from where the test was started This should fix the bugs found when importing a big table with many varchars and one/many blobs to Maria dbug/dbug.c: Added global function _db_force_flush() that is usable when doing debugging in gdbine extra/replace.c: Fixed memory leak include/my_dbug.h: Prototype for _db_force_flush() include/my_global.h: Added stdarg.h as my_sys.h now depends on it. include/my_sys.h: Make my_dbug_put_break_here() a NOP if not DBUG build Added my_printv_error() include/myisamchk.h: Added entry 'lost' to be able to count space that is lost forever mysql-test/r/maria.result: Updated results mysql-test/t/maria.test: Reset autocommit after test New test to check if delete_all_rows is used (verified with --debug) mysys/my_error.c: Added my_printv_error() scripts/mysql_fix_privilege_tables.sh: First use binaries and scripts from source distribution, then in installed distribution This ensures that a development branch doesn't pick up wrong scripts) sql/mysqld.cc: Fix that one can break maria recovery with ^C when debugging sql/sql_class.cc: Removed #ifdef that has no effect (The preceeding DBUG_ASSERT() ensures that the following code will not be exectued) storage/maria/ha_maria.cc: Increase size of sortbuffer and pagecache to 64M Fix that optimize works for Maria tables Fixed DBUG_ASSERT() when enable_indexes failes for end_bulk_insert() If not in autocommit mode, delete rows one by one so that we can roll back if necessary Fixed variable comments storage/maria/ma_bitmap.c: More ASSERTS to detect overwrite of bitmap pages bitmap->used_size was not correctly set, which caused bitmap pages to be overwritten Ensure we reserve place for directory entry when calculation place for head and tail pages bitmap->size[0] should not include space for directory entry Simplify code to abort when we found optimal bit pattern Skip also full head page bit patterns when searching for tail (should speed up some common cases) Fixed bug in allocate_tail() when block->used was not aligned on 6 bytes Fixed wrong assert in flush_log_for_bitmap Fixed bug in _ma_bitmap_release_unused() where tail blocks could be wrongly reset storage/maria/ma_blockrec.c: Ensure my_errno is set on return Fixed not optimal setting of row->min_length if we don't have variable length fields Use pagecache_unlock_by_link() instead of pagecache_write() if possible. (Avoids a memory copy and a find_block) Added DBUG_ASSERT() if we read or write wrong VARCHAR data Added DBUG_ASSERT() to find out if row sizes are calculated wrong Fixed bug in logging of rows with more than one big blob storage/maria/ma_check.c: Disable logging while normal repair is done to avoid logging of index changes Fixed bug that caused CHECKSUM part of key page to be used Fixed that deleted of wrong records also works for BLOCK_RECORD Clear unallocated pages: - BLOB pages are not automaticly cleared on delete, so we need to use the bitmap to know if page is used or not Better error reporting More information about record page utilization Change printing of file position to printing of pages to make output more readable Always print warning if rows are deleted storage/maria/ma_create.c: Calculate share.base_max_pack_length more accurately for BLOCK_RECORD pages (for future) Fixed that FIELD_SKIP_PRESPACE is recorded as FIELD_NORMAL; Fixed bug where fields could be used in wrong order Store FIELD_SKIP_ZERO fields before CHAR and VARCHAR fields (optimization) Store other fields in length order (to get better utilization of head block) storage/maria/ma_delete.c: Ensure my_errno is set on return storage/maria/ma_dynrec.c: Indentation fix storage/maria/ma_locking.c: Set changed if open_count is counted down. (To avoid getting error "client is using or hasn't closed the table properly" with transactional tables storage/maria/ma_loghandler.c: Fixed problem with advancing log horizon pointer within one page bounds (Patch from Sanja) Added more DBUG Indentation fixes storage/maria/ma_open.c: Removed wrong casts storage/maria/ma_page.c: Fixed usage of PAGECACHE_LOCK_WRITE_UNLOCK with _ma_new() Mark new pages as changed (Required to get repair() to work) storage/maria/ma_pagecache.c: Fixed test of error condition for flush Fixed problem when using PAGECACHE_LOCK_WRITE_TO_READ with unlock() Added call to my_debug_put_break_here() in case of errors (for debugging) storage/maria/ma_pagecrc.c: Ensure we get same crc for 32 and 64 bit systems by forcing argument to maria_page_crc to uint32 storage/maria/ma_recovery.c: Call my_printv_error() from eprint() to get critical errors to mysqld log Removed \n from error strings to eprint() to get nicer output in mysqld Added simple test in _ma_reenable_logging_for_table() to not do any work if not needed storage/maria/ma_update.c: Ensure my_errno is set on return storage/maria/ma_write.c: Ensure my_errno is set on return storage/maria/maria_chk.c: Use DEBUGGER_OFF if --debug is not use (to get slightly faster execution for debug binaries) Added option --skip-safemalloc Don't write exponents for rec/key storage/maria/maria_def.h: Increase default repair buffer to 128M for maria_chk and maria_read_log Increase default sort buffer for maria_chk to 64M storage/maria/unittest/Makefile.am: Don't update files automaticly from bitkeeper storage/maria/unittest/ma_pagecache_consist.c: Remove testfile at end storage/maria/unittest/ma_pagecache_single.c: Remove testfile at end storage/maria/unittest/ma_test_all-t: More tests Safer checking if test caused error
2008-01-07 18:54:41 +02:00
$com.= ">ma_test2_message.txt 2>&1";
ok($com, $verbose, 0, 1);
ok("cat ma_test2_message.txt", $verbose, 0);
ok("grep \"Error: 135\" ma_test2_message.txt > /dev/null", $verbose, 0);
Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type Added --zerofill (-z) option to maria_chk (Mostly code from Jani) Added now table states ZEROFILLED and MOVEABLE Set state.changed with new states when things changes include/maria.h: Added maria_zerofill include/myisamchk.h: Added option for zerofill Extend testflag to be 64 to allow for more flags mysql-test/r/create.result: Updated results after merge mysql-test/r/maria.result: Updated results after merge mysys/my_getopt.c: Removed not used variable sql/sql_show.cc: Fixed wrong page type storage/maria/ma_blockrec.c: Renamed compact_page() to ma_compact_block_page() and made it global Always zerofill half filled blob pages Set share.state.changed on REDO storage/maria/ma_blockrec.h: Added _ma_compact_block_page() storage/maria/ma_check.c: Added maria_zerofill() This is used to bzero all not used parts of the index pages and compact and bzero the not used parts of the data pages of block-record type This gives the following benefits: - Table is smaller if compressed - All LSN are removed for transactinal tables and this makes them movable between systems Dont set table states of we are using --quick Changed log entry for repair to use 8 bytes for flag storage/maria/ma_delete.c: Simplify code Update state.changed storage/maria/ma_key_recover.c: Update state.changed storage/maria/ma_locking.c: Set uuid for file on first change if it's not set (table was cleared with zerofill) storage/maria/ma_loghandler.c: Updated log entry for REDO_REPAIR_TABLE storage/maria/ma_recovery.c: Updated log entry for REDO_REPAIR_TABLE (flag is now 8 bytes) Set new bits in state.changed storage/maria/ma_test_all.sh: Nicer output storage/maria/ma_test_recovery.expected: Updated results (now states flags are visible) storage/maria/ma_update.c: Update state.changed storage/maria/ma_write.c: Simplify code Set state.changed storage/maria/maria_chk.c: Added option --zerofill Added printing of states for MOVABLE and ZEROFILLED MYD -> MAD MYI -> MAI storage/maria/maria_def.h: Added states STATE_NOT_MOVABLE and STATE_NOT_ZEROFILLED Added prototype for new functions storage/maria/unittest/ma_test_all-t: More tests, including tests for zerofill Removed some not needed 'print' statements storage/maria/unittest/ma_test_loghandler_multithread-t.c: Smaller buffer to not trash devlopment machines totally
2007-12-31 11:55:46 +02:00
# maria_path/maria_chk$suffix -sm test2 will warn that
# Datafile is almost full
ok("$maria_path/maria_chk$suffix -sm test2 >ma_test2_message.txt 2>&1",
$verbose, 0);
ok("cat ma_test2_message.txt", $verbose, 0);
ok("grep \"warning: Datafile is almost full\" ma_test2_message.txt>/dev/null",
$verbose, 0);
unlink <ma_test2_message.txt>;
ok("$maria_path/maria_chk$suffix -ssm test2", $verbose, 0);
return 0;
}
####
#### Test that removing tables and applying the log leads to identical tables
####
sub run_ma_test_recovery
{
my ($verbose, $count)= @_;
return 1 if ($count); # Number of tests in this function
ok("$maria_path/ma_test_recovery", $verbose, 0);
return 0;
}
####
#### Tests on CLR's
####
sub run_tests_on_clrs
{
my ($verbose, $count)= @_;
my ($i);
my @t= ($NEW_TEST,
"$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -A1",
"cp maria_log_control tmp",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -s -e test2",
"cp tmp/maria_log_control .",
"rm test2.MA?",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -s -e test2",
"rm test2.MA?",
$NEW_TEST,
"$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b -t2 -A1",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -s -e test2",
"rm test2.MA?",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -e -s test2",
"rm test2.MA?",
$NEW_TEST,
"$maria_path/ma_test2 -s -L -K -W -P -M -T -c -b32768 -t4 -A1",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -es test2",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -es test2",
"rm test2.MA?",
"$maria_path/maria_read_log -a -s",
"$maria_path/maria_chk -es test2",
"rm test2.MA?"
);
return &count_tests(\@t) if ($count);
&run_test_bunch(\@t, $verbose, 1);
return 0;
}
#
# Print "ok" on success and "not ok" on error
#
# Note: Every time this function is called it will be counted
# as a unit test.
#
# Args: $com: The actual command run. Will be printed on a failure
# $verbose: Be more verbose.
# $iteration: Number of iterations in a loop when the error
# occurred. If not in loop, this should be blank
# (e.g. send zero).
# $expected_error: Optional; put here expected error code. Test
# will pass with this result only.
#
# Return value: Will return 1 on success and 0 on an error
#
sub ok
{
my ($com, $verbose, $iteration, $expected_error)= @_;
my ($msg, $output, $err, $len);
$msg= "";
$expected_error= 0 if (!defined($expected_error));
if ($verbose)
{
print "$com ";
}
$output= `$com 2>&1`;
$len= length($com);
if ($verbose)
{
print " " x (65 - $len);
print " ";
}
$err= $?;
Bugs fixed: - If not in autocommit mode, delete rows one by one so that we can roll back if necessary - bitmap->used_size was not correctly set, which caused bitmap pages to be overwritten - Fixed bug in bitmap handling when allocation tail pages - Ensure we reserve place for directory entry when calculation place for head and tail pages - Fixed wrong value in bitmap->size[0] - Fixed wrong assert in flush_log_for_bitmap - Fixed bug in _ma_bitmap_release_unused() where tail blocks could be wrongly reset - Mark new pages as changed (Required to get repair() to work) - Fixed problem with advancing log horizon pointer within one page bounds - Fixed DBUG_ASSERT() when enable_indexes failes for end_bulk_insert() - Fixed bug in logging of rows with more than one big blob - Fixed DBUG_ASSERTS() in pagecache to allow change of WRITE_LOCK to READ_LOCK in unlock() calls - Flush pagecache when we change from logging to not logging (if not, pagecache code breaks) - Ensure my_errno is set on return from write/delete/update - Fixed bug when using FIELD_SKIP_PRESPACE New features: - mysql_fix_privilege_tables now first uses binaries and scripts from source distribution, then in installed distribution - Fix that optimize works for Maria tables - maria_check --zerofill now also clear freed blob pages - maria_check -di now prints more information about record page utilization Optimizations: - Use pagecache_unlock_by_link() instead of pagecache_write() if possible. (Avoids a memory copy and a find_block) - Simplify code to abort when we found optimal bit pattern - Skip also full head page bit patterns when searching for tail - Increase default repair buffer to 128M for maria_chk and maria_read_log - Increase default sort buffer for maria_chk to 64M - Increase size of sortbuffer and pagecache for mysqld to 64M - VARCHAR/CHAR fields are stored in increasing length order for BLOCK_RECORD tables Better reporting: - Fixed test of error condition for flush (for better error code) - More error messages to mysqld if Maria recovery fails - Always print warning if rows are deleted in repair - Added global function _db_force_flush() that is usable when doing debugging in gdb - Added call to my_debug_put_break_here() in case of some errors (for debugging) - Remove used testfiles in unittest as these was written in different directories depending on from where the test was started This should fix the bugs found when importing a big table with many varchars and one/many blobs to Maria dbug/dbug.c: Added global function _db_force_flush() that is usable when doing debugging in gdbine extra/replace.c: Fixed memory leak include/my_dbug.h: Prototype for _db_force_flush() include/my_global.h: Added stdarg.h as my_sys.h now depends on it. include/my_sys.h: Make my_dbug_put_break_here() a NOP if not DBUG build Added my_printv_error() include/myisamchk.h: Added entry 'lost' to be able to count space that is lost forever mysql-test/r/maria.result: Updated results mysql-test/t/maria.test: Reset autocommit after test New test to check if delete_all_rows is used (verified with --debug) mysys/my_error.c: Added my_printv_error() scripts/mysql_fix_privilege_tables.sh: First use binaries and scripts from source distribution, then in installed distribution This ensures that a development branch doesn't pick up wrong scripts) sql/mysqld.cc: Fix that one can break maria recovery with ^C when debugging sql/sql_class.cc: Removed #ifdef that has no effect (The preceeding DBUG_ASSERT() ensures that the following code will not be exectued) storage/maria/ha_maria.cc: Increase size of sortbuffer and pagecache to 64M Fix that optimize works for Maria tables Fixed DBUG_ASSERT() when enable_indexes failes for end_bulk_insert() If not in autocommit mode, delete rows one by one so that we can roll back if necessary Fixed variable comments storage/maria/ma_bitmap.c: More ASSERTS to detect overwrite of bitmap pages bitmap->used_size was not correctly set, which caused bitmap pages to be overwritten Ensure we reserve place for directory entry when calculation place for head and tail pages bitmap->size[0] should not include space for directory entry Simplify code to abort when we found optimal bit pattern Skip also full head page bit patterns when searching for tail (should speed up some common cases) Fixed bug in allocate_tail() when block->used was not aligned on 6 bytes Fixed wrong assert in flush_log_for_bitmap Fixed bug in _ma_bitmap_release_unused() where tail blocks could be wrongly reset storage/maria/ma_blockrec.c: Ensure my_errno is set on return Fixed not optimal setting of row->min_length if we don't have variable length fields Use pagecache_unlock_by_link() instead of pagecache_write() if possible. (Avoids a memory copy and a find_block) Added DBUG_ASSERT() if we read or write wrong VARCHAR data Added DBUG_ASSERT() to find out if row sizes are calculated wrong Fixed bug in logging of rows with more than one big blob storage/maria/ma_check.c: Disable logging while normal repair is done to avoid logging of index changes Fixed bug that caused CHECKSUM part of key page to be used Fixed that deleted of wrong records also works for BLOCK_RECORD Clear unallocated pages: - BLOB pages are not automaticly cleared on delete, so we need to use the bitmap to know if page is used or not Better error reporting More information about record page utilization Change printing of file position to printing of pages to make output more readable Always print warning if rows are deleted storage/maria/ma_create.c: Calculate share.base_max_pack_length more accurately for BLOCK_RECORD pages (for future) Fixed that FIELD_SKIP_PRESPACE is recorded as FIELD_NORMAL; Fixed bug where fields could be used in wrong order Store FIELD_SKIP_ZERO fields before CHAR and VARCHAR fields (optimization) Store other fields in length order (to get better utilization of head block) storage/maria/ma_delete.c: Ensure my_errno is set on return storage/maria/ma_dynrec.c: Indentation fix storage/maria/ma_locking.c: Set changed if open_count is counted down. (To avoid getting error "client is using or hasn't closed the table properly" with transactional tables storage/maria/ma_loghandler.c: Fixed problem with advancing log horizon pointer within one page bounds (Patch from Sanja) Added more DBUG Indentation fixes storage/maria/ma_open.c: Removed wrong casts storage/maria/ma_page.c: Fixed usage of PAGECACHE_LOCK_WRITE_UNLOCK with _ma_new() Mark new pages as changed (Required to get repair() to work) storage/maria/ma_pagecache.c: Fixed test of error condition for flush Fixed problem when using PAGECACHE_LOCK_WRITE_TO_READ with unlock() Added call to my_debug_put_break_here() in case of errors (for debugging) storage/maria/ma_pagecrc.c: Ensure we get same crc for 32 and 64 bit systems by forcing argument to maria_page_crc to uint32 storage/maria/ma_recovery.c: Call my_printv_error() from eprint() to get critical errors to mysqld log Removed \n from error strings to eprint() to get nicer output in mysqld Added simple test in _ma_reenable_logging_for_table() to not do any work if not needed storage/maria/ma_update.c: Ensure my_errno is set on return storage/maria/ma_write.c: Ensure my_errno is set on return storage/maria/maria_chk.c: Use DEBUGGER_OFF if --debug is not use (to get slightly faster execution for debug binaries) Added option --skip-safemalloc Don't write exponents for rec/key storage/maria/maria_def.h: Increase default repair buffer to 128M for maria_chk and maria_read_log Increase default sort buffer for maria_chk to 64M storage/maria/unittest/Makefile.am: Don't update files automaticly from bitkeeper storage/maria/unittest/ma_pagecache_consist.c: Remove testfile at end storage/maria/unittest/ma_pagecache_single.c: Remove testfile at end storage/maria/unittest/ma_test_all-t: More tests Safer checking if test caused error
2008-01-07 18:54:41 +02:00
if ((!$err && !$expected_error) ||
(($err >> 8) == $expected_error && $expected_error))
{
print "[ " if ($verbose);
print "ok";
print " ]" if ($verbose);
print "\n";
return 1;
}
print "[ " if ($verbose);
print "not ok";
print " ]" if ($verbose);
print "\n";
if ($verbose && length($output))
{
print "$output\n";
}
if (!$verbose)
{
$msg= "\n"; # Get a nicer output in perl unit test mode
}
$msg.= "Failed test '$com' ";
if ($iteration)
{
$msg.= "(loop iteration $iteration.) ";
}
$msg.= "at line ";
$msg.= (caller)[2];
$msg.= " (errcode: $err)\n";
if ($expected_error)
{
$msg.= "Was expecting errcode: $expected_error\n";
}
warn $msg;
$runtime_error= 1;
return 0;
}
####
#### Count tests
#### Arguments: $t: an array of the tests
####
sub count_tests
{
my ($t)= @_;
my ($i, $nr_tests);
$nr_tests= 0;
for ($i= 0; defined(@$t[$i]); $i++) { $nr_tests++ if (@$t[$i]); }
return $nr_tests;
}
####
#### Run a bunch of tests
#### Arguments: $t: an array of the tests
#### $verbose: to be passed to ok()
#### $clear: clear log files if set
####
sub run_test_bunch
{
my ($t, $verbose, $clear)= @_;
my ($i);
for ($i= 0; defined(@$t[$i]); $i++)
{
if ($clear && @$t[$i] eq $NEW_TEST)
{
unlink <maria_log.* maria_log_control>;
}
if (@$t[$i] ne $NEW_TEST)
{
ok(@$t[$i], $verbose, $i + 1);
}
}
}
####
#### usage
####
sub usage
{
print <<EOF;
$my_progname version $VER
Description:
Run various Maria related tests. Typically used via make test as a unittest.
Please set environment variable maria_path before executing, if you
are not starting the program where ma_test1, ma_test2, ma_test3,
ma_test_recovery etc. files are.
Options
--help Show this help and exit.
--version Show version number and exit.
--verbose Be more verbose. Will print each unittest on a line
and result after. This mode cannot be used with unit.pl
when running in normal unit test mode.
--maria-path=... Path to maria test files. You can set this as an
environment variable 'maria_path' also.
(maria_path: '$maria_path')
--valgrind=... Options for valgrind.
('$opt_valgrind')
--suffix=... Suffix for test files (ma_test1, ma_test2 etc.),
if they have one ('$opt_suffix')
--silent=... Silent option passed to ma_test* tests ('$opt_silent')
EOF
exit(0);
}