硬盘空间满导致mysql ibd文件被删后提示Tablespace is missing for table 'db_rsk/XXX"

昨天一早,开发人员反馈说一个测试环境报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。

找到问题了,解决就方便了,找个备份,把这张表重新导入进去就可以了。

补充:如果重新创建的时候出现类似“ "db_rsk"."tb_rsk_compliancecalcservice"”已存在的提示,drop的时候又出现unkown table "db_rsk"."tb_rsk_compliancecalcservice"的情况,则先删除data目录下对应表的ibd和frm文件,然后使用mysqladmin shutdown, mysqld_safe干净的重启,不要kill -9。否则,该错误可能会一直存在。

这说回来,mysql的容错程度比oracle好多了,oracle异常后恢复的时候经常要resetlogs,有些时候连resetlogs也会失败。

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券