summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/t/truncate_crash.test
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-09-06 11:51:50 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-09-07 22:10:03 +0300
commit73ed19e44f57853c01936a4bcb8c4ad8cfb7242c (patch)
tree8f352bff28150f907b73dd7a2f8f11c962450efa /mysql-test/suite/innodb/t/truncate_crash.test
parent8dcacd3b01943746badd26265c5cff6d4d33a121 (diff)
downloadmariadb-git-73ed19e44f57853c01936a4bcb8c4ad8cfb7242c.tar.gz
MDEV-14585 Automatically remove #sql- tables in InnoDB dictionary during recovery
This is a backport of the following commits: commit b4165985c97a4133e19dd99b459dea27f87fbb1b commit 69e88de0fe6dc5312f5d6e7a179a5ab73d60dc43 commit 40f4525f43aba5d579cf55bae2df504001cd04f4 commit 656f66def27b7a2cf42a28f873f1eeef0416aa71 Now that MDEV-14717 made RENAME TABLE crash-safe within InnoDB, it should be safe to drop the #sql- tables within InnoDB during crash recovery. These tables can be one of two things: (1) #sql-ib related to deferred DROP TABLE (follow-up to MDEV-13407) or to table-rebuilding ALTER TABLE...ALGORITHM=INPLACE (since MDEV-14378, only related to the intermediate copy of a table), (2) #sql- related to the intermediate copy of a table during ALTER TABLE...ALGORITHM=COPY We will not drop tables whose name starts with #sql2, because the server can be killed during an ALGORITHM=COPY operation at a point where the original table was renamed to #sql2 but the finished intermediate copy was not yet renamed from #sql- to the original table name. If an old version of MariaDB Server before 10.2.13 (MDEV-11415) was killed while ALTER TABLE...ALGORITHM=COPY was in progress, after recovery there could be undo log records for some records that were inserted into an intermediate copy of the table. Due to these undo log records, InnoDB would resurrect locks at recovery, and the intermediate table would be locked while we are trying to drop it. This would cause a call to row_rename_table_for_mysql(), either from row_mysql_drop_garbage_tables() or from the rollback of a RENAME operation that was part of the ALTER TABLE. row_rename_table_for_mysql(): Do not attempt to parse FOREIGN KEY constraints when renaming from #sql-something to #sql-something-else, because it does not make any sense. row_drop_table_for_mysql(): When deferring DROP TABLE due to locks, do not rename the table if its name already starts with the #sql- prefix, which is what row_mysql_drop_garbage_tables() uses. Previously, the too strict prefix #sql-ib was used, and some tables were renamed unnecessarily.
Diffstat (limited to 'mysql-test/suite/innodb/t/truncate_crash.test')
-rw-r--r--mysql-test/suite/innodb/t/truncate_crash.test22
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/t/truncate_crash.test b/mysql-test/suite/innodb/t/truncate_crash.test
new file mode 100644
index 00000000000..15ba475e0e1
--- /dev/null
+++ b/mysql-test/suite/innodb/t/truncate_crash.test
@@ -0,0 +1,22 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+FLUSH TABLES;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 SET a=1;
+
+connect (wait,localhost,root,,test);
+SET DEBUG_SYNC='after_trx_committed_in_memory SIGNAL c WAIT_FOR ever';
+send TRUNCATE TABLE t1;
+
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR c';
+--let $shutdown_timeout=0
+--source include/restart_mysqld.inc
+disconnect wait;
+
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+DROP TABLE t1;