mirror of
https://github.com/MariaDB/server.git
synced 2025-06-04 18:03:14 +03:00
If InnoDB is killed while ALTER TABLE...ALGORITHM=COPY is in progress, after recovery there could be undo log records 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.
55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
--source include/have_debug_sync.inc
|
|
--source include/not_embedded.inc
|
|
|
|
LET $datadir= `SELECT @@datadir`;
|
|
|
|
CREATE TABLE t1 (a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB;
|
|
INSERT INTO t1 () VALUES ();
|
|
|
|
--connect (con1,localhost,root,,test)
|
|
SET DEBUG_SYNC='before_rename_table_commit SIGNAL renamed WAIT_FOR ever';
|
|
--send
|
|
RENAME TABLE t1 TO t2;
|
|
--connection default
|
|
SET DEBUG_SYNC='now WAIT_FOR renamed';
|
|
--let $shutdown_timeout=0
|
|
--source include/restart_mysqld.inc
|
|
--disconnect con1
|
|
SELECT * FROM t1;
|
|
|
|
let $c = 999;
|
|
BEGIN;
|
|
--disable_query_log
|
|
while ($c) {
|
|
INSERT INTO t1() VALUES();
|
|
dec $c;
|
|
}
|
|
--enable_query_log
|
|
COMMIT;
|
|
UPDATE t1 SET b=a%7, c=a%11, d=a%13;
|
|
|
|
--source include/expect_crash.inc
|
|
SET DEBUG_DBUG='+d,crash_commit_before';
|
|
--error 2013
|
|
ALTER TABLE t1
|
|
ADD INDEX(b,c,d,a),ADD INDEX(b,c,a,d),ADD INDEX(b,a,c,d),ADD INDEX(b,a,d,c),
|
|
ADD INDEX(b,d,a,c),ADD INDEX(b,d,c,a),ADD INDEX(a,b,c,d),ADD INDEX(a,b,d,c),
|
|
ADD INDEX(a,c,b,d),ADD INDEX(a,c,d,b),ADD INDEX(a,d,b,c),ADD INDEX(a,d,c,b),
|
|
ADD INDEX(c,a,b,d),ADD INDEX(c,a,d,b),ADD INDEX(c,b,a,d),ADD INDEX(c,b,d,a),
|
|
ADD INDEX(c,d,a,b),ADD INDEX(c,d,b,a),ADD INDEX(d,a,b,c),ADD INDEX(d,a,c,b),
|
|
ADD INDEX(d,b,a,c),ADD INDEX(d,b,c,a),ADD INDEX(d,c,a,b),ADD INDEX(d,c,b,a),
|
|
ADD INDEX(a,b,c), ADD INDEX(a,c,b), ADD INDEX(a,c,d), ADD INDEX(a,d,c),
|
|
ADD INDEX(a,b,d), ADD INDEX(a,d,b), ADD INDEX(b,c,d), ADD INDEX(b,d,c),
|
|
ALGORITHM=COPY;
|
|
--source include/start_mysqld.inc
|
|
CHECK TABLE t1;
|
|
SELECT COUNT(*) FROM t1;
|
|
DROP TABLE t1;
|
|
# MDEV-11415 TODO: remove the following
|
|
SET GLOBAL innodb_background_drop_list_empty=
|
|
@@GLOBAL.innodb_background_drop_list_empty;
|
|
# Work around missing crash recovery at the SQL layer.
|
|
--remove_files_wildcard $datadir/test #sql-*.frm
|