List:Commits« Previous MessageNext Message »
From:Marc Alff Date:April 11 2009 4:46am
Subject:bzr commit into mysql-6.0-perf branch (marc.alff:2862) Bug#44210
View as plain text  
#At file:///home/malff/BZR-TREE/mysql-6.0-perf/ based on revid:marc.alff@stripped

 2862 Marc Alff	2009-04-10
      Bug#44210 Performance schema: pool-of-threads threads instrumentation is missing
      
      Instrumented the current thread for every implementation of --thread_handling
      Added functional tests
added:
  mysql-test/suite/perfschema/r/no_threads.result
  mysql-test/suite/perfschema/r/one_thread_per_con.result
  mysql-test/suite/perfschema/r/pool_of_threads.result
  mysql-test/suite/perfschema/t/no_threads-master.opt
  mysql-test/suite/perfschema/t/no_threads.test
  mysql-test/suite/perfschema/t/one_thread_per_con-master.opt
  mysql-test/suite/perfschema/t/one_thread_per_con.test
  mysql-test/suite/perfschema/t/pool_of_threads-master.opt
  mysql-test/suite/perfschema/t/pool_of_threads.test
modified:
  mysql-test/suite/perfschema/include/setup_helper.inc
  mysql-test/suite/perfschema/r/maria_mutex.result
  sql/mysqld.cc
  sql/scheduler.cc
  sql/sql_class.cc
  sql/sql_connect.cc
  storage/perfschema/pfs.cc

=== modified file 'mysql-test/suite/perfschema/include/setup_helper.inc'
--- a/mysql-test/suite/perfschema/include/setup_helper.inc	2009-04-09 16:48:46 +0000
+++ b/mysql-test/suite/perfschema/include/setup_helper.inc	2009-04-11 04:46:25 +0000
@@ -18,8 +18,10 @@
 let $MYSQLD_DATADIR= `select @@datadir`;
 let $MYSQLD_TMPDIR= `select @@tmpdir`;
 
+--disable_query_log
 update performance_schema.SETUP_INSTRUMENTS set enabled='NO';
 update performance_schema.SETUP_CONSUMERS set enabled='YES';
+--enable_query_log
 
 connect (con1,localhost,root,,);
 
