List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:March 9 2011 10:19am
Subject:bzr commit into mysql-5.5-cluster branch (magnus.blaudd:3240)
View as plain text  
#At file:///C:/mysql/5.5-cluster/ based on revid:magnus.blaudd@stripped

 3240 Magnus Blåudd	2011-03-09
      ndb
       - add ndb_schema_locks_count session variable which counts the number
        of times that a thread takes the "ndb global schema lock"
       - add test to show that all the commands that are configured to take the global schema lock
        updates the counter

    added:
      mysql-test/suite/ndb/r/ndb_global_schema_lock.result
      mysql-test/suite/ndb/t/ndb_global_schema_lock.test
      mysql-test/suite/ndb/t/ndb_init_schema_locks_count.inc
      mysql-test/suite/ndb/t/ndb_schema_locks_count.inc
    modified:
      mysql-test/suite/ndb/r/ndb_basic.result
      sql/ha_ndbcluster.cc
      sql/ndb_global_schema_lock.cc
      sql/ndb_thd_ndb.h
=== modified file 'mysql-test/suite/ndb/r/ndb_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_basic.result	2011-02-16 08:58:32 +0000
+++ b/mysql-test/suite/ndb/r/ndb_basic.result	2011-03-09 10:18:50 +0000
@@ -74,6 +74,7 @@ Ndb_number_of_data_nodes	#
 Ndb_number_of_ready_data_nodes	#
 Ndb_pruned_scan_count	#
 Ndb_scan_count	#
+Ndb_schema_locks_count	#
 SHOW GLOBAL VARIABLES LIKE 'ndb\_%';
 Variable_name	Value
 ndb_autoincrement_prefetch_sz	#

=== added file 'mysql-test/suite/ndb/r/ndb_global_schema_lock.result'
--- a/mysql-test/suite/ndb/r/ndb_global_schema_lock.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/r/ndb_global_schema_lock.result	2011-03-09 10:18:50 +0000
@@ -0,0 +1,31 @@
+CREATE DATABASE test2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+ALTER DATABASE test2 CHARACTER SET latin2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+DROP DATABASE test2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+CREATE TABLE t1(a int not null primary key) ENGINE ndb;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+RENAME TABLE t1 TO t2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+CREATE TABLE t3 LIKE t2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+ALTER TABLE t3 ADD COLUMN b int default NULL;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+INSERT INTO t2 VALUES(1);
+TRUNCATE TABLE t2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+DROP TABLE t2;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+DROP TABLE t3;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1

=== added file 'mysql-test/suite/ndb/t/ndb_global_schema_lock.test'
--- a/mysql-test/suite/ndb/t/ndb_global_schema_lock.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndb_global_schema_lock.test	2011-03-09 10:18:50 +0000
@@ -0,0 +1,48 @@
+-- source include/have_ndb.inc
+
+#
+# Run all the commands which should take the global schema lock
+# and thus increment the ndb_schema_locks_count variable   
+#
+--source ndb_init_schema_locks_count.inc
+CREATE DATABASE test2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+ALTER DATABASE test2 CHARACTER SET latin2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+DROP DATABASE test2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+CREATE TABLE t1(a int not null primary key) ENGINE ndb;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+RENAME TABLE t1 TO t2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+CREATE TABLE t3 LIKE t2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+ALTER TABLE t3 ADD COLUMN b int default NULL;
+--source ndb_schema_locks_count.inc
+
+# Insert a row to truncate
+INSERT INTO t2 VALUES(1);
+
+--source ndb_init_schema_locks_count.inc
+TRUNCATE TABLE t2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+DROP TABLE t2;
+--source ndb_schema_locks_count.inc
+
+--source ndb_init_schema_locks_count.inc
+DROP TABLE t3;
+--source ndb_schema_locks_count.inc

