[MDEV-8142] Temporary files are left behind after in-place ALTER fails Created: 2015-05-11  Updated: 2018-07-16  Resolved: 2018-07-16

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Storage Engine - XtraDB
Affects Version/s: 10.0.19
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Nirbhay Choubey (Inactive) Assignee: Jan Lindström (Inactive)
Resolution: Not a Bug Votes: 1
Labels: SUSE


 Description   

MariaDB [test]> CREATE TABLE t1 (f1 INT NOT NULL, f2 INT NOT NULL) ENGINE=innodb;
Query OK, 0 rows affected (0.09 sec)
 
MariaDB [test]> SET debug_dbug='d,innodb_alter_commit_crash_before_commit';
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [test]> INSERT INTO t1 VALUES(1, 1);
Query OK, 1 row affected (0.16 sec)
 
MariaDB [test]> INSERT INTO t1 VALUES(2, 2);
Query OK, 1 row affected (0.08 sec)
 
MariaDB [test]> ALTER TABLE t1 ADD PRIMARY KEY (f2, f1);
ERROR 2013 (HY000): Lost connection to MySQL server during query
 
.. restart server & reconnect.. 
 
MariaDB [test]> ALTER TABLE t1 ADD PRIMARY KEY (f2, f1);
Query OK, 0 rows affected (0.20 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> SHOW CREATE TABLE t1;
+-------+----------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                           |
+-------+----------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `f1` int(11) NOT NULL,
  `f2` int(11) NOT NULL,
  PRIMARY KEY (`f2`,`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)
 
MariaDB [test]> SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES;
+----------+---------------------------+------+--------+-------+-------------+------------+---------------+
| TABLE_ID | NAME                      | FLAG | N_COLS | SPACE | FILE_FORMAT | ROW_FORMAT | ZIP_PAGE_SIZE |
+----------+---------------------------+------+--------+-------+-------------+------------+---------------+
...
|       19 | test/#sql-ib18-1827491244 |    1 |      5 |     5 | Antelope    | Compact    |             0 |
|       20 | test/t1                   |    1 |      5 |     6 | Antelope    | Compact    |             0 |
+----------+---------------------------+------+--------+-------+-------------+------------+---------------+
9 rows in set (0.00 sec)
 
MariaDB [test]> \! ls data1/test
#sql-426c_3.frm  #sql-ib18-1827491244.ibd  t1.frm  t1.ibd
 

Its a side effect of the following fix :
https://github.com/mysql/mysql-server/commit/ee194ca48f1fe028bf64b861c993b12f4957e2a0

These leftover temp files can later be dropped using DROP TABLE by naming the frm file, but
I think there is some room for automatically dropping these temporary files.

Originally reported here : https://bugzilla.suse.com/show_bug.cgi?id=928172



 Comments   
Comment by Jan Lindström (Inactive) [ 2018-07-16 ]

It is true that temporary files are left behind after in-place ALTER fails, but test case provided uses debug build intentional server crash code that is not available on normal production servers. At restart InnoDB does not automatically delete these temporary files as they may contain important user data. User can then drop those tables (temporary or original) based on his/her needs.

Generated at Thu Feb 08 07:24:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.