From b768d7fdefa7547d6642730f2f10a1b21ca8d04f Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Tue, 23 Nov 2010 14:34:00 +0100 Subject: [PATCH 1/6] Bug #43418 MTR2: does not notice a memory leak occuring at shutdown of mysqld w/ --valgrind Follow-up discussed with Reporter: Avoid hard shutdown after test failure, if caused by server log warning AND we are running valgrind More general pick-up of valgrind summaries, order may apparently vary Do exit(1) if we did find valgrind summary warnings --- mysql-test/mysql-test-run.pl | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b4cd53cff09..ae82bf5a589 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -568,7 +568,10 @@ sub run_test_server ($$$) { if ( !$opt_force ) { # Test has failed, force is off push(@$completed, $result); - return $completed; + return $completed unless $result->{'dont_kill_server'}; + # Prevent kill of server, to get valgrind report + print $sock "BYE\n"; + next; } elsif ($opt_max_test_fail > 0 and $num_failed_test >= $opt_max_test_fail) { @@ -808,13 +811,14 @@ sub run_worker ($) { elsif ($line eq 'BYE'){ mtr_report("Server said BYE"); stop_all_servers($opt_shutdown_timeout); + my $valgrind_reports= 0; if ($opt_valgrind_mysqld) { - valgrind_exit_reports(); + $valgrind_reports= valgrind_exit_reports(); } if ( $opt_gprof ) { gprof_collect (find_mysqld($basedir), keys %gprof_dirs); } - exit(0); + exit($valgrind_reports); } else { mtr_error("Could not understand server, '$line'"); @@ -4232,7 +4236,12 @@ sub after_failure ($) { sub report_failure_and_restart ($) { my $tinfo= shift; - stop_all_servers(); + if ($opt_valgrind_mysqld && ($tinfo->{'warnings'} || $tinfo->{'timeout'})) { + # In these cases we may want valgrind report from normal termination + $tinfo->{'dont_kill_server'}= 1; + } + # Shotdown properly if not to be killed (for valgrind) + stop_all_servers($tinfo->{'dont_kill_server'} ? $opt_shutdown_timeout : 0); $tinfo->{'result'}= 'MTR_RES_FAILED'; @@ -5359,6 +5368,8 @@ sub valgrind_arguments { # sub valgrind_exit_reports() { + my $found_err= 0; + foreach my $log_file (keys %mysqld_logs) { my @culprits= (); @@ -5394,7 +5405,7 @@ sub valgrind_exit_reports() { next; } # This line marks the start of a valgrind report - $found_report= 1 if $line =~ /ERROR SUMMARY:/; + $found_report= 1 if $line =~ /^==\d+== .* SUMMARY:/; if ($found_report) { $line=~ s/^==\d+== //; @@ -5411,8 +5422,11 @@ sub valgrind_exit_reports() { mtr_print ("Valgrind report from $log_file after tests:\n", @culprits); mtr_print_line(); print ("$valgrind_rep\n"); + $found_err= 1; } } + + return $found_err; } # From a2cbe6e94937d909dcca5bd8f21b06ac09c0862a Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Wed, 24 Nov 2010 10:22:03 +0100 Subject: [PATCH 2/6] Bug #58424 mtr ignores failing mysqltest in the presence of expect file for mysqld If mysqltest dies, mtr waits to see if mysqld dies too within 100ms But in that case, it should not care about expected crash Fix: jump past the code that checks the expect file --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b4cd53cff09..775eec7a9ef 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3673,7 +3673,6 @@ sub run_testcase ($) { # ---------------------------------------------------- # Check if it was an expected crash # ---------------------------------------------------- - SRVDIED: my $check_crash = check_expected_crash_and_restart($proc); if ($check_crash) { @@ -3683,6 +3682,7 @@ sub run_testcase ($) { next; } + SRVDIED: # ---------------------------------------------------- # Stop the test case timer # ---------------------------------------------------- From b2d1b1f897efe70e92238edd9ddde6fc54cae167 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 25 Nov 2010 10:28:36 +0100 Subject: [PATCH 3/6] Test sys_vars.shared_memory_base_name_basic used wrong path --- .../sys_vars/r/shared_memory_base_name_basic.result | 10 +++++----- .../sys_vars/t/shared_memory_base_name_basic.test | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/shared_memory_base_name_basic.result b/mysql-test/suite/sys_vars/r/shared_memory_base_name_basic.result index a94a906e121..356b3c9e879 100644 --- a/mysql-test/suite/sys_vars/r/shared_memory_base_name_basic.result +++ b/mysql-test/suite/sys_vars/r/shared_memory_base_name_basic.result @@ -1,20 +1,20 @@ select @@global.shared_memory_base_name; @@global.shared_memory_base_name -MYSQLTEST_VARDIR/tmp/mysqld.1.sock +MYSQL_TMP_DIR/mysqld.1.sock select @@session.shared_memory_base_name; ERROR HY000: Variable 'shared_memory_base_name' is a GLOBAL variable show global variables like 'shared_memory_base_name'; Variable_name Value -shared_memory_base_name MYSQLTEST_VARDIR/tmp/mysqld.1.sock +shared_memory_base_name MYSQL_TMP_DIR/mysqld.1.sock show session variables like 'shared_memory_base_name'; Variable_name Value -shared_memory_base_name MYSQLTEST_VARDIR/tmp/mysqld.1.sock +shared_memory_base_name MYSQL_TMP_DIR/mysqld.1.sock select * from information_schema.global_variables where variable_name='shared_memory_base_name'; VARIABLE_NAME VARIABLE_VALUE -SHARED_MEMORY_BASE_NAME MYSQLTEST_VARDIR/tmp/mysqld.1.sock +SHARED_MEMORY_BASE_NAME MYSQL_TMP_DIR/mysqld.1.sock select * from information_schema.session_variables where variable_name='shared_memory_base_name'; VARIABLE_NAME VARIABLE_VALUE -SHARED_MEMORY_BASE_NAME MYSQLTEST_VARDIR/tmp/mysqld.1.sock +SHARED_MEMORY_BASE_NAME MYSQL_TMP_DIR/mysqld.1.sock set global shared_memory_base_name=1; ERROR HY000: Variable 'shared_memory_base_name' is a read only variable set session shared_memory_base_name=1; diff --git a/mysql-test/suite/sys_vars/t/shared_memory_base_name_basic.test b/mysql-test/suite/sys_vars/t/shared_memory_base_name_basic.test index 24418a78687..da165564791 100644 --- a/mysql-test/suite/sys_vars/t/shared_memory_base_name_basic.test +++ b/mysql-test/suite/sys_vars/t/shared_memory_base_name_basic.test @@ -3,17 +3,17 @@ # # only global # ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR select @@global.shared_memory_base_name; --error ER_INCORRECT_GLOBAL_LOCAL_VAR select @@session.shared_memory_base_name; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR show global variables like 'shared_memory_base_name'; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR show session variables like 'shared_memory_base_name'; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR select * from information_schema.global_variables where variable_name='shared_memory_base_name'; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR select * from information_schema.session_variables where variable_name='shared_memory_base_name'; # From f6c89f46cad6c87059e74177a3c92964f5ea4c6b Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Thu, 25 Nov 2010 13:43:58 +0100 Subject: [PATCH 4/6] Bug #58482 mtr doesn't use suite names from individually specified test cases It does work in general, the problem here was that the test name 'alter_table' matches 'main.alter_table-big' which has already been found. Fixed by matching more explicitly (with/without suite name) --- mysql-test/lib/mtr_cases.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 7961fa6fa7d..ece6c61ee1d 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -143,7 +143,7 @@ sub collect_test_cases ($$$) { { last unless $opt_reorder; # test->{name} is always in suite.name format - if ( $test->{name} =~ /.*\.$tname/ ) + if ( $test->{name} =~ /^$sname.*\.$tname$/ ) { $found= 1; last; From ca2ea5541e980fb36eaa98047f5bbce80fc1ab7a Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Fri, 26 Nov 2010 10:57:01 +0100 Subject: [PATCH 5/6] Bug #58412 mysqltest: allow quoting of strings in let and in if comparison Stripping quotes in let was a bad idea, will not fix Added code to strip quotes from rhs in comparisons --- client/mysqltest.cc | 11 +++++++++++ .../rpl_tests/rpl_implicit_commit_binlog.test | 14 +++++++------- mysql-test/r/mysqltest.result | 3 +++ mysql-test/t/mysqltest.test | 14 +++++++++++++- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 459abf8ffe1..dfd383cc714 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -5678,6 +5678,17 @@ void do_block(enum block_cmd cmd, struct st_command* command) while (my_isspace(charset_info, *curr_ptr)) curr_ptr++; + /* Strip off trailing white space */ + while (my_isspace(charset_info, expr_end[-1])) + expr_end--; + /* strip off ' or " around the string */ + if (*curr_ptr == '\'' || *curr_ptr == '"') + { + if (expr_end[-1] != *curr_ptr) + die("Unterminated string value"); + curr_ptr++; + expr_end--; + } VAR v2; var_init(&v2,0,0,0,0); eval_expr(&v2, curr_ptr, &expr_end); diff --git a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test index bbd4969ef40..172483e1466 100644 --- a/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test +++ b/mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test @@ -36,8 +36,8 @@ let $ddl_cases= 41; while ($ddl_cases >= 1) { --echo -b-b-b-b-b-b-b-b-b-b-b- >> << -b-b-b-b-b-b-b-b-b-b-b- - let $in_temporary= "no"; - let $ok= "yes"; + let $in_temporary= no; + let $ok= yes; # # In SBR and MIXED modes, the commit event is usually the third event in the # binary log: @@ -91,7 +91,7 @@ while ($ddl_cases >= 1) { # This seems to be related to epochs. # We need to check this against an updated version or avoid it. - let $ok= "no"; + let $ok= no; let $commit_event_row_number= 6; } } @@ -356,7 +356,7 @@ while ($ddl_cases >= 1) if ($ddl_cases == 11) { let $cmd= CREATE TEMPORARY TABLE tt_xx (a int); - let $in_temporary= "yes"; + let $in_temporary= yes; # In SBR and MIXED modes, the DDL statement is written to the binary log but # does not commit the current transaction. # @@ -478,7 +478,7 @@ while ($ddl_cases >= 1) if ($ddl_cases == 8) { let $cmd= DROP TEMPORARY TABLE IF EXISTS new_tt_xx; - let $in_temporary= "yes"; + let $in_temporary= yes; # # In SBR and MIXED modes, the DDL statement is written to the binary log # but does not commit the current transaction: @@ -618,14 +618,14 @@ while ($ddl_cases >= 1) # commit. The flag in_temporary is used to avoid aborting the test in such # cases. Thus we force the commit. # - if ($in_temporary == "yes") + if ($in_temporary == yes) { --eval COMMIT } let $event_commit= query_get_value("SHOW BINLOG EVENTS FROM $first_binlog_position", Info, $commit_event_row_number); if (`SELECT SUBSTRING("$event_commit",1,6) != "COMMIT"`) { - if ($ok == "yes") + if ($ok == yes) { --echo it *does not* commit the current transaction. --echo $cmd diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index f5dce1e4196..6892164c225 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -423,7 +423,10 @@ while with string, only once hello == hello hello == hello hello != goodbye +'quoted' == ''quoted'' two words +'two words' +"two words" two words are two words right answer anything goes diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index cde517be03a..186b0e0fbfa 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1276,12 +1276,24 @@ if ($ifvar != goodbye) { echo hello != goodbye; } - +let $ifvar= 'quoted'; +if ($ifvar == ''quoted'') +{ + echo 'quoted' == ''quoted''; +} let $ifvar= two words; if ($ifvar == two words) { echo two words; } +if ($ifvar == 'two words') +{ + echo 'two words'; +} +if ($ifvar == "two words") +{ + echo "two words"; +} if ($ifvar == `SELECT 'two words'`) { echo two words are two words; From 067710eba1e3c958fb64fe569fae027afc65fd90 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Fri, 26 Nov 2010 13:59:39 +0100 Subject: [PATCH 6/6] Bug #58515 Tests: use use exec echo, not write_file to write mysqld.1.expect Fixed as suggested in the .inc file and two tests Could not reproduce problem, but tested tests on Windows --- .../extra/rpl_tests/rpl_get_master_version_and_clock.test | 8 ++------ mysql-test/include/restart_mysqld.inc | 8 ++------ mysql-test/suite/rpl/t/rpl_trigger.test | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test index 40e155bc314..c7e3d1abc03 100644 --- a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test +++ b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test @@ -53,9 +53,7 @@ source include/wait_for_slave_to_start.inc; connection master; # Write file to make mysql-test-run.pl expect the "crash", but don't start # it until it's told to ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -wait -EOF +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Send shutdown to the connected server and give # it 10 seconds to die before zapping it @@ -85,9 +83,7 @@ source include/wait_for_slave_io_error.inc; eval set @@global.debug = "-d,$dbug_sync_point"; # Write file to make mysql-test-run.pl start up the server again ---append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect connection master; # Turn on reconnect diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc index 0f363ff1ee3..d92115f0a61 100644 --- a/mysql-test/include/restart_mysqld.inc +++ b/mysql-test/include/restart_mysqld.inc @@ -1,18 +1,14 @@ # Write file to make mysql-test-run.pl expect the "crash", but don't start # it until it's told to ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -wait -EOF +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Send shutdown to the connected server and give # it 10 seconds to die before zapping it shutdown_server 10; # Write file to make mysql-test-run.pl start up the server again ---append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Turn on reconnect --enable_reconnect diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test index e296da01bad..afa80e9c3f5 100644 --- a/mysql-test/suite/rpl/t/rpl_trigger.test +++ b/mysql-test/suite/rpl/t/rpl_trigger.test @@ -313,9 +313,7 @@ FLUSH LOGS; # Stop master server --echo --> Stop master server ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -wait -EOF +--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc # Replace binlog @@ -323,9 +321,7 @@ remove_file $MYSQLD_DATADIR/master-bin.000001; copy_file $MYSQL_TEST_DIR/std_data/bug16266.000001 $MYSQLD_DATADIR/master-bin.000001; --echo --> Start master server ---append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -restart -EOF +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc let $binlog_version= query_get_value(SHOW BINLOG EVENTS, Info, 1);