List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:March 28 2011 7:38am
Subject:bzr push into mysql-5.5-cluster branch (magnus.blaudd:3250 to 3251)
View as plain text  
 3251 Magnus Blåudd	2011-03-28
      ndb GSl locking
       - add tests for GSL's behaviour combined with LOCK TABLES

    modified:
      mysql-test/suite/ndb/r/ndb_global_schema_lock.result
      mysql-test/suite/ndb/t/ndb_global_schema_lock.test
 3250 Magnus Blåudd	2011-03-24
      ndb global schema lock
       - Move the locking of GSLl to just befoere taking the EXCLUSIVE MDL lock in the local mysqld, this is
         to avoid deadlocking with another mysqld also holding the EXCLUSIVE lock  and trying to take GSL.
       - NOTE! Don't change TRUNCATE and ALTER code yet....
       - Revert previous change which returned error and aborted the statement if GSL lock could not be taken
        the statement should just get a warning pushed and continue to run. If NDB is involved in the statement
        it will fail there.
       - Update ndb_global_schema_lock_error.test with new behaviour(like it was before). Add tests for how all
        the different statements that  have GSL lock behave if cluster is disconnected.

    modified:
      mysql-test/suite/ndb/r/ndb_global_schema_lock_error.result
      mysql-test/suite/ndb/t/ndb_global_schema_lock_error.test
      sql/ndb_global_schema_lock.cc
      sql/ndb_global_schema_lock_guard.h
      sql/sql_db.cc
      sql/sql_parse.cc
      sql/sql_rename.cc
      sql/sql_table.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_global_schema_lock.result'
--- a/mysql-test/suite/ndb/r/ndb_global_schema_lock.result	2011-03-09 12:12:56 +0000
+++ b/mysql-test/suite/ndb/r/ndb_global_schema_lock.result	2011-03-28 07:34:23 +0000
@@ -32,3 +32,53 @@ DROP TABLE t2;
 DROP TABLE t3, t4;
 @ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
 1
+CREATE TABLE t10(a int primary key) ENGINE ndb;
+LOCK TABLES t10 READ;
+CREATE DATABASE test2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+ALTER DATABASE test2 CHARACTER SET latin2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+DROP DATABASE test2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+LOCK TABLES t10 WRITE;
+CREATE DATABASE test2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+ALTER DATABASE test2 CHARACTER SET latin2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+DROP DATABASE test2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+LOCK TABLES t10 READ;
+CREATE TABLE t1(a int not null primary key);
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+RENAME TABLE t10 TO t2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+CREATE TABLE t3 LIKE t10;
+ERROR HY000: Table 't3' was not locked with LOCK TABLES
+ALTER TABLE t10 ADD COLUMN b int default NULL;
+ERROR HY000: Table 't10' was locked with a READ lock and can't be updated
+TRUNCATE TABLE t10;
+ERROR HY000: Table 't10' was locked with a READ lock and can't be updated
+CREATE TABLE t4 AS SELECT * FROM t10;
+ERROR HY000: Table 't4' was not locked with LOCK TABLES
+DROP TABLE t10;
+ERROR HY000: Table 't10' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+LOCK TABLES t10 WRITE;
+CREATE TABLE t1(a int not null primary key);
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+RENAME TABLE t10 TO t2;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+CREATE TABLE t3 LIKE t10;
+ERROR HY000: Table 't3' was not locked with LOCK TABLES
+ALTER TABLE t10 ADD COLUMN b int default NULL;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+TRUNCATE TABLE t10;
+@ndb_schema_locks_count:=VARIABLE_VALUE-@ndb_init_schema_locks_count
+1
+CREATE TABLE t4 AS SELECT * FROM t10;
+ERROR HY000: Table 't4' was not locked with LOCK TABLES
+DROP TABLE t10;
+UNLOCK TABLES;

=== modified file 'mysql-test/suite/ndb/t/ndb_global_schema_lock.test'
--- a/mysql-test/suite/ndb/t/ndb_global_schema_lock.test	2011-03-09 12:12:56 +0000
+++ b/mysql-test/suite/ndb/t/ndb_global_schema_lock.test	2011-03-28 07:34:23 +0000
@@ -50,3 +50,84 @@ DROP TABLE t2;
 --source ndb_init_schema_locks_count.inc
 DROP TABLE t3, t4;
 --source ndb_schema_locks_count.inc
+
+
+#
+# Testing GSL behaviour combined with LOCK TABLES
+#
+# NOTE! Using LOCK TABLES should not be a way to circumvent
+# global schema locking
+#
+
+CREATE TABLE t10(a int primary key) ENGINE ndb;
+
+#
+# Database DDL with READ lock, should return error
+#
+LOCK TABLES t10 READ;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+CREATE DATABASE test2;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+ALTER DATABASE test2 CHARACTER SET latin2;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+DROP DATABASE test2;
+UNLOCK TABLES;
+
+#
+# Database DDL with WRITE lock, should return error
+#
+LOCK TABLES t10 WRITE;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+CREATE DATABASE test2;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+ALTER DATABASE test2 CHARACTER SET latin2;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+DROP DATABASE test2;
+UNLOCK TABLES;
+
+#
+# Table DDL with READ lock
+#
+LOCK TABLES t10 READ;
+# Catch 22, not possible to lock table until created
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t1(a int not null primary key);
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+RENAME TABLE t10 TO t2;
+# Catch 22, not possible to lock table until created
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t3 LIKE t10;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+ALTER TABLE t10 ADD COLUMN b int default NULL;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+TRUNCATE TABLE t10;
+# Catch 22, not possible to lock table until created
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t4 AS SELECT * FROM t10;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+DROP TABLE t10;
+UNLOCK TABLES;
+
+#
+# Table DDL with WRITE lock
+#
+LOCK TABLES t10 WRITE;
+# Catch 22, not possible to lock table until created
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t1(a int not null primary key);
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+RENAME TABLE t10 TO t2;
+# Catch 22, not possible to lock table until created
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t3 LIKE t10;
+--source ndb_init_schema_locks_count.inc
+ALTER TABLE t10 ADD COLUMN b int default NULL;
+--source ndb_schema_locks_count.inc
+--source ndb_init_schema_locks_count.inc
+TRUNCATE TABLE t10;
+--source ndb_schema_locks_count.inc
+# Catch 22, not possible to lock table until created
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE t4 AS SELECT * FROM t10;
+DROP TABLE t10;
+UNLOCK TABLES;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (magnus.blaudd:3250 to 3251) Magnus Blåudd28 Mar