debugsqlMinor
ERROR Cannot find or open table?
Viewed 0 times
cannoterroropenfindtable
Problem
- MySQL version: 5.5.24
Due to the following problem:
mysql> desc reportingdb.v3_zone_date_cpm7k;
ERROR 1146 (42S02): Table 'reportingdb.v3_zone_date_cpm7k' doesn't exist/var/log/mysqld.log
120927 16:57:04 [ERROR] Cannot find or open table reportingdb/v3_zone_date_cpm7k#P#pcurrent_2012926 from
the internal data dictionary of InnoDB though the .frm file for the
table exists. Maybe you have deleted and recreated InnoDB data
files but have forgotten to delete the corresponding .frm files
of InnoDB tables, or you have moved .frm files to another database?
or, the table contains indexes that this version of the engine
doesn't support.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-troubleshooting.html
how you can resolve the problem.(I haven't find out the reason yet)
The table's files are still exist in the datadir:
-rw-rw---- 1 mysql mysql 8932 Sep 26 16:50 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k.frm
-rw-rw---- 1 mysql mysql 84 Sep 26 16:50 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k.par
-rw-rw---- 1 mysql mysql 9437184 Sep 13 17:56 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k#P#MERGER_2012828.ibd
-rw-rw---- 1 mysql mysql 1048576 Sep 27 15:42 /var/lib/mysql/reportingdb/v3_zone_date_cpm7k#P#MERGER_2012926.ibdThis is the table DDL from a month old backup (so the partitions have changed), but for reference:
``
CREATE TABLE v3_zone_date_cpm7k (
campaignid mediumint(9) NOT NULL DEFAULT '0' COMMENT 'sub_campaignid',
zoneid smallint(6) NOT NULL DEFAULT '0',
bannerid mediumint(9) NOT NULL DEFAULT '0',
totalclick mediumint(9) unsigned NOT NULL DEFAULT '0',
realclick mediumint(9) unsigned NOT NULL DEFAULT '0',
clickcharge mediumint(9) NOT NULL DEFAULT '0',
totalview mediumint(9) unsigned NOT NULL DEFAULT '0',
viewcharge mediumint(9) unsigned NOT NULL DEFAULT '0',
dt date NOT NULL DEFAULT '0000-00-00',
partnerid smallint(6) unsigned NOT NULL DEFAULT '0',
KEY ix_zoneid (zSolution
I've spent a bit of time trying to reproduce the error on the partition scheme, but cannot get the exact error with the orphaned table
120927 16:57:04 [ERROR] Cannot find or open table reportingdb/v3_zone_date_cpm7k#P#pcurrent_2012926 from
the internal data dictionary of InnoDB though the .frm file for the
table exists.
By moving the .ibd file for the partition out of the data directory (which it seems somehow has happened), I get an expected error:
[ERROR] MySQL is trying to open a table handle but the .ibd file for
table foo/v3_zone_date_cpm7k#P#pcurrent_2012822 does not exist.
From a chat discussion I know you have an outdated backup file. Barring actually being able to force drop the partition 'pcurrent_2012926' (some data loss), the steps to restore this backup are as follows (a month worth of data loss unfortunately):
The last step is in regards to the error message telling you you have an orphaned table:
This means that there is an orphaned .frm file without a corresponding table inside InnoDB. You can drop the orphaned .frm file by deleting it manually. [src]
I really hope this is not necessary and you can restore the partition by another means. This is a last resort method.
I finally reproduced your initial error. Though it will do little to restore the partition, it might be helpful to understand to keep this from happening in the future (potential issue in how backup/restore process is handled, or how the partitions are created):
-
copy the v3_zone_date_cpm7k files BACK to the datadir
desc v3_zone_date_cpm7k;
[ERROR] Cannot find or open table v3_zone_date_cpm7k#P#p00 from
the internal data dictionary of InnoDB though the .frm file for the
table exists.
120927 16:57:04 [ERROR] Cannot find or open table reportingdb/v3_zone_date_cpm7k#P#pcurrent_2012926 from
the internal data dictionary of InnoDB though the .frm file for the
table exists.
By moving the .ibd file for the partition out of the data directory (which it seems somehow has happened), I get an expected error:
[ERROR] MySQL is trying to open a table handle but the .ibd file for
table foo/v3_zone_date_cpm7k#P#pcurrent_2012822 does not exist.
From a chat discussion I know you have an outdated backup file. Barring actually being able to force drop the partition 'pcurrent_2012926' (some data loss), the steps to restore this backup are as follows (a month worth of data loss unfortunately):
- Take a backup of your main server (just in case!)
- Restore the backup on a different server
- Take a mysqldump of the table:
mysqldump -uuser -p reportingdb v3_zone_date_cpm7k > v3_zone_date_cpm7k.sql
- copy v3_zone_date_cpm7k.sql to the main server
- On the main server, attempt to do this:
DROP TABLE reportingdb.v3_zone_date_cpm7k
- If that works, import your dumpfile:
mysql -uuser -p reportingdb
- If the DROP TABLE
does not work, try moving thev3_zone_date_cpm7k.frmand other files to a different location and restarting the server. Then import the dump file
The last step is in regards to the error message telling you you have an orphaned table:
This means that there is an orphaned .frm file without a corresponding table inside InnoDB. You can drop the orphaned .frm file by deleting it manually. [src]
I really hope this is not necessary and you can restore the partition by another means. This is a last resort method.
I finally reproduced your initial error. Though it will do little to restore the partition, it might be helpful to understand to keep this from happening in the future (potential issue in how backup/restore process is handled, or how the partitions are created):
- I copied the v3_zone_date_cpm7k to a different location (as a backup).
- issue a DROP TABLE v3_zone_date_cpm7k
-
copy the v3_zone_date_cpm7k files BACK to the datadir
desc v3_zone_date_cpm7k;
ERROR 1146 (42S02): Table 'v3_zone_date_cpm7k' doesn't exist`[ERROR] Cannot find or open table v3_zone_date_cpm7k#P#p00 from
the internal data dictionary of InnoDB though the .frm file for the
table exists.
Context
StackExchange Database Administrators Q#25036, answer score: 3
Revisions (0)
No revisions yet.