config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/ndb/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/ndb/t/ndb_dd_restore_check_tablespace_mdl.test

# Bug#20676000 FAILING MDL TABLESPACE ASSERTION FOR ALTER NDB TABLE IN UNIREG.CC:263
#
# For mysql versions before 50120, NDB stored the tablespace names only
# in the NDB dictionary. Thus, in order to acquire an MDL lock on the
# tablespace name, the server has to get the name from the engine rather
# than the .FRM file in this case. This test verifies that restoring an
# NDB table with version < 50120, followed by various SQL commands,
# will lock the tablespace name properly.
#
# We do various SQL statements in a separate connection, and verify that
# each statement grabs an MDL lock on the tablespace name. We create
# a new connection each time to verify that this works even if getting
# the tablespace name from NDB is the first function in NDB being invoked
# for the given connection. Between each SQL statement that is tested,
# we must drop the restored database items and restore over again,
# because the DDL statements will write the meta data according to the
# target mysql version, and not the backed up version < 50120 (which is
# what we want to test in this context).

--source include/have_ndb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_perfschema.inc

--enable_connect_log

# Directory containing the saved backup files
let $backup_data_dir=$MYSQL_TEST_DIR/suite/ndb/backups;

--echo #################################################################
--echo # Test DDL statement 1: ALTER TABLE.

--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
SHOW CREATE TABLE t1;

--connect (con1, localhost, root)

SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--echo # Sending 'ALTER TABLE t1 ADD COLUMN c int;'
--send ALTER TABLE t1 ADD COLUMN c int;

--echo # Verify that the tablespace name is locked.
--connection default

SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts';
--source include/wait_condition.inc

SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'ALTER TABLE t1 ADD COLUMN c int;'
--reap
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default

SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB;
DROP TABLESPACE ts ENGINE NDB;
DROP LOGFILE GROUP lg ENGINE NDB;

--echo #################################################################
--echo # Test DDL statement 2: RENAME TABLE.
--echo # Disabled due to failing assert in ndb.

#--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
#--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
#SHOW CREATE TABLE t1;
#
#--connect (con1, localhost, root)
#
#SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
#  SIGNAL got_lock
#  WAIT_FOR cont';
#--echo # Sending 'RENAME TABLE t1 TO t2;'
#--send RENAME TABLE t1 TO t2;
#
#--echo # Verify that the tablespace name is locked.
#--connection default
#
#SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
#LET $wait_condition=
#  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
#    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts';
#--source include/wait_condition.inc
#
#SET DEBUG_SYNC= 'now SIGNAL cont';
#
#--connection con1
#--echo # Reaping 'RENAME TABLE t1 TO t2;'
#--reap
#--disconnect con1
#--source include/wait_until_disconnected.inc
#--connection default
#
#SET DEBUG_SYNC= 'RESET';
#DROP TABLE t2;
#ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB;
#DROP TABLESPACE ts ENGINE NDB;
#DROP LOGFILE GROUP lg ENGINE NDB;

--echo #################################################################
--echo # Test DDL statement 3: TRUNCATE TABLE.

--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
SHOW CREATE TABLE t1;

--connect (con1, localhost, root)

SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--echo # Sending 'TRUNCATE TABLE t1;'
--send TRUNCATE TABLE t1;

--echo # Verify that the tablespace name is locked.
--connection default

SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts';
--source include/wait_condition.inc

SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'TRUNCATE TABLE t1;'
--reap
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default

SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB;
DROP TABLESPACE ts ENGINE NDB;
DROP LOGFILE GROUP lg ENGINE NDB;

--echo #################################################################
--echo # Test DDL statement 4: DROP TABLE.

--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
SHOW CREATE TABLE t1;

--connect (con1, localhost, root)

SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--echo # Sending 'DROP TABLE t1;'
--send DROP TABLE t1;

--echo # Verify that the tablespace name is locked.
--connection default

SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts';
--source include/wait_condition.inc

SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'DROP TABLE t1;'
--reap
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default

SET DEBUG_SYNC= 'RESET';
ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB;
DROP TABLESPACE ts ENGINE NDB;
DROP LOGFILE GROUP lg ENGINE NDB;

--echo #################################################################
--echo # Test DDL statement 5: ALTER TABLE, but now use the default
--echo # connection to verify that repeated use of the same connection
--echo # works too. In this case, we skip the verification of MDL lock
--echo # acquisition, since it has already been tested above.

--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT
--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT

