【问题现象】web页面错误
500 状态错误码 received on GET method for API: /api/v1/clusters/hbcm_ocdp/alerts?format=groupedSummary
【后台日志】
【问题分析】
告警查询以alert_current表为入口,然后再关联alert_history表的详细信息进行前端展现。
经过确认alert_current表中有1099条记录在alert_history中没有对应的关联数据,所以查询的时候会报错;
select count() from alert_current;
select count() from alert_current current, alert_history history where current.history_id=history.alert_id;
select alert_id
from alert_current
where alert_id not in
(
select current.alert_id
from alert_current current, alert_history history
where current.history_id=history.alert_id
);
【解决方案】建议清除alert_current表中相关记录
delete from alert_current
where alert_id not in
(
select current.alert_id
from alert_current current, alert_history history
where current.history_id=history.alert_id
);
注: 如果有外键检查先执行set foreign_key_checks=0;