#At file:///home/malff/BZR_TREE/mysql-trunk-perfschema/ based on revid:marc.alff@stripped
2936 Marc Alff 2009-11-03
Bug#45956 Performance schema: exotic mysqld startup, bad results
When initialization of the performance schema failed,
the server was internally in disabled state,
but show variables like "performance_schema" continued to report "ON",
which is misleading.
With this fix, performance_schema=OFF when initialization fails internally.
Also, more warning/information messages are printed in the server log,
to explain if/why the performance schema is enabled or disabled at startup.
added:
mysql-test/suite/perfschema/r/bad_option_3.result
mysql-test/suite/perfschema/r/start_server_oom.result
mysql-test/suite/perfschema/t/bad_option_3.test
mysql-test/suite/perfschema/t/start_server_oom-master.opt
mysql-test/suite/perfschema/t/start_server_oom.test
modified:
sql/mysqld.cc
=== added file 'mysql-test/suite/perfschema/r/bad_option_3.result'
--- a/mysql-test/suite/perfschema/r/bad_option_3.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/bad_option_3.result 2009-11-03 23:59:45 +0000
@@ -0,0 +1 @@
+Found: Performance schema disabled .reason: init failed..
=== added file 'mysql-test/suite/perfschema/r/start_server_oom.result'
--- a/mysql-test/suite/perfschema/r/start_server_oom.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_oom.result 2009-11-03 23:59:45 +0000
@@ -0,0 +1,59 @@
+show databases;
+Database
+information_schema
+mtr
+mysql
+performance_schema
+test
+select count(*) from performance_schema.PERFORMANCE_TIMERS;
+count(*)
+5
+select count(*) from performance_schema.SETUP_CONSUMERS;
+count(*)
+8
+select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 0
+0
+select count(*) from performance_schema.SETUP_TIMERS;
+count(*)
+1
+select * from performance_schema.COND_INSTANCES;
+select * from performance_schema.EVENTS_WAITS_CURRENT;
+select * from performance_schema.EVENTS_WAITS_HISTORY;
+select * from performance_schema.EVENTS_WAITS_HISTORY_LONG;
+select * from performance_schema.EVENTS_WAITS_SUMMARY_BY_EVENT_NAME;
+select * from performance_schema.EVENTS_WAITS_SUMMARY_BY_INSTANCE;
+select * from performance_schema.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME;
+select * from performance_schema.FILE_INSTANCES;
+select * from performance_schema.FILE_SUMMARY_BY_EVENT_NAME;
+select * from performance_schema.FILE_SUMMARY_BY_INSTANCE;
+select * from performance_schema.MUTEX_INSTANCES;
+select * from performance_schema.PERFORMANCE_TIMERS;
+select * from performance_schema.PROCESSLIST;
+select * from performance_schema.RWLOCK_INSTANCES;
+select * from performance_schema.SETUP_CONSUMERS;
+select * from performance_schema.SETUP_INSTRUMENTS;
+select * from performance_schema.SETUP_OBJECTS;
+select * from performance_schema.SETUP_TIMERS;
+show variables like "performance_schema%";
+Variable_name Value
+performance_schema OFF
+performance_schema_events_waits_history_long_size 10000
+performance_schema_events_waits_history_size 10
+performance_schema_max_cond_classes 80
+performance_schema_max_cond_instances 1000
+performance_schema_max_file_classes 999999999999
+performance_schema_max_file_handles 32768
+performance_schema_max_file_instances 10000
+performance_schema_max_mutex_classes 200
+performance_schema_max_mutex_instances 1000
+performance_schema_max_rwlock_classes 20
+performance_schema_max_rwlock_instances 1000
+performance_schema_max_table_handles 100000
+performance_schema_max_table_instances 50000
+performance_schema_max_thread_classes 50
+performance_schema_max_thread_instances 1000
+show engine PERFORMANCE_SCHEMA status;
+show status like "performance_schema%";
+call mtr.add_suppression(
+"Performance schema disabled .reason: init failed.");
=== added file 'mysql-test/suite/perfschema/t/bad_option_3.test'
--- a/mysql-test/suite/perfschema/t/bad_option_3.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/bad_option_3.test 2009-11-03 23:59:45 +0000
@@ -0,0 +1,46 @@
+# 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
+# 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
+
+# Tests for PERFORMANCE_SCHEMA
+# Check error handling for internal initialization errors (OOM)
+
+--source include/not_embedded.inc
+
+# max-file-classes=999999999999 is to cause OOM
+# no-such-option is to avoid starting a server and having to cleanup
+
+--error 2
+--exec $MYSQLD_BOOTSTRAP_CMD --loose-console --enable-performance-schema --performance-schema-max-file-classes=999999999999 --no-such-option > $MYSQLTEST_VARDIR/tmp/bad_option_3.txt 2>&1
+
+perl;
+ use strict;
+ use warnings;
+ my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/bad_option_3.txt";
+ open(FILE, "<", $fname) or die;
+ my @lines= <FILE>;
+ # those must be in the file for the test to pass
+ my @patterns=
+ ("Performance schema disabled .reason: init failed..");
+ foreach my $one_line (@lines)
+ {
+ foreach my $one_pattern (@patterns)
+ {
+ # print pattern, not line, to get a stable output
+ print "Found: $one_pattern\n" if ($one_line =~ /$one_pattern/);
+ }
+ }
+ close FILE;
+EOF
+
=== added file 'mysql-test/suite/perfschema/t/start_server_oom-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_oom-master.opt 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_oom-master.opt 2009-11-03 23:59:45 +0000
@@ -0,0 +1 @@
+--enable-performance-schema --performance_schema_max_file_classes=999999999999
=== added file 'mysql-test/suite/perfschema/t/start_server_oom.test'
--- a/mysql-test/suite/perfschema/t/start_server_oom.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_oom.test 2009-11-03 23:59:45 +0000
@@ -0,0 +1,25 @@
+# Copyright (C) 2008-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
+# 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
+
+# Tests for PERFORMANCE_SCHEMA
+# Verify that performance_schema=OFF when initialization failed.
+
+--source include/not_embedded.inc
+
+--source ../include/start_server_common.inc
+
+call mtr.add_suppression(
+"Performance schema disabled .reason: init failed.");
+
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-11-03 22:02:10 +0000
+++ b/sql/mysqld.cc 2009-11-03 23:59:45 +0000
@@ -4563,7 +4563,26 @@ int main(int argc, char **argv)
/* Add back the program name handle_options removes */
remaining_argc++;
remaining_argv--;
- PSI_hook= initialize_performance_schema(& pfs_param);
+ if (pfs_param.m_enabled)
+ {
+ PSI_hook= initialize_performance_schema(&pfs_param);
+ if (PSI_hook == NULL)
+ {
+ pfs_param.m_enabled= false;
+ buffered_logs.buffer(WARNING_LEVEL,
+ "Performance schema disabled (reason: init failed).");
+ }
+ else
+ {
+ buffered_logs.buffer(INFORMATION_LEVEL,
+ "Performance schema enabled.");
+ }
+ }
+ else
+ {
+ buffered_logs.buffer(INFORMATION_LEVEL,
+ "Performance schema disabled (reason: start parameters).");
+ }
}
#else
/*
Attachment: [text/bzr-bundle] bzr/marc.alff@sun.com-20091103235945-hvl1dexhcdvco9w8.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk-perfschema branch (marc.alff:2936) Bug#45956 | Marc Alff | 4 Nov |