SHOW CREATE TABLE t1;
ALTER TABLE t1 ADD COLUMN c int;
SHOW CREATE TABLE t1;

DROP TABLE t1;
ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB;
DROP TABLESPACE ts ENGINE NDB;
DROP LOGFILE GROUP lg ENGINE NDB;

--disable_connect_log


--echo # Bug#21376265 - ENHANCEMENT: ACQUIRE MDL LOCKS ON ALL TABLESPACE
--echo #                REFERRED BY A STATEMENT

# In NDB, LIST, RANGE and HASH partition disabled by default,
# we have to use --new option to enable it.
set new=on;

CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M ENGINE=NDB;

CREATE TABLESPACE ts1
ADD DATAFILE 'datafile1.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 64M
ENGINE NDB;

CREATE TABLE t1 (
  a INT NOT NULL,
  PRIMARY KEY (a)
)
ENGINE=NDB
PARTITION BY RANGE (a)
PARTITIONS 1
(PARTITION P1 VALUES LESS THAN (2) TABLESPACE ts1);


--connect (con1, localhost, root)
set new=on;
--echo #############################################
--echo # Case1: Checking ALTER TABLE
--echo # Sending 'ALTER TABLE t1 ADD COLUMN f int;'
SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--send ALTER TABLE t1 ADD COLUMN f int;

--echo # Verify that the tablespace name is locked.
--connection default
SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts1';
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'ALTER TABLE t1 ADD COLUMN f int;'
--reap

--echo #############################################
--echo # Case2: Checking TRUNCATE TABLE
--echo # Sending 'TRUNCATE TABLE t1;'
SET DEBUG_SYNC= 'RESET';
SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--send TRUNCATE TABLE t1;

--echo # Verify that the tablespace name is locked.
--connection default
SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts1';
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'TRUNCATE TABLE t1'
--reap

#--echo #############################################
#--echo # Case3: RENAME TABLE t1 to t2 crashes NDB server.
#--echo # Search for "Test DDL statement 2: RENAME TABLE" above
#--echo # in the same test file.

--echo #############################################
--echo # Case4: Checking CREATE TABLE

SET DEBUG_SYNC= 'RESET';
SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--send CREATE TABLE t3 (a INT NOT NULL, PRIMARY KEY (a)) ENGINE=NDB PARTITION BY RANGE (a) PARTITIONS 1 (PARTITION P1 VALUES LESS THAN (2) TABLESPACE ts1);


--echo # Verify that the tablespace name is locked.
--connection default
SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts1';
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'CREATE TABLE'
--reap

--echo #############################################
--echo # Case5: Checking CREATE TABLE LIKE

SET DEBUG_SYNC= 'RESET';
SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--send CREATE TABLE t4 LIKE t3;

--echo # Verify that the tablespace name is locked.
--connection default
SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts1';
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'CREATE TABLE LIKE'
--reap

--echo #############################################
--echo # Case6: Checking ALTER TABLE ... PARTITION

CREATE TABLESPACE ts2
ADD DATAFILE 'datafile2.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 64M
ENGINE NDB;

SET DEBUG_SYNC= 'RESET';
SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--send ALTER TABLE t3 ADD PARTITION (PARTITION p2 VALUES LESS THAN (4) TABLESPACE ts2);

--echo # Verify that the tablespace name is locked.
--connection default
SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts2';
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'ALTER TABLE'
--reap

--echo #############################################
--echo # Case7: Checking LOCK TABLE t2 WRITE

SET DEBUG_SYNC= 'RESET';
SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table
  SIGNAL got_lock
  WAIT_FOR cont';
--send LOCK TABLE t3 WRITE

--echo # Verify that the tablespace name is locked.
--connection default
SET DEBUG_SYNC= 'now WAIT_FOR got_lock';
LET $wait_condition=
  SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks
    WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts2';
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL cont';

--connection con1
--echo # Reaping 'LOCK TABLE'
--reap

UNLOCK TABLES;

--disconnect con1
--source include/wait_until_disconnected.inc

--echo # Cleanup
--connection default
set new=off;
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
DROP TABLE t3;
DROP TABLE t4;
ALTER TABLESPACE ts1 DROP DATAFILE 'datafile1.dat' ENGINE NDB;
ALTER TABLESPACE ts2 DROP DATAFILE 'datafile2.dat' ENGINE NDB;
DROP TABLESPACE ts1 ENGINE NDB;
DROP TABLESPACE ts2 ENGINE NDB;
DROP LOGFILE GROUP lg1 ENGINE NDB;


Man Man