=== added file 'mysql-test/suite/ndb/t/ndb_init_schema_locks_count.inc'
--- a/mysql-test/suite/ndb/t/ndb_init_schema_locks_count.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndb_init_schema_locks_count.inc	2011-03-09 10:18:50 +0000
@@ -0,0 +1,7 @@
+--disable_query_log
+--disable_result_log
+SELECT @ndb_init_schema_locks_count:=VARIABLE_VALUE
+  FROM information_schema.session_status
+  WHERE variable_name like 'NDB_SCHEMA_LOCKS_COUNT';
+--enable_query_log
+--enable_result_log

=== added file 'mysql-test/suite/ndb/t/ndb_schema_locks_count.inc'
--- a/mysql-test/suite/ndb/t/ndb_schema_locks_count.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndb_schema_locks_count.inc	2011-03-09 10:18:50 +0000
@@ -0,0 +1,5 @@
+--disable_query_log
+SELECT @ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+  FROM information_schema.session_status
+  WHERE variable_name like 'NDB_SCHEMA_LOCKS_COUNT';
+--enable_query_log

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-03-09 08:14:40 +0000
+++ b/sql/ha_ndbcluster.cc	2011-03-09 10:18:50 +0000
@@ -385,6 +385,7 @@ struct st_ndb_status {
   long execute_count;
   long scan_count;
   long pruned_scan_count;
+  long schema_locks_count;
   long transaction_no_hint_count[MAX_NDB_NODES];
   long transaction_hint_count[MAX_NDB_NODES];
   long long api_client_stats[Ndb::NumClientStatistics];
@@ -444,6 +445,7 @@ static int update_status_variables(Thd_n
     {
       ns->api_client_stats[i] = thd_ndb->ndb->getClientStat(i);
     }
+    ns->schema_locks_count= thd_ndb->schema_locks_count;
   }
   return 0;
 }
@@ -518,6 +520,7 @@ SHOW_VAR ndb_status_variables_dynamic[]=
   {"execute_count",      (char*) &g_ndb_status.execute_count,         SHOW_LONG},
   {"scan_count",         (char*) &g_ndb_status.scan_count,            SHOW_LONG},
   {"pruned_scan_count",  (char*) &g_ndb_status.pruned_scan_count,     SHOW_LONG},
+  {"schema_locks_count", (char*) &g_ndb_status.schema_locks_count,    SHOW_LONG},
   NDBAPI_COUNTERS("_session", &g_ndb_status.api_client_stats),
   {NullS, NullS, SHOW_LONG}
 };
@@ -989,7 +992,8 @@ uchar *thd_ndb_share_get_key(THD_NDB_SHA
 }
 
 Thd_ndb::Thd_ndb(THD* thd) :
-  m_thd(thd)
+  m_thd(thd),
+  schema_locks_count(0)
 {
   connection= ndb_get_cluster_connection();
   m_connect_count= connection->get_connect_count();

=== modified file 'sql/ndb_global_schema_lock.cc'
--- a/sql/ndb_global_schema_lock.cc	2011-03-09 07:31:29 +0000
+++ b/sql/ndb_global_schema_lock.cc	2011-03-09 10:18:50 +0000
@@ -272,6 +272,12 @@ ndbcluster_global_schema_lock(THD *thd,
     {
       sql_print_information("NDB: Global schema lock acquired");
     }
+
+    // Count number of global schema locks taken by this thread
+    thd_ndb->schema_locks_count++;
+    DBUG_PRINT("info", ("schema_locks_count: %d",
+                        thd_ndb->schema_locks_count));
+
     DBUG_RETURN(0);
   }
 

=== modified file 'sql/ndb_thd_ndb.h'
--- a/sql/ndb_thd_ndb.h	2011-03-08 22:24:14 +0000
+++ b/sql/ndb_thd_ndb.h	2011-03-09 10:18:50 +0000
@@ -109,6 +109,7 @@ public:
   NdbTransaction *global_schema_lock_trans;
   uint global_schema_lock_count;
   uint global_schema_lock_error;
+  uint schema_locks_count; // Number of global schema locks taken by thread
   bool has_required_global_schema_lock(const char* func);
 
   unsigned m_connect_count;

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20110309101850-oa01x0lamvcsztl5.bundle
Thread
bzr commit into mysql-5.5-cluster branch (magnus.blaudd:3240) Magnus Blåudd9 Mar