Commit c5a5eaa9 authored by Eugene Kosov's avatar Eugene Kosov Committed by Marko Mäkelä

MDEV-17470 Orphan temporary files after interrupted ALTER cause InnoDB:...

MDEV-17470 Orphan temporary files after interrupted ALTER cause InnoDB: Operating system error number 17 and eventual fatal error 71

Orphan #sql* tables may remain after ALTER TABLE
was interrupted by timeout or KILL or client disconnect.

This is a regression caused by MDEV-16515.

Similar to temporary tables (MDEV-16647), we had better ignore the
KILL when dropping the original table in the final part of ALTER TABLE.

Closes #1020
parent 9ad1663f
...@@ -68,3 +68,24 @@ SET DEBUG_SYNC = 'now SIGNAL S2'; ...@@ -68,3 +68,24 @@ SET DEBUG_SYNC = 'now SIGNAL S2';
ERROR 23000: Duplicate entry '1' for key 'a' ERROR 23000: Duplicate entry '1' for key 'a'
SET DEBUG_SYNC='RESET'; SET DEBUG_SYNC='RESET';
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-17470 Orphan temporary files after interrupted ALTER
# cause InnoDB: Operating system error number 17 and eventual
# fatal error 71
#
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8);
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
LOCK TABLE t1 READ;
SET max_statement_time= 1;
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
SET DEBUG_SYNC = 'now SIGNAL stop_waining';
SET DEBUG_SYNC = 'now WAIT_FOR stop_waining';
UNLOCK TABLES;
DROP TABLE t1;
SET DEBUG_SYNC = 'RESET';
...@@ -100,3 +100,31 @@ DROP TABLE t1; ...@@ -100,3 +100,31 @@ DROP TABLE t1;
# Wait till all disconnects are completed # Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
--echo #
--echo # MDEV-17470 Orphan temporary files after interrupted ALTER
--echo # cause InnoDB: Operating system error number 17 and eventual
--echo # fatal error 71
--echo #
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8);
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
INSERT INTO t1 SELECT NULL, i FROM t1;
LOCK TABLE t1 READ;
--connect (con1,localhost,root,,test)
SET max_statement_time= 1;
--error ER_STATEMENT_TIMEOUT
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
SET DEBUG_SYNC = 'now SIGNAL stop_waining';
--disconnect con1
--connection default
SET DEBUG_SYNC = 'now WAIT_FOR stop_waining';
UNLOCK TABLES;
DROP TABLE t1;
SET DEBUG_SYNC = 'RESET';
...@@ -4224,9 +4224,10 @@ row_drop_table_for_mysql( ...@@ -4224,9 +4224,10 @@ row_drop_table_for_mysql(
calling btr_search_drop_page_hash_index() while we calling btr_search_drop_page_hash_index() while we
hold the InnoDB dictionary lock, we will drop any hold the InnoDB dictionary lock, we will drop any
adaptive hash index entries upfront. */ adaptive hash index entries upfront. */
const bool is_temp = dict_table_is_temporary(table)
|| strstr(tablename_minus_db, tmp_file_prefix);
while (buf_LRU_drop_page_hash_for_tablespace(table)) { while (buf_LRU_drop_page_hash_for_tablespace(table)) {
if ((!dict_table_is_temporary(table) if ((!is_temp && trx_is_interrupted(trx))
&& trx_is_interrupted(trx))
|| srv_shutdown_state != SRV_SHUTDOWN_NONE) { || srv_shutdown_state != SRV_SHUTDOWN_NONE) {
err = DB_INTERRUPTED; err = DB_INTERRUPTED;
goto funct_exit; goto funct_exit;
......
...@@ -4234,9 +4234,10 @@ row_drop_table_for_mysql( ...@@ -4234,9 +4234,10 @@ row_drop_table_for_mysql(
calling btr_search_drop_page_hash_index() while we calling btr_search_drop_page_hash_index() while we
hold the InnoDB dictionary lock, we will drop any hold the InnoDB dictionary lock, we will drop any
adaptive hash index entries upfront. */ adaptive hash index entries upfront. */
const bool is_temp = dict_table_is_temporary(table)
|| strstr(tablename_minus_db, tmp_file_prefix);
while (buf_LRU_drop_page_hash_for_tablespace(table)) { while (buf_LRU_drop_page_hash_for_tablespace(table)) {
if ((!dict_table_is_temporary(table) if ((!is_temp && trx_is_interrupted(trx))
&& trx_is_interrupted(trx))
|| srv_shutdown_state != SRV_SHUTDOWN_NONE) { || srv_shutdown_state != SRV_SHUTDOWN_NONE) {
err = DB_INTERRUPTED; err = DB_INTERRUPTED;
goto funct_exit; goto funct_exit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment