|
| 1 | +# Bug#20676000 FAILING MDL TABLESPACE ASSERTION FOR ALTER NDB TABLE IN UNIREG.CC:263 |
| 2 | +# |
| 3 | +# For mysql versions before 50120, NDB stored the tablespace names only |
| 4 | +# in the NDB dictionary. Thus, in order to acquire an MDL lock on the |
| 5 | +# tablespace name, the server has to get the name from the engine rather |
| 6 | +# than the .FRM file in this case. This test verifies that restoring an |
| 7 | +# NDB table with version < 50120, followed by various SQL commands, |
| 8 | +# will lock the tablespace name properly. |
| 9 | +# |
| 10 | +# We do various SQL statements in a separate connection, and verify that |
| 11 | +# each statement grabs an MDL lock on the tablespace name. We create |
| 12 | +# a new connection each time to verify that this works even if getting |
| 13 | +# the tablespace name from NDB is the first function in NDB being invoked |
| 14 | +# for the given connection. Between each SQL statement that is tested, |
| 15 | +# we must drop the restored database items and restore over again, |
| 16 | +# because the DDL statements will write the meta data according to the |
| 17 | +# target mysql version, and not the backed up version < 50120 (which is |
| 18 | +# what we want to test in this context). |
| 19 | + |
| 20 | +--source include/have_ndb.inc |
| 21 | +--source include/have_debug.inc |
| 22 | +--source include/have_debug_sync.inc |
| 23 | +--source include/have_perfschema.inc |
| 24 | + |
| 25 | +--enable_connect_log |
| 26 | + |
| 27 | +# Directory containing the saved backup files |
| 28 | +let $backup_data_dir=$MYSQL_TEST_DIR/suite/ndb/backups; |
| 29 | + |
| 30 | +--echo ################################################################# |
| 31 | +--echo # Test DDL statement 1: ALTER TABLE. |
| 32 | + |
| 33 | +--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 34 | +--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 35 | +SHOW CREATE TABLE t1; |
| 36 | + |
| 37 | +--connect (con1, localhost, root) |
| 38 | + |
| 39 | +SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table |
| 40 | + SIGNAL got_lock |
| 41 | + WAIT_FOR cont'; |
| 42 | +--echo # Sending 'ALTER TABLE t1 ADD COLUMN c int;' |
| 43 | +--send ALTER TABLE t1 ADD COLUMN c int; |
| 44 | + |
| 45 | +--echo # Verify that the tablespace name is locked. |
| 46 | +--connection default |
| 47 | + |
| 48 | +SET DEBUG_SYNC= 'now WAIT_FOR got_lock'; |
| 49 | +LET $wait_condition= |
| 50 | + SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks |
| 51 | + WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts'; |
| 52 | +--source include/wait_condition.inc |
| 53 | + |
| 54 | +SET DEBUG_SYNC= 'now SIGNAL cont'; |
| 55 | + |
| 56 | +--connection con1 |
| 57 | +--echo # Reaping 'ALTER TABLE t1 ADD COLUMN c int;' |
| 58 | +--reap |
| 59 | +--disconnect con1 |
| 60 | +--source include/wait_until_disconnected.inc |
| 61 | +--connection default |
| 62 | + |
| 63 | +SET DEBUG_SYNC= 'RESET'; |
| 64 | +DROP TABLE t1; |
| 65 | +ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB; |
| 66 | +DROP TABLESPACE ts ENGINE NDB; |
| 67 | +DROP LOGFILE GROUP lg ENGINE NDB; |
| 68 | + |
| 69 | +--echo ################################################################# |
| 70 | +--echo # Test DDL statement 2: RENAME TABLE. |
| 71 | +--echo # Disabled due to failing assert in ndb. |
| 72 | + |
| 73 | +#--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 74 | +#--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 75 | +#SHOW CREATE TABLE t1; |
| 76 | +# |
| 77 | +#--connect (con1, localhost, root) |
| 78 | +# |
| 79 | +#SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table |
| 80 | +# SIGNAL got_lock |
| 81 | +# WAIT_FOR cont'; |
| 82 | +#--echo # Sending 'RENAME TABLE t1 TO t2;' |
| 83 | +#--send RENAME TABLE t1 TO t2; |
| 84 | +# |
| 85 | +#--echo # Verify that the tablespace name is locked. |
| 86 | +#--connection default |
| 87 | +# |
| 88 | +#SET DEBUG_SYNC= 'now WAIT_FOR got_lock'; |
| 89 | +#LET $wait_condition= |
| 90 | +# SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks |
| 91 | +# WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts'; |
| 92 | +#--source include/wait_condition.inc |
| 93 | +# |
| 94 | +#SET DEBUG_SYNC= 'now SIGNAL cont'; |
| 95 | +# |
| 96 | +#--connection con1 |
| 97 | +#--echo # Reaping 'RENAME TABLE t1 TO t2;' |
| 98 | +#--reap |
| 99 | +#--disconnect con1 |
| 100 | +#--source include/wait_until_disconnected.inc |
| 101 | +#--connection default |
| 102 | +# |
| 103 | +#SET DEBUG_SYNC= 'RESET'; |
| 104 | +#DROP TABLE t2; |
| 105 | +#ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB; |
| 106 | +#DROP TABLESPACE ts ENGINE NDB; |
| 107 | +#DROP LOGFILE GROUP lg ENGINE NDB; |
| 108 | + |
| 109 | +--echo ################################################################# |
| 110 | +--echo # Test DDL statement 3: TRUNCATE TABLE. |
| 111 | + |
| 112 | +--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 113 | +--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 114 | +SHOW CREATE TABLE t1; |
| 115 | + |
| 116 | +--connect (con1, localhost, root) |
| 117 | + |
| 118 | +SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table |
| 119 | + SIGNAL got_lock |
| 120 | + WAIT_FOR cont'; |
| 121 | +--echo # Sending 'TRUNCATE TABLE t1;' |
| 122 | +--send TRUNCATE TABLE t1; |
| 123 | + |
| 124 | +--echo # Verify that the tablespace name is locked. |
| 125 | +--connection default |
| 126 | + |
| 127 | +SET DEBUG_SYNC= 'now WAIT_FOR got_lock'; |
| 128 | +LET $wait_condition= |
| 129 | + SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks |
| 130 | + WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts'; |
| 131 | +--source include/wait_condition.inc |
| 132 | + |
| 133 | +SET DEBUG_SYNC= 'now SIGNAL cont'; |
| 134 | + |
| 135 | +--connection con1 |
| 136 | +--echo # Reaping 'TRUNCATE TABLE t1;' |
| 137 | +--reap |
| 138 | +--disconnect con1 |
| 139 | +--source include/wait_until_disconnected.inc |
| 140 | +--connection default |
| 141 | + |
| 142 | +SET DEBUG_SYNC= 'RESET'; |
| 143 | +DROP TABLE t1; |
| 144 | +ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB; |
| 145 | +DROP TABLESPACE ts ENGINE NDB; |
| 146 | +DROP LOGFILE GROUP lg ENGINE NDB; |
| 147 | + |
| 148 | +--echo ################################################################# |
| 149 | +--echo # Test DDL statement 4: DROP TABLE. |
| 150 | + |
| 151 | +--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 152 | +--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 153 | +SHOW CREATE TABLE t1; |
| 154 | + |
| 155 | +--connect (con1, localhost, root) |
| 156 | + |
| 157 | +SET DEBUG_SYNC= 'after_wait_locked_tablespace_name_for_table |
| 158 | + SIGNAL got_lock |
| 159 | + WAIT_FOR cont'; |
| 160 | +--echo # Sending 'DROP TABLE t1;' |
| 161 | +--send DROP TABLE t1; |
| 162 | + |
| 163 | +--echo # Verify that the tablespace name is locked. |
| 164 | +--connection default |
| 165 | + |
| 166 | +SET DEBUG_SYNC= 'now WAIT_FOR got_lock'; |
| 167 | +LET $wait_condition= |
| 168 | + SELECT COUNT(*) = 1 FROM performance_schema.metadata_locks |
| 169 | + WHERE object_type LIKE 'TABLESPACE' AND object_name LIKE 'ts'; |
| 170 | +--source include/wait_condition.inc |
| 171 | + |
| 172 | +SET DEBUG_SYNC= 'now SIGNAL cont'; |
| 173 | + |
| 174 | +--connection con1 |
| 175 | +--echo # Reaping 'DROP TABLE t1;' |
| 176 | +--reap |
| 177 | +--disconnect con1 |
| 178 | +--source include/wait_until_disconnected.inc |
| 179 | +--connection default |
| 180 | + |
| 181 | +SET DEBUG_SYNC= 'RESET'; |
| 182 | +ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB; |
| 183 | +DROP TABLESPACE ts ENGINE NDB; |
| 184 | +DROP LOGFILE GROUP lg ENGINE NDB; |
| 185 | + |
| 186 | +--echo ################################################################# |
| 187 | +--echo # Test DDL statement 5: ALTER TABLE, but now use the default |
| 188 | +--echo # connection to verify that repeated use of the same connection |
| 189 | +--echo # works too. In this case, we skip the verification of MDL lock |
| 190 | +--echo # acquisition, since it has already been tested above. |
| 191 | + |
| 192 | +--exec $NDB_RESTORE --no-defaults -b 1 -n 1 -p 1 -m -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 193 | +--exec $NDB_RESTORE --no-defaults -e -b 1 -n 2 -p 1 -r $backup_data_dir/51_dd >> $NDB_TOOLS_OUTPUT |
| 194 | + |
| 195 | +SHOW CREATE TABLE t1; |
| 196 | +ALTER TABLE t1 ADD COLUMN c int; |
| 197 | +SHOW CREATE TABLE t1; |
| 198 | + |
| 199 | +DROP TABLE t1; |
| 200 | +ALTER TABLESPACE ts DROP DATAFILE 'datafile.dat' ENGINE NDB; |
| 201 | +DROP TABLESPACE ts ENGINE NDB; |
| 202 | +DROP LOGFILE GROUP lg ENGINE NDB; |
| 203 | + |
| 204 | +--disable_connect_log |
0 commit comments