MariaDB 遇到个奇怪的现象,空表无缘无故消失、

2021-09-11 11:00:38 +08:00
 s609926202

例表:t_table,表中无数据。

生产环境下( MySQL )这个表一切正常,我本地环境下( MariaDB 10.4.10-MariaDB-log )都出现好几次表无缘无故消失不见(只剩 .ibd 文件,.frm 文件消失了)。

表结构如下:

CREATE TABLE `t_table` (
  `id` char(36) NOT NULL,
  `assem_ref` varchar(20) NOT NULL,
  `as_id` char(36) NOT NULL,
  `goods_id` char(36) NOT NULL,
  `period` varchar(20) NOT NULL DEFAULT '',
  `in_date` date DEFAULT NULL,
  `in_pici` varchar(20) NOT NULL,
  `in_count` int(20) unsigned NOT NULL,
  `in_count_total` int(20) unsigned NOT NULL,
  `cost_price` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_material` decimal(18,2) unsigned NOT NULL,
  `cost_labor` decimal(18,2) unsigned NOT NULL,
  `cost_prod` decimal(18,2) unsigned NOT NULL',
  `input_user_id` char(36) NOT NULL,
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT NULL,
  `cost_fuli` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_power` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_low_value` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_house` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_depr` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_leasing` decimal(18,2) NOT NULL,
  `cost_soft` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_dev` decimal(18,2) NOT NULL DEFAULT '0.00',
  `cost_init_material` decimal(18,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;

当用 drop table t_table 时,提示:Unknown table 't_table',但是在数据目录下还有 t_table.ibd 文件存在,对应的 .ifm 消失了。

删除 t_table.ibd 文件后,重新建表时又提示:Table 't_table' already exists,t_table.ibd 文件自动恢复了、、

大家有遇到这种情况吗?求解是什么导致的,因为只有这一张表隔三差五出现这个问题。

1275 次点击
所在节点    数据库
5 条回复
westoy
2021-09-11 11:04:09 +08:00
你硬盘有可能要不行了
singerll
2021-09-11 11:56:19 +08:00
mysql 的系统表是有这个 bug,动不动看不到。
s609926202
2021-09-11 12:10:32 +08:00
@westoy 只有这一张表有问题
gBurnX
2021-09-12 02:48:02 +08:00
1.OS ?

2.OS version ?

3.MariaDB version ?

4.SELinux 关闭没?

5.MariaDB 安装方式?

6.MariaDB 安装时有没有指派特殊账号?

7.MariaDB 数据目录的权限 对于 MariaDB 服务的进程的账号,有没有限制?

8.有没有监控 MariaDB 所有的 SQL,从里面提取"DROP TABLE"关键字?

9.有没有联合监控 SQL 与.frm 文件,在.frm 消失时,最近 10 秒内的 SQL ?

如果还不行,万不得已就只能走非常麻烦的带源码调试了,这种方式的麻烦程度接近于反汇编,虽然一定能找到结果,但巨麻烦。
lolizeppelin
2021-09-22 14:18:09 +08:00
看 change log 中 bug 修复有没有相关的

用官方稳定版. 10.4 的是 10.4.21

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/801192

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX