MySQL中SELECT单列结果行数多于SELECT *的异常问题排查
Zabbix数据库maintenances表索引损坏异常
表结构信息
Zabbix的MySQL数据库中maintenances表结构如下:
| maintenanceid | name | maintenance_type | description | active_since | active_till | tags_evaltype |
|---|---|---|---|---|---|---|
| 122 | XXXXXXXXXXXXXXX | 0 | 1647298800 | 2057612400 | 0 | |
| 124 | YYYYYYYYYYYYYY | 0 | 1671656400 | 1671663600 | 0 |
查询异常表现
- 执行语句
SELECT * FROM maintenances;返回18行数据:18 rows in set (0.001 sec)
- 执行语句
SELECT name FROM maintenances;却返回37行数据:37 rows in set (0.001 sec)
表创建语句
CREATE TABLE `maintenances` ( `maintenanceid` bigint(20) unsigned NOT NULL, `name` varchar(128) NOT NULL DEFAULT '', `maintenance_type` int(11) NOT NULL DEFAULT 0, `description` text NOT NULL, `active_since` int(11) NOT NULL DEFAULT 0, `active_till` int(11) NOT NULL DEFAULT 0, `tags_evaltype` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`maintenanceid`), UNIQUE KEY `maintenances_2` (`name`), KEY `maintenances_1` (`active_since`,`active_till`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
表损坏检查结果
执行CHECK TABLE maintenances;命令后,确认表存在损坏:
| Table | Op | Msg_type | Msg_text |
|---|---|---|---|
| zabbix.maintenances | check | Warning | InnoDB: Index 'maintenances_2' contains 37 entries, should be 18. |
| zabbix.maintenances | check | error | Corrupt |
使用的数据库版本
mysql Ver 15.1 Distrib 10.5.18-MariaDB, for debian-linux-gnu
内容的提问来源于stack exchange,提问作者daniel
相关产品推荐
相关产品推荐