@@ -38,7 +40,13 @@ let $con3_THREAD_ID=`select thread_id fr
 
 connection default;
 
-prepare stmt_dump_events from "select event_name, source, operation,
-number_of_bytes from performance_schema.EVENTS_WAITS_HISTORY_LONG
-where thread_id=? order by event_id;";
+--disable_query_log
+prepare stmt_dump_events from
+  "select event_name, source, operation, number_of_bytes
+  from performance_schema.EVENTS_WAITS_HISTORY_LONG
+  where thread_id=? order by event_id;";
+
+prepare stmt_dump_thread from
+  "select name from performance_schema.PROCESSLIST where thread_id=? ;";
+--enable_query_log
 

=== modified file 'mysql-test/suite/perfschema/r/maria_mutex.result'
--- a/mysql-test/suite/perfschema/r/maria_mutex.result	2009-04-09 16:48:46 +0000
+++ b/mysql-test/suite/perfschema/r/maria_mutex.result	2009-04-11 04:46:25 +0000
@@ -1,8 +1,3 @@
-update performance_schema.SETUP_INSTRUMENTS set enabled='NO';
-update performance_schema.SETUP_CONSUMERS set enabled='YES';
-prepare stmt_dump_events from "select event_name, source, operation,
-number_of_bytes from performance_schema.EVENTS_WAITS_HISTORY_LONG
-where thread_id=? order by event_id;";
 update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
   where name like "wait/synch/mutex/maria/THR_LOCK_maria";
 drop table if exists test.t1;

=== added file 'mysql-test/suite/perfschema/r/no_threads.result'
--- a/mysql-test/suite/perfschema/r/no_threads.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/no_threads.result	2009-04-11 04:46:25 +0000
@@ -0,0 +1,54 @@
+update performance_schema.SETUP_INSTRUMENTS set enabled='NO';
+update performance_schema.SETUP_CONSUMERS set enabled='YES';
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
+  where name like "wait/synch/mutex/maria/THR_LOCK_maria";
+drop table if exists test.t1;
+truncate table performance_schema.EVENTS_WAITS_CURRENT;
+truncate table performance_schema.EVENTS_WAITS_HISTORY;
+truncate table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+show variables like "thread_handling";
+Variable_name	Value
+thread_handling	no-threads
+create table test.t1(a int) engine=MARIA;
+show variables like "performance_schema_enabled";
+Variable_name	Value
+performance_schema_enabled	ON
+show variables like "performance_schema_max_thread%";
+Variable_name	Value
+performance_schema_max_thread	10
+performance_schema_max_thread_instruments	50
+show status like "performance_schema%";
+Variable_name	Value
+Performance_schema_cond_instrument_lost	0
+Performance_schema_cond_lost	0
+Performance_schema_file_instrument_lost	0
+Performance_schema_file_lost	0
+Performance_schema_mutex_instrument_lost	0
+Performance_schema_mutex_lost	0
+Performance_schema_rwlock_instrument_lost	0
+Performance_schema_rwlock_lost	0
+Performance_schema_table_instrument_lost	0
+Performance_schema_table_lost	0
+Performance_schema_thread_instrument_lost	0
+Performance_schema_thread_lost	0
+select count(*) from performance_schema.PROCESSLIST
+where name like "thread/sql/main";
+count(*)
+1
+select count(*) from performance_schema.PROCESSLIST
+where name like "thread/sql/OneConnection";
+count(*)
+1
+select event_name, operation, source
+from performance_schema.EVENTS_WAITS_CURRENT;
+event_name	operation	source
+wait/synch/mutex/maria/THR_LOCK_maria	lock	ma_create.c:782
+select event_name, operation, source
+from performance_schema.EVENTS_WAITS_HISTORY;
+event_name	operation	source
+wait/synch/mutex/maria/THR_LOCK_maria	lock	ma_create.c:782
+select event_name, operation, source
+from performance_schema.EVENTS_WAITS_HISTORY_LONG;
+event_name	operation	source
+wait/synch/mutex/maria/THR_LOCK_maria	lock	ma_create.c:782
+drop table test.t1;

=== added file 'mysql-test/suite/perfschema/r/one_thread_per_con.result'
--- a/mysql-test/suite/perfschema/r/one_thread_per_con.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/one_thread_per_con.result	2009-04-11 04:46:25 +0000
@@ -0,0 +1,38 @@
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
+  where name like "wait/synch/mutex/maria/THR_LOCK_maria";
+drop table if exists test.t1;
+drop table if exists test.t2;
+drop table if exists test.t3;
+truncate table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+show variables like "thread_handling";
+Variable_name	Value
+thread_handling	one-thread-per-connection
+"----------------- Connection 1"
+create table test.t1(a int) engine=MARIA;
+"----------------- Connection 2"
+create table test.t2(a int) engine=MARIA;
+"----------------- Connection 3"
+create table test.t3(a int) engine=MARIA;
+"----------------- Connection default"
+execute stmt_dump_events using @tid;
+event_name	source	operation	number_of_bytes
+wait/synch/mutex/maria/THR_LOCK_maria	ma_create.c:782	lock	NULL
+execute stmt_dump_thread using @tid;
+name
+thread/sql/OneConnection
+execute stmt_dump_events using @tid;
+event_name	source	operation	number_of_bytes
+wait/synch/mutex/maria/THR_LOCK_maria	ma_create.c:782	lock	NULL
+execute stmt_dump_thread using @tid;
+name
+thread/sql/OneConnection
+execute stmt_dump_events using @tid;
+event_name	source	operation	number_of_bytes
+wait/synch/mutex/maria/THR_LOCK_maria	ma_create.c:782	lock	NULL
+execute stmt_dump_thread using @tid;
+name
+thread/sql/OneConnection
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES';

=== added file 'mysql-test/suite/perfschema/r/pool_of_threads.result'
--- a/mysql-test/suite/perfschema/r/pool_of_threads.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/pool_of_threads.result	2009-04-11 04:46:25 +0000
@@ -0,0 +1,38 @@
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
+  where name like "wait/synch/mutex/maria/THR_LOCK_maria";
+drop table if exists test.t1;
+drop table if exists test.t2;
+drop table if exists test.t3;
+truncate table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+show variables like "thread_handling";
+Variable_name	Value
+thread_handling	pool-of-threads
+"----------------- Connection 1"
+create table test.t1(a int) engine=MARIA;
+"----------------- Connection 2"
+create table test.t2(a int) engine=MARIA;
+"----------------- Connection 3"
+create table test.t3(a int) engine=MARIA;
+"----------------- Connection default"
+execute stmt_dump_events using @tid;
+event_name	source	operation	number_of_bytes
+wait/synch/mutex/maria/THR_LOCK_maria	ma_create.c:782	lock	NULL
+execute stmt_dump_thread using @tid;
+name
+thread/sql/OneConnection
+execute stmt_dump_events using @tid;
+event_name	source	operation	number_of_bytes
+wait/synch/mutex/maria/THR_LOCK_maria	ma_create.c:782	lock	NULL
+execute stmt_dump_thread using @tid;
+name
+thread/sql/OneConnection
+execute stmt_dump_events using @tid;
+event_name	source	operation	number_of_bytes
+wait/synch/mutex/maria/THR_LOCK_maria	ma_create.c:782	lock	NULL
+execute stmt_dump_thread using @tid;
+name
+thread/sql/OneConnection
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES';

=== added file 'mysql-test/suite/perfschema/t/no_threads-master.opt'
--- a/mysql-test/suite/perfschema/t/no_threads-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/no_threads-master.opt	2009-04-11 04:46:25 +0000
@@ -0,0 +1 @@
+--one-thread --thread-handling=no-threads --performance-schema-max-thread=10

=== added file 'mysql-test/suite/perfschema/t/no_threads.test'
--- a/mysql-test/suite/perfschema/t/no_threads.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/no_threads.test	2009-04-11 04:46:25 +0000
@@ -0,0 +1,65 @@
+# 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
+
+--source include/not_embedded.inc
+
+# Setup : in this main thread
+
+update performance_schema.SETUP_INSTRUMENTS set enabled='NO';
+update performance_schema.SETUP_CONSUMERS set enabled='YES';
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
+  where name like "wait/synch/mutex/maria/THR_LOCK_maria";
+
+--disable_warnings
+drop table if exists test.t1;
+--enable_warnings
+
+truncate table performance_schema.EVENTS_WAITS_CURRENT;
+truncate table performance_schema.EVENTS_WAITS_HISTORY;
+truncate table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+
+show variables like "thread_handling";
+
+# Code to test : in this main thread
+
+create table test.t1(a int) engine=MARIA;
+
+show variables like "performance_schema_enabled";
+show variables like "performance_schema_max_thread%";
+show status like "performance_schema%";
+
+# Verification : in this main thread
+
+select count(*) from performance_schema.PROCESSLIST
+  where name like "thread/sql/main";
+
+select count(*) from performance_schema.PROCESSLIST
+  where name like "thread/sql/OneConnection";
+
+select event_name, operation, source
+  from performance_schema.EVENTS_WAITS_CURRENT;
+
+select event_name, operation, source
+  from performance_schema.EVENTS_WAITS_HISTORY;
+
+select event_name, operation, source
+  from performance_schema.EVENTS_WAITS_HISTORY_LONG;
+
+# Cleanup
+
+drop table test.t1;
+

=== added file 'mysql-test/suite/perfschema/t/one_thread_per_con-master.opt'
--- a/mysql-test/suite/perfschema/t/one_thread_per_con-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/one_thread_per_con-master.opt	2009-04-11 04:46:25 +0000
@@ -0,0 +1 @@
+--thread_handling=one-thread-per-connection

=== added file 'mysql-test/suite/perfschema/t/one_thread_per_con.test'
--- a/mysql-test/suite/perfschema/t/one_thread_per_con.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/one_thread_per_con.test	2009-04-11 04:46:25 +0000
@@ -0,0 +1,93 @@
+# 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
+
+--source include/not_embedded.inc
+
+# Setup
+
+--source ../include/setup_helper.inc
+
+# We use a maria table here because CREATE TABLE has a known,
+# stable behavior (it will lock THR_LOCK_maria once).
+# The point is not to test maria, but to test that each
+# connection is properly instrumented, with one-thread-per-connection
+
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
+  where name like "wait/synch/mutex/maria/THR_LOCK_maria";
+
+--disable_warnings
+drop table if exists test.t1;
+drop table if exists test.t2;
+drop table if exists test.t3;
+--enable_warnings
+
+truncate table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+
+show variables like "thread_handling";
+
+# Code to test
+
+connection con1;
+
+-- echo "----------------- Connection 1"
+create table test.t1(a int) engine=MARIA;
+
+connection con2;
+
+-- echo "----------------- Connection 2"
+create table test.t2(a int) engine=MARIA;
+
+connection con3;
+
+-- echo "----------------- Connection 3"
+create table test.t3(a int) engine=MARIA;
+
+# Verification
+
+connection default;
+
+-- echo "----------------- Connection default"
+
+--disable_query_log
+eval set @tid= $con1_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+--disable_query_log
+eval set @tid= $con2_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+--disable_query_log
+eval set @tid= $con3_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+# Cleanup
+
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+
+--source ../include/cleanup_helper.inc
+

=== added file 'mysql-test/suite/perfschema/t/pool_of_threads-master.opt'
--- a/mysql-test/suite/perfschema/t/pool_of_threads-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/pool_of_threads-master.opt	2009-04-11 04:46:25 +0000
@@ -0,0 +1 @@
+--thread_handling=pool-of-threads

=== added file 'mysql-test/suite/perfschema/t/pool_of_threads.test'
--- a/mysql-test/suite/perfschema/t/pool_of_threads.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/pool_of_threads.test	2009-04-11 04:46:25 +0000
@@ -0,0 +1,93 @@
+# 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
+
+--source include/not_embedded.inc
+
+# Setup
+
+--source ../include/setup_helper.inc
+
+# We use a maria table here because CREATE TABLE has a known,
+# stable behavior (it will lock THR_LOCK_maria once).
+# The point is not to test maria, but to test that each
+# connection in a pool of thread is properly instrumented.
+
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES'
+  where name like "wait/synch/mutex/maria/THR_LOCK_maria";
+
+--disable_warnings
+drop table if exists test.t1;
+drop table if exists test.t2;
+drop table if exists test.t3;
+--enable_warnings
+
+truncate table performance_schema.EVENTS_WAITS_HISTORY_LONG;
+
+show variables like "thread_handling";
+
+# Code to test
+
+connection con1;
+
+-- echo "----------------- Connection 1"
+create table test.t1(a int) engine=MARIA;
+
+connection con2;
+
+-- echo "----------------- Connection 2"
+create table test.t2(a int) engine=MARIA;
+
+connection con3;
+
+-- echo "----------------- Connection 3"
+create table test.t3(a int) engine=MARIA;
+
+# Verification
+
+connection default;
+
+-- echo "----------------- Connection default"
+
+--disable_query_log
+eval set @tid= $con1_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+--disable_query_log
+eval set @tid= $con2_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+--disable_query_log
+eval set @tid= $con3_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+# Cleanup
+
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+
+--source ../include/cleanup_helper.inc
+

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-04-03 23:18:46 +0000
+++ b/sql/mysqld.cc	2009-04-11 04:46:25 +0000
@@ -5072,6 +5072,12 @@ static bool read_init_file(char *file_na
 
 void handle_connection_in_main_thread(THD *thd)
 {
+#ifdef HAVE_PSI_INTERFACE
+  thd->m_psi= init_psi_thread_with_id(key_thread_one_connection, thd, thd->thread_id);
+#else
+  thd->m_psi= NULL;
+#endif
+
   MYSQL_MUTEX_ASSERT_OWNER(&LOCK_thread_count);
   thread_cache_size=0;			// Safety
   threads.append(thd);
@@ -5088,6 +5094,12 @@ void create_thread_to_handle_connection(
 {
   if (cached_thread_count > wake_thread)
   {
+#ifdef HAVE_PSI_INTERFACE
+    thd->m_psi= init_psi_thread_with_id(key_thread_one_connection, thd, thd->thread_id);
+#else
+    thd->m_psi= NULL;
+#endif
+
     /* Get thread from cache */
     thread_cache.append(thd);
     wake_thread++;

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2009-03-31 23:10:54 +0000
+++ b/sql/scheduler.cc	2009-04-11 04:46:25 +0000
@@ -462,6 +462,12 @@ static void libevent_add_connection(THD
     DBUG_VOID_RETURN;
   }
 
+#ifdef HAVE_PSI_INTERFACE
+  thd->m_psi= init_psi_thread_with_id(key_thread_one_connection, thd, thd->thread_id);
+#else
+  thd->m_psi= NULL;
+#endif
+
   thd->set_time();
   thd->thr_create_utime= my_micro_time();
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2009-04-03 23:18:46 +0000
+++ b/sql/sql_class.cc	2009-04-11 04:46:25 +0000
@@ -1261,6 +1261,7 @@ bool THD::store_globals(bool real_thread
   }
   else
   {
+    DBUG_ASSERT(m_psi == NULL);
     m_psi= NULL;
   }
 #endif

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2009-03-27 10:12:29 +0000
+++ b/sql/sql_connect.cc	2009-04-11 04:46:25 +0000
@@ -1106,6 +1106,8 @@ pthread_handler_t handle_one_connection(
 #ifdef HAVE_PSI_INTERFACE
   thd->m_psi= init_and_bind_psi_thread_with_id(key_thread_one_connection,
                                                thd, thd->thread_id);
+#else
+  thd->m_psi= NULL;
 #endif
 
   do_handle_one_connection(thd);
@@ -1173,9 +1175,6 @@ end_thread:
     */
     thd= current_thd;
     thd->thread_stack= (char*) &thd;
-#ifdef HAVE_PSI_INTERFACE
-    thd->m_psi= (PSI_server ? PSI_server->get_thread() : NULL);
-#endif
   }
 }
 #endif /* EMBEDDED_LIBRARY */

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2009-04-07 00:01:45 +0000
+++ b/storage/perfschema/pfs.cc	2009-04-11 04:46:25 +0000
@@ -1113,12 +1113,11 @@ static void set_thread_v1(PSI_thread* th
 {
   PFS_thread *pfs= (PFS_thread*) thread;
   /*
-    Unless the code runs in a degraded mode (thread_lost),
+    Unless the code runs in a degraded mode (thread_info_lost, thread_lost),
     the called should have instrumented something in THD::m_psi.
     This assert will detect incomplete instrumentations in the calling code.
-    FIXME: cleanup all the code before enforcing this.
   */
-  /* DBUG_ASSERT((thread_lost > 0) || (pfs != NULL)); */
+  DBUG_ASSERT((thread_info_lost > 0) || (thread_lost > 0) || (pfs != NULL));
   my_pthread_setspecific_ptr(THR_PFS, pfs);
 }
 

Thread
bzr commit into mysql-6.0-perf branch (marc.alff:2862) Bug#44210Marc Alff11 Apr