MySQL table does not exist

MySQLsql

I am getting following error in err file.

110803  6:51:26  InnoDB: Error: table `ims`.`temp_discoveryjobdetails` already exists in InnoDB internal
InnoDB: data dictionary. Have you deleted the .frm file
InnoDB: and not used DROP TABLE? Have you used DROP DATABASE
InnoDB: for InnoDB tables in MySQL version <= 3.23.43?
InnoDB: See the Restrictions section of the InnoDB manual.
InnoDB: You can drop the orphaned table inside InnoDB by
InnoDB: creating an InnoDB table with the same name in another
InnoDB: database and copying the .frm file to the current database.
InnoDB: Then MySQL thinks the table exists, and DROP TABLE will
InnoDB: succeed.
InnoDB: You can look for further help from
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html

And when I do the same, like copying the frm file from other database to here and drop the table, i am getting following error,

InnoDB: Error: trying to load index PRIMARY for table ims/temp_discoveryjobdetails
InnoDB: but the index tree has been freed!
110803  6:50:26  InnoDB: Error: table `ims`.`temp_discoveryjobdetails` does not exist in the InnoDB internal
InnoDB: data dictionary though MySQL is trying to drop it.
InnoDB: Have you copied the .frm file of the table to the
InnoDB: MySQL database directory from another database?
InnoDB: You can look for further help from
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html

Please any one help me out of this.
Also can any one tell me why this error is coming.

EDIT:

The issue is occurring only when disk size is full and when we use Truncate table.
Also this is occurring only in 5.1 version but not in 5.0 version.

Best Answer

Tried this? http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting-datadict.html

A specific issue with tables is that the MySQL server keeps data dictionary information in .frm files it stores in the database directories, whereas InnoDB also stores the information into its own data dictionary inside the tablespace files. If you move .frm files around, or if the server crashes in the middle of a data dictionary operation, the locations of the .frm files may end up out of synchrony with the locations recorded in the InnoDB internal data dictionary.