From 8f52b41d4ccbba3e27a99df6ffe2ed10266d2b0f Mon Sep 17 00:00:00 2001 From: Matthias Leich Date: Tue, 20 Jul 2010 21:15:29 +0200 Subject: [PATCH] Bug#53102 perfschema.pfs_upgrade fails on sol10 sparc64 max in parallel mode The reason for the bug above is unclear but - Modify pfs_upgrade so that it's result is easier to analyze in case something fails - Fix several minor weaknesses which could cause that a successing test (either an already existing or a to be developed one) fails because of imperfect cleanup, too slow disconnected sessions etc. should either fix the bug or reduce it's probability or at least make the analysis of failures easier. mysql-test/suite/perfschema/include/upgrade_check.inc: New include file which contains redundant stuff taken from pfs_upgrade.test. Remove any file which might harm analysis of suspicious results. mysql-test/suite/perfschema/r/query_cache.result: Updated results mysql-test/suite/perfschema/r/selects.result: Updated results mysql-test/suite/perfschema/t/bad_option_1.test: Add the missing remove_file at beginning and end of test. mysql-test/suite/perfschema/t/bad_option_2.test: Add the missing remove_file at beginning and end of test. mysql-test/suite/perfschema/t/global_read_lock.test: Add a wait routine which ensures that the disconnect is really completed when the test ends. mysql-test/suite/perfschema/t/pfs_upgrade.test: - Move redundant actions to include/upgrade_check.inc - Add preemptive removal of files mysql-test/suite/perfschema/t/privilege.test: Add a wait routine which ensures that the disconnect is really completed when the test ends. mysql-test/suite/perfschema/t/query_cache.test: Add "flush status" so that counters are reset. (./mtr --repeat=2 perfschema.query_cache failed) mysql-test/suite/perfschema/t/read_only.test: Add a wait routine which ensures that the disconnect is really completed when the test ends. mysql-test/suite/perfschema/t/selects-master.opt: Needed for running with enabled event-scheduler mysql-test/suite/perfschema/t/selects.test: - Correct the sub test for the EVENT scheduler - Replace "sleep" by wait_routine - Add premptive cleanups like "DROP ... IF EXISTS ..." --- .../perfschema/include/upgrade_check.inc | 29 ++++++++++ .../suite/perfschema/r/query_cache.result | 1 + mysql-test/suite/perfschema/r/selects.result | 15 +++++- .../suite/perfschema/t/bad_option_1.test | 12 +++-- .../suite/perfschema/t/bad_option_2.test | 12 +++-- .../suite/perfschema/t/global_read_lock.test | 1 + .../suite/perfschema/t/pfs_upgrade.test | 53 ++++++++----------- mysql-test/suite/perfschema/t/privilege.test | 4 +- .../suite/perfschema/t/query_cache.test | 8 +-- mysql-test/suite/perfschema/t/read_only.test | 1 + .../suite/perfschema/t/selects-master.opt | 1 + mysql-test/suite/perfschema/t/selects.test | 43 ++++++++++++--- 12 files changed, 127 insertions(+), 53 deletions(-) create mode 100644 mysql-test/suite/perfschema/include/upgrade_check.inc create mode 100644 mysql-test/suite/perfschema/t/selects-master.opt diff --git a/mysql-test/suite/perfschema/include/upgrade_check.inc b/mysql-test/suite/perfschema/include/upgrade_check.inc new file mode 100644 index 00000000000..935a71ab065 --- /dev/null +++ b/mysql-test/suite/perfschema/include/upgrade_check.inc @@ -0,0 +1,29 @@ +# Copyright (C) 2010 Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Routine to be called by pfs_upgrade.test +# $out_file and $err_file must be set within pfs_upgrade.test. +# + +--error 1 +--exec $MYSQL_UPGRADE --skip-verbose > $out_file 2> $err_file + +# Verify that mysql_upgrade complained about the performance_schema +--cat_file $err_file +--error 0,1 +--remove_file $out_file +--error 0,1 +--remove_file $err_file + diff --git a/mysql-test/suite/perfschema/r/query_cache.result b/mysql-test/suite/perfschema/r/query_cache.result index f2fe8c727b2..a0aeac5a916 100644 --- a/mysql-test/suite/perfschema/r/query_cache.result +++ b/mysql-test/suite/perfschema/r/query_cache.result @@ -65,3 +65,4 @@ Variable_name Value Qcache_hits 1 SET GLOBAL query_cache_size= default; drop table t1; +flush status; diff --git a/mysql-test/suite/perfschema/r/selects.result b/mysql-test/suite/perfschema/r/selects.result index b5bef207303..9b91c6f0fc8 100644 --- a/mysql-test/suite/perfschema/r/selects.result +++ b/mysql-test/suite/perfschema/r/selects.result @@ -55,14 +55,21 @@ THREAD_ID EVENT_ID [THREAD_ID] [EVENT_ID] [THREAD_ID] [EVENT_ID] [THREAD_ID] [EVENT_ID] +DROP TABLE IF EXISTS t_event; +DROP EVENT IF EXISTS t_ps_event; +CREATE TABLE t_event AS +SELECT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT +WHERE 1 = 2; CREATE EVENT t_ps_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND -DO SELECT DISTINCT EVENT_ID +DO INSERT INTO t_event +SELECT DISTINCT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT JOIN performance_schema.EVENTS_WAITS_HISTORY USING (EVENT_ID) ORDER BY EVENT_ID LIMIT 1; ALTER TABLE t1 ADD COLUMN c INT; +DROP TRIGGER IF EXISTS t_ps_trigger; CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1 FOR EACH ROW BEGIN SET NEW.c = (SELECT MAX(EVENT_ID) @@ -76,6 +83,7 @@ id c 12 [EVENT_ID] 13 [EVENT_ID] DROP TRIGGER t_ps_trigger; +DROP PROCEDURE IF EXISTS t_ps_proc; CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT) BEGIN SELECT id FROM performance_schema.PROCESSLIST @@ -83,6 +91,7 @@ WHERE THREAD_ID = tid INTO pid; END; | CALL t_ps_proc(0, @p_id); +DROP FUNCTION IF EXISTS t_ps_proc; CREATE FUNCTION t_ps_func(tid INT) RETURNS int BEGIN return (SELECT id FROM performance_schema.PROCESSLIST @@ -92,6 +101,10 @@ END; SELECT t_ps_func(0) = @p_id; t_ps_func(0) = @p_id 1 +SELECT * FROM t_event; +EVENT_ID +[EVENT_ID] DROP PROCEDURE t_ps_proc; DROP FUNCTION t_ps_func; DROP TABLE t1; +DROP TABLE t_event; diff --git a/mysql-test/suite/perfschema/t/bad_option_1.test b/mysql-test/suite/perfschema/t/bad_option_1.test index 9962f327093..ee4f0d0d160 100644 --- a/mysql-test/suite/perfschema/t/bad_option_1.test +++ b/mysql-test/suite/perfschema/t/bad_option_1.test @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -10,8 +10,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA # Tests for PERFORMANCE_SCHEMA # Check error handling for invalid server start options @@ -19,8 +19,11 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +let $outfile= $MYSQLTEST_VARDIR/tmp/bad_option_1.txt; +--error 0,1 +--remove_file $outfile --error 7 ---exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-enabled=maybe > $MYSQLTEST_VARDIR/tmp/bad_option_1.txt 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-enabled=maybe > $outfile 2>&1 perl; use strict; @@ -42,4 +45,5 @@ perl; } close FILE; EOF +--remove_file $outfile diff --git a/mysql-test/suite/perfschema/t/bad_option_2.test b/mysql-test/suite/perfschema/t/bad_option_2.test index a8d15764864..b8f45be3cdf 100644 --- a/mysql-test/suite/perfschema/t/bad_option_2.test +++ b/mysql-test/suite/perfschema/t/bad_option_2.test @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Sun Microsystems, Inc +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -10,8 +10,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA # Tests for PERFORMANCE_SCHEMA # Check error handling for ambiguous server start options @@ -19,8 +19,11 @@ --source include/not_embedded.inc --source include/have_perfschema.inc +let $outfile= $MYSQLTEST_VARDIR/tmp/bad_option_2.txt; +--error 0,1 +--remove_file $outfile --error 3 ---exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-max_=12 > $MYSQLTEST_VARDIR/tmp/bad_option_2.txt 2>&1 +--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --performance-schema-max_=12 > $outfile 2>&1 perl; use strict; @@ -41,4 +44,5 @@ perl; } close FILE; EOF +--remove_file $outfile diff --git a/mysql-test/suite/perfschema/t/global_read_lock.test b/mysql-test/suite/perfschema/t/global_read_lock.test index 16971023cbb..b953ea32ce0 100644 --- a/mysql-test/suite/perfschema/t/global_read_lock.test +++ b/mysql-test/suite/perfschema/t/global_read_lock.test @@ -81,6 +81,7 @@ update performance_schema.SETUP_INSTRUMENTS set enabled='YES'; unlock tables; disconnect con1; +--source include/wait_until_disconnected.inc --echo connection default; connection default; diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade.test b/mysql-test/suite/perfschema/t/pfs_upgrade.test index 4902dc73e8a..b8d25d4a66e 100644 --- a/mysql-test/suite/perfschema/t/pfs_upgrade.test +++ b/mysql-test/suite/perfschema/t/pfs_upgrade.test @@ -22,6 +22,15 @@ --source include/have_perfschema.inc --source include/have_lowercase0.inc +# Some initial settings + Preemptive cleanup +let $MYSQLD_DATADIR= `SELECT @@datadir`; +let $err_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err; +let $out_file= $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out; +--error 0,1 +--remove_file $out_file +--error 0,1 +--remove_file $err_file + --disable_warnings drop table if exists test.user_table; drop procedure if exists test.user_proc; @@ -29,22 +38,20 @@ drop function if exists test.user_func; drop event if exists test.user_event; --enable_warnings + --echo "Testing mysql_upgrade with TABLE performance_schema.user_table" create table test.user_table(a int); -let $MYSQLD_DATADIR= `SELECT @@datadir`; +--error 0,1 +--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm --copy_file $MYSQLD_DATADIR/test/user_table.frm $MYSQLD_DATADIR/performance_schema/user_table.frm # Make sure the table is visible use performance_schema; show tables like "user_table"; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc # Make sure the table is still visible show tables like "user_table"; @@ -54,22 +61,20 @@ use test; --remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm drop table test.user_table; + --echo "Testing mysql_upgrade with VIEW performance_schema.user_view" create view test.user_view as select "Not supposed to be here"; -let $MYSQLD_DATADIR= `SELECT @@datadir`; +--error 0,1 +--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm --copy_file $MYSQLD_DATADIR/test/user_view.frm $MYSQLD_DATADIR/performance_schema/user_view.frm # Make sure the view is visible use performance_schema; show tables like "user_view"; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc # Make sure the view is still visible show tables like "user_view"; @@ -79,6 +84,7 @@ use test; --remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm drop view test.user_view; + --echo "Testing mysql_upgrade with PROCEDURE performance_schema.user_proc" create procedure test.user_proc() @@ -86,17 +92,14 @@ create procedure test.user_proc() update mysql.proc set db='performance_schema' where name='user_proc'; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc select name from mysql.proc where db='performance_schema'; update mysql.proc set db='test' where name='user_proc'; drop procedure test.user_proc; + --echo "Testing mysql_upgrade with FUNCTION performance_schema.user_func" create function test.user_func() returns integer @@ -104,17 +107,14 @@ create function test.user_func() returns integer update mysql.proc set db='performance_schema' where name='user_func'; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc select name from mysql.proc where db='performance_schema'; update mysql.proc set db='test' where name='user_func'; drop function test.user_func; + --echo "Testing mysql_upgrade with EVENT performance_schema.user_event" create event test.user_event on schedule every 1 day do @@ -122,17 +122,10 @@ create event test.user_event on schedule every 1 day do update mysql.event set db='performance_schema' where name='user_event'; ---error 1 ---exec $MYSQL_UPGRADE --skip-verbose > $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out 2> $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - -# Verify that mysql_upgrade complained about the performance_schema ---cat_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err +--source suite/perfschema/include/upgrade_check.inc select name from mysql.event where db='performance_schema'; update mysql.event set db='test' where name='user_event'; drop event test.user_event; ---remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.out ---remove_file $MYSQLTEST_VARDIR/tmp/pfs_upgrade.err - diff --git a/mysql-test/suite/perfschema/t/privilege.test b/mysql-test/suite/perfschema/t/privilege.test index d2f3c2a9e6b..2d682de2870 100644 --- a/mysql-test/suite/perfschema/t/privilege.test +++ b/mysql-test/suite/perfschema/t/privilege.test @@ -350,9 +350,9 @@ TRUNCATE TABLE performance_schema.EVENTS_WAITS_HISTORY; TRUNCATE TABLE performance_schema.EVENTS_WAITS_CURRENT; --echo # Clean up - ---connection default --disconnect pfs_user_4 +--source include/wait_until_disconnected.inc +--connection default REVOKE ALL PRIVILEGES, GRANT OPTION FROM pfs_user_4; DROP USER pfs_user_4; flush privileges; diff --git a/mysql-test/suite/perfschema/t/query_cache.test b/mysql-test/suite/perfschema/t/query_cache.test index 95f78d290ee..a48704dc9d6 100644 --- a/mysql-test/suite/perfschema/t/query_cache.test +++ b/mysql-test/suite/perfschema/t/query_cache.test @@ -1,4 +1,4 @@ -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (C) 2009 Sun Microsystems, Inc # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -10,8 +10,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Tests for PERFORMANCE_SCHEMA @@ -33,7 +33,6 @@ SET GLOBAL query_cache_size=1355776; flush query cache; reset query cache; -# Reset Qcache_* to a known state flush status; select * from t1; @@ -67,4 +66,5 @@ show status like "Qcache_hits"; SET GLOBAL query_cache_size= default; drop table t1; +flush status; diff --git a/mysql-test/suite/perfschema/t/read_only.test b/mysql-test/suite/perfschema/t/read_only.test index 62631fa048f..73150207f66 100644 --- a/mysql-test/suite/perfschema/t/read_only.test +++ b/mysql-test/suite/perfschema/t/read_only.test @@ -85,6 +85,7 @@ update performance_schema.SETUP_INSTRUMENTS set enabled='YES'; --enable_result_log disconnect con1; +--source include/wait_until_disconnected.inc --echo connection default; connection default; diff --git a/mysql-test/suite/perfschema/t/selects-master.opt b/mysql-test/suite/perfschema/t/selects-master.opt new file mode 100644 index 00000000000..f93413a61e5 --- /dev/null +++ b/mysql-test/suite/perfschema/t/selects-master.opt @@ -0,0 +1 @@ +--event-scheduler diff --git a/mysql-test/suite/perfschema/t/selects.test b/mysql-test/suite/perfschema/t/selects.test index d5268e8465c..a0c000b80c1 100644 --- a/mysql-test/suite/perfschema/t/selects.test +++ b/mysql-test/suite/perfschema/t/selects.test @@ -1,4 +1,4 @@ -# Copyright (C) 2008-2009 Sun Microsystems, Inc +# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -10,8 +10,8 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# along with this program; if not, write to the Free Software Foundation, +# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA --source include/not_embedded.inc --source include/have_perfschema.inc @@ -85,20 +85,32 @@ LIMIT 5; # EVENT +# Check that the event_scheduler is really running +--source include/running_event_scheduler.inc + +--disable_warnings +DROP TABLE IF EXISTS t_event; +DROP EVENT IF EXISTS t_ps_event; +--enable_warnings +CREATE TABLE t_event AS +SELECT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT +WHERE 1 = 2; CREATE EVENT t_ps_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND -DO SELECT DISTINCT EVENT_ID +DO INSERT INTO t_event + SELECT DISTINCT EVENT_ID FROM performance_schema.EVENTS_WAITS_CURRENT JOIN performance_schema.EVENTS_WAITS_HISTORY USING (EVENT_ID) ORDER BY EVENT_ID LIMIT 1; ---sleep 2 - # TRIGGER ALTER TABLE t1 ADD COLUMN c INT; +--disable_warnings +DROP TRIGGER IF EXISTS t_ps_trigger; +--enable_warnings delimiter |; CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1 @@ -119,6 +131,9 @@ DROP TRIGGER t_ps_trigger; # PROCEDURE +--disable_warnings +DROP PROCEDURE IF EXISTS t_ps_proc; +--enable_warnings delimiter |; CREATE PROCEDURE t_ps_proc(IN tid INT, OUT pid INT) @@ -135,6 +150,9 @@ CALL t_ps_proc(0, @p_id); # FUNCTION +--disable_warnings +DROP FUNCTION IF EXISTS t_ps_proc; +--enable_warnings delimiter |; CREATE FUNCTION t_ps_func(tid INT) RETURNS int @@ -149,8 +167,17 @@ delimiter ;| SELECT t_ps_func(0) = @p_id; -DROP PROCEDURE t_ps_proc; -DROP FUNCTION t_ps_func; +# We might reach this point too early which means the event scheduler has not +# execute our "t_ps_event". Therefore we poll till the record was inserted +# and run our test statement afterwards. +let $wait_timeout= 20; +let $wait_condition= SELECT COUNT(*) = 1 FROM t_event; +--source include/wait_condition.inc +--replace_column 1 [EVENT_ID] +SELECT * FROM t_event; # Clean up +DROP PROCEDURE t_ps_proc; +DROP FUNCTION t_ps_func; DROP TABLE t1; +DROP TABLE t_event;