昨天一早,开发人员反馈说一个测试环境报Tablespace is missing for table 'db_rsk/XXX",周末刚升级过,特地让开发回去查了下,说脚本中肯定没有drop table的操作。datadir下检查了下,发现frm文件在的ibd文件没有了,bing了下,没发现类似异常。于是先回到mysql.err往回搜索,半天后发现上周五下午mysql出现了一次异常宕机,说是磁盘空间不足了,看日志该文件被损坏了,如下:
2016-11-12 11:31:00 28443 [ERROR] Error writing file '/usr/local/Percona-Server-5.6.30-rel76.3-Linux.x86_64.ssl101/data/tmp-demo-slow.log' (errno: 1 - No space left on device)
2016-11-12 11:40:00 7fc9c995c700 InnoDB: Error: Write to file ./db_rsk/tb_rsk_compliancecalcservice.ibd failed at offset 0.
InnoDB: 65536 bytes should have been written, only 0 were written.
InnoDB: Operating system error number 28.
InnoDB: Check that your OS and file system support files of this size.
InnoDB: Check also that the disk is not full or a disk quota exceeded.
InnoDB: Error number 28 means 'No space left on device'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
2016-11-12 11:40:00 28443 [ERROR] InnoDB: TRUNCATE TABLE db_rsk/tb_rsk_compliancecalcservice failed to create a new tablespace
2016-11-12 11:40:00 7fc9c995c700 InnoDB: cannot calculate statistics for table "db_rsk"."tb_rsk_compliancecalcservice" because the .ibd file is missing. For help, please refer to http://dev.mysql.com/doc/refma
n/5.6/en/innodb-troubleshooting.html
随后后台就一直报 ibd file is missing。
找到问题了,解决就方便了,找个备份,把这张表重新导入进去就可以了。
这说回来,mysql的容错程度比oracle好多了,oracle异常后恢复的时候经常要resetlogs,有些时候连resetlogs也会失败。