Skip to content

Commit c5a5eaa

Browse files
kevgsdr-m
authored andcommitted
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
1 parent 9ad1663 commit c5a5eaa

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

mysql-test/suite/innodb/r/innodb-alter-debug.result

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,24 @@ SET DEBUG_SYNC = 'now SIGNAL S2';
6868
ERROR 23000: Duplicate entry '1' for key 'a'
6969
SET DEBUG_SYNC='RESET';
7070
DROP TABLE t1;
71+
#
72+
# MDEV-17470 Orphan temporary files after interrupted ALTER
73+
# cause InnoDB: Operating system error number 17 and eventual
74+
# fatal error 71
75+
#
76+
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB;
77+
INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8);
78+
INSERT INTO t1 SELECT NULL, i FROM t1;
79+
INSERT INTO t1 SELECT NULL, i FROM t1;
80+
INSERT INTO t1 SELECT NULL, i FROM t1;
81+
INSERT INTO t1 SELECT NULL, i FROM t1;
82+
INSERT INTO t1 SELECT NULL, i FROM t1;
83+
LOCK TABLE t1 READ;
84+
SET max_statement_time= 1;
85+
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
86+
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
87+
SET DEBUG_SYNC = 'now SIGNAL stop_waining';
88+
SET DEBUG_SYNC = 'now WAIT_FOR stop_waining';
89+
UNLOCK TABLES;
90+
DROP TABLE t1;
91+
SET DEBUG_SYNC = 'RESET';

mysql-test/suite/innodb/t/innodb-alter-debug.test

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,31 @@ DROP TABLE t1;
100100

101101
# Wait till all disconnects are completed
102102
--source include/wait_until_count_sessions.inc
103+
104+
--echo #
105+
--echo # MDEV-17470 Orphan temporary files after interrupted ALTER
106+
--echo # cause InnoDB: Operating system error number 17 and eventual
107+
--echo # fatal error 71
108+
--echo #
109+
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB;
110+
INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8);
111+
INSERT INTO t1 SELECT NULL, i FROM t1;
112+
INSERT INTO t1 SELECT NULL, i FROM t1;
113+
INSERT INTO t1 SELECT NULL, i FROM t1;
114+
INSERT INTO t1 SELECT NULL, i FROM t1;
115+
INSERT INTO t1 SELECT NULL, i FROM t1;
116+
117+
LOCK TABLE t1 READ;
118+
119+
--connect (con1,localhost,root,,test)
120+
SET max_statement_time= 1;
121+
--error ER_STATEMENT_TIMEOUT
122+
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
123+
SET DEBUG_SYNC = 'now SIGNAL stop_waining';
124+
--disconnect con1
125+
126+
--connection default
127+
SET DEBUG_SYNC = 'now WAIT_FOR stop_waining';
128+
UNLOCK TABLES;
129+
DROP TABLE t1;
130+
SET DEBUG_SYNC = 'RESET';

storage/innobase/row/row0mysql.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,9 +4224,10 @@ row_drop_table_for_mysql(
42244224
calling btr_search_drop_page_hash_index() while we
42254225
hold the InnoDB dictionary lock, we will drop any
42264226
adaptive hash index entries upfront. */
4227+
const bool is_temp = dict_table_is_temporary(table)
4228+
|| strstr(tablename_minus_db, tmp_file_prefix);
42274229
while (buf_LRU_drop_page_hash_for_tablespace(table)) {
4228-
if ((!dict_table_is_temporary(table)
4229-
&& trx_is_interrupted(trx))
4230+
if ((!is_temp && trx_is_interrupted(trx))
42304231
|| srv_shutdown_state != SRV_SHUTDOWN_NONE) {
42314232
err = DB_INTERRUPTED;
42324233
goto funct_exit;

storage/xtradb/row/row0mysql.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4234,9 +4234,10 @@ row_drop_table_for_mysql(
42344234
calling btr_search_drop_page_hash_index() while we
42354235
hold the InnoDB dictionary lock, we will drop any
42364236
adaptive hash index entries upfront. */
4237+
const bool is_temp = dict_table_is_temporary(table)
4238+
|| strstr(tablename_minus_db, tmp_file_prefix);
42374239
while (buf_LRU_drop_page_hash_for_tablespace(table)) {
4238-
if ((!dict_table_is_temporary(table)
4239-
&& trx_is_interrupted(trx))
4240+
if ((!is_temp && trx_is_interrupted(trx))
42404241
|| srv_shutdown_state != SRV_SHUTDOWN_NONE) {
42414242
err = DB_INTERRUPTED;
42424243
goto funct_exit;

0 commit comments

Comments
 (0)