Bug #37648 Changing storage engine to ARCHIVE in 5.1 loses data if disk fills up
Submitted: 26 Jun 2008 0:48 Modified: 22 Jul 2008 11:44
Reporter: Alex Tomic Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Archive storage engine Severity:S2 (Serious)
Version:5.1.25 OS:Linux (CentOS 5)
Assigned to: CPU Architecture:Any
Tags: archive, regression

[26 Jun 2008 0:48] Alex Tomic
Description:
Changing a table to ARCHIVE storage engine loses original table data if disk fills up during the conversion process. The statement returns a "-1" storage engine error.

Originally encountered the issue with a partitioned table, but I have confirmed the issue exists with non-partitioned tables. I was not able to reproduce the issue on 5.0.51.

How to repeat:
Converting from MyISAM to Archive using the statement below returns a strange error:

mysql> alter table widgets engine = Archive;
ERROR 1030 (HY000): Got error -1 from storage engine

Looking on the filesystem in my test case during the conversion process:

[atomic@dev-atomic2 corp]$ ls -lh
total 116M
-rw-rw---- 1 atomic atomic  11K Jun 25 15:57 widgets.frm
-rw-rw---- 1 atomic atomic 116M Jun 25 15:58 widgets.MYD
-rw-rw---- 1 atomic atomic 1.0K Jun 25 15:58 widgets.MYI
[atomic@dev-atomic2 corp]$ ls -lh
total 118M
-rw-rw---- 1 atomic atomic  11K Jun 25 15:57 widgets.frm
-rw-rw---- 1 atomic atomic 116M Jun 25 15:58 widgets.MYD
-rw-rw---- 1 atomic atomic 1.0K Jun 25 15:58 widgets.MYI
-rw-rw---- 1 atomic atomic 1.9M Jun 25 15:58 #sql-696d_6.ARZ
-rw-rw---- 1 atomic atomic  11K Jun 25 15:58 #sql-696d_6.frm
[atomic@dev-atomic2 corp]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       19G   18G  6.2M 100% /
/dev/sda1              99M   11M   83M  12% /boot
tmpfs                 320M     0  320M   0% /dev/shm
[atomic@dev-atomic2 corp]$ ls -lh
total 12M
-rw-rw---- 1 atomic atomic 12M Jun 25 15:59 widgets.ARZ
-rw-rw---- 1 atomic atomic 11K Jun 25 15:58 widgets.frm

The error is thrown before the table completes conversion, but the ARZ file remains, not the myisam files, and the table is inaccessible.

For fun, I verified that a change to InnoDB is stopped correctly:

mysql> alter table widgets engine = innodb;
ERROR 1114 (HY000): The table '#sql-647c_19' is full

Changing from archive to myisam, when the disk is near-full, causes the statement to hang, but after being killed, the server correctly cleans up.

On 5.0.51a, a correct error is thrown:

mysql> alter table widgets engine = ARCHIVE;
ERROR 1030 (HY000): Got error 28 from storage engine

Suggested fix:
I ran the test scenario with debug enabled and generated a trace file. For some reason, mysqld crashes when run in debug mode rather than throwing the error normally. I will attach the trace along with the bug.

I have not had a chance to dive into the code but will try to do so if I get some time. Want to report the issue here first so that others may be warned -- I lost a ton of data on a test environment due to this! Luckily I can recover the data.
[26 Jun 2008 0:51] Alex Tomic
Trace of failed conversion to archive storage engine

Attachment: bug37648-trace.gz (application/x-gzip, text), 404.77 KiB.