Bug #60502 Unable to drop databases completely after upgrade from 5.0 to 5.1
Submitted: 17 Mar 2011 8:04 Modified: 18 Mar 2011 10:09
Reporter: Justinas Urbanavičius Email Updates:
Status: Duplicate Impact on me:
Category:MySQL Server Severity:S2 (Serious)
Version:5.1.49-3 OS:Linux (debian stable Linux 2.6.26-2-686)
Assigned to: CPU Architecture:Any
Tags: drop database, risidual ARM files, upgrade

[17 Mar 2011 8:04] Justinas Urbanavičius
After installing mysql-server-5.1 package with aptitude and running mysql_upgrade.
Many databases contained, tables with storage type ARCHIVE, all these tables where marked as corrupt.
mysql_upgrade or any king of repair didn't help. So the tables where Dropped loosing all data and recreated. After this operation each database folder in file system contained residual ARM file. table_name.ARM that wasn't deleted or removed when dropping table. 
When trying to drop any database that previously contained corrupted table, all tables are dropped but the residual ARM file prevents from dropping database itself with error:
Error dropping database (can't rmdir './database_name/', errno: 17)

only workaround solution is to physically delete the ARM file form the file system database folder. Then Drop database statement runs without errors.

How to repeat:
Install mysql-server-5.0, 
Create database which contains 1 MyISAM and 1 ARCHIVE storage type table.
Insert some data to the ARCHIVE storage type table.
then upgrade server package to mysql-server-5.1.
Run mysql_upgrade all ARCHIVE tables will be marked as corrupted with no possible repair options.
Drop table ARCHIVE, create the same ARCHIVE table with the same name.

now /var/lib/mysql/database_name folder should contain free files
of witch ARM shouldn't be there.
DROP database containing these tables, and will get an error.

Suggested fix:
mysql_upgrade should recreate these tables or upgrade them to the new format and remove ARM file.
[17 Mar 2011 8:37] Valeriy Kravchuk
Looks like a duplicate of bug #48633. Please, check.
[17 Mar 2011 11:41] Justinas Urbanavičius
the patch in proposed duplicate bug is version 5.1.39, and i'm using 5.1.49, so i assume this version should already have this patch. but it doesn't.
The issue sounds similar, except for the leftover ARM files, that should have been deleted when the table was dropped.
[17 Mar 2011 12:43] Valeriy Kravchuk
Bug #48633 is NOT closed (still "Verified"), so the patch (if any) is not present in any officially released version of MySQL server. 

The problem is NOT fixed. I think this your report is just yet another (maybe a bit more complicated) case of the same problem.
[17 Mar 2011 13:21] Justinas Urbanavičius
if that's the case, then i'll have to agree with you that this is a bit more complicated but yet the same problem as described in Bug #48633.
[18 Mar 2011 10:09] Valeriy Kravchuk
Let's consider this a duplicate of Bug #48633, at least until it is fixed and we can check if fix solves current problem also.