summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-12-09 10:42:19 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-12-09 10:42:19 +0200
commit782b2a750067a12be07b9c305ede4d2c28f173e0 (patch)
tree228deca0a3082f87e4b5b4fc0b86c0b7d0927e5c /mysql-test/suite/innodb
parent8f3631d0096ceecc21f2879a9558fd9242f09f8c (diff)
downloadmariadb-git-782b2a750067a12be07b9c305ede4d2c28f173e0.tar.gz
MDEV-29144 ER_TABLE_SCHEMA_MISMATCH or crash on DISCARD/IMPORT
mysql_discard_or_import_tablespace(): On successful ALTER TABLE...DISCARD TABLESPACE, evict the table handle from the table definition cache, so that ha_innobase::close() will be invoked, like InnoDB expects to be the case. This will avoid an assertion failure ut_a(table->get_ref_count() == 0) during IMPORT TABLESPACE. ha_innobase::open(): Do not issue any ER_TABLESPACE_DISCARDED warning. Member functions for DML will do that. ha_innobase::truncate(), ha_innobase::check_if_supported_inplace_alter(): Issue ER_TABLESPACE_DISCARDED warnings, to compensate for the removal of the warning in ha_innobase::open(). row_quiesce_write_indexes(): Only write information about committed indexes. The ALTER TABLE t NOWAIT ADD INDEX(c) in the nondeterministic test case will most of the time fail due to a metadata lock (MDL) timeout and leave behind an uncommitted index. Reviewed by: Sergei Golubchik
Diffstat (limited to 'mysql-test/suite/innodb')
-rw-r--r--mysql-test/suite/innodb/r/import_tablespace_race.result26
-rw-r--r--mysql-test/suite/innodb/t/import_tablespace_race.test54
2 files changed, 80 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/import_tablespace_race.result b/mysql-test/suite/innodb/r/import_tablespace_race.result
new file mode 100644
index 00000000000..786b8cbd261
--- /dev/null
+++ b/mysql-test/suite/innodb/r/import_tablespace_race.result
@@ -0,0 +1,26 @@
+#
+# MDEV-29144 ER_TABLE_SCHEMA_MISMATCH or crash on DISCARD/IMPORT
+#
+CREATE TABLE t (pk int PRIMARY KEY, c varchar(1024))
+ENGINE=InnoDB CHARSET latin1;
+INSERT INTO t SELECT seq, 'x' FROM seq_1_to_100;
+connect con1,localhost,root,,test;
+BEGIN NOT ATOMIC
+DECLARE a INT DEFAULT 0;
+REPEAT
+SET a= a+1;
+UPDATE t SET c = 'xx' WHERE pk = a;
+UNTIL a = 100
+END REPEAT;
+END
+$
+connection default;
+ALTER TABLE t NOWAIT ADD INDEX (c);
+connection con1;
+connection default;
+FLUSH TABLE t FOR EXPORT;
+UNLOCK TABLES;
+DROP TABLE t;
+ALTER TABLE t DISCARD TABLESPACE;
+ALTER TABLE t IMPORT TABLESPACE;
+DROP TABLE t;
diff --git a/mysql-test/suite/innodb/t/import_tablespace_race.test b/mysql-test/suite/innodb/t/import_tablespace_race.test
new file mode 100644
index 00000000000..532c2684dde
--- /dev/null
+++ b/mysql-test/suite/innodb/t/import_tablespace_race.test
@@ -0,0 +1,54 @@
+--source include/have_innodb.inc
+--source include/have_sequence.inc
+
+--echo #
+--echo # MDEV-29144 ER_TABLE_SCHEMA_MISMATCH or crash on DISCARD/IMPORT
+--echo #
+
+CREATE TABLE t (pk int PRIMARY KEY, c varchar(1024))
+ENGINE=InnoDB CHARSET latin1;
+INSERT INTO t SELECT seq, 'x' FROM seq_1_to_100;
+
+--connect (con1,localhost,root,,test)
+--delimiter $
+--send
+ BEGIN NOT ATOMIC
+ DECLARE a INT DEFAULT 0;
+ REPEAT
+ SET a= a+1;
+ UPDATE t SET c = 'xx' WHERE pk = a;
+ UNTIL a = 100
+ END REPEAT;
+ END
+$
+--delimiter ;
+
+--connection default
+--error 0,ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE t NOWAIT ADD INDEX (c);
+
+--connection con1
+--reap
+
+--connection default
+
+--let $datadir= `select @@datadir`
+
+FLUSH TABLE t FOR EXPORT;
+--let $create= query_get_value(SHOW CREATE TABLE t, Create Table, 1)
+--copy_file $datadir/test/t.cfg $MYSQL_TMP_DIR/t.cfg
+--copy_file $datadir/test/t.ibd $MYSQL_TMP_DIR/t.ibd
+UNLOCK TABLES;
+
+DROP TABLE t;
+--disable_query_log
+eval $create;
+--enable_query_log
+
+ALTER TABLE t DISCARD TABLESPACE;
+--move_file $MYSQL_TMP_DIR/t.cfg $datadir/test/t.cfg
+--move_file $MYSQL_TMP_DIR/t.ibd $datadir/test/t.ibd
+ALTER TABLE t IMPORT TABLESPACE;
+
+# Cleanup
+DROP TABLE t;