zabbix异常之query failed: [1062] Duplicate entry '948905' for key 'PRIMARY
一、zabbix发现query failed: [1062] Duplicate entry '948905' for key 'PRIMARY异常
查看zabbix server log发现如下异常
1 29049:20200916:084034.399 [Z3005] query failed: [1062] Duplicate entry '948905' for key 'PRIMARY' [insert into event_recovery (eventid,r_eventid,correlationid,c_eventid,userid) values (10171139,10179838,null,null,null),(948905,10179836,null,null,null),(10168455,10179832,null,null,null),(10168466,10179839,null,null,null),(10175915,10179836,null,null,null),(859256,10179831,null,null,null),(836795,10179832,null,null,null),(948904,10179829,null,null,null),(10171138,10179831,null,null,null),(10175914,10179829,null,null,null),(859260,10179838,null,null,null),(836798,10179839,null,null,null); 2 ] 3 29049:20200916:084034.406 [Z3005] query failed: [1062] Duplicate entry '948905' for key 'PRIMARY' [insert into event_recovery (eventid,r_eventid,correlationid,c_eventid,userid) values (948905,10179845,null,null,null),(10168455,10179844,null,null,null),(10168466,10179848,null,null,null),(1064453,10179846,null,null,null),(1064451,10179842,null,null,null),(10175915,10179845,null,null,null),(836795,10179844,null,null,null),(10168465,10179847,null,null,null),(948904,10179841,null,null,null),(10168454,10179843,null,null,null),(1647623,10179843,null,null,null),(10168453,10179842,null,null,null),(10175914,10179841,null,null,null),(1647625,10179847,null,null,null),(10168464,10179846,null,null,null),(836798,10179848,null,null,null); 4 ] 5 29049:20200916:084034.414 [Z3005] query failed: [1062] Duplicate entry '859256' for key 'PRIMARY' [insert into event_recovery (eventid,r_eventid,correlationid,c_eventid,userid) values (10171139,10179850,null,null,null),(859256,10179849,null,null,null),(10171138,10179849,null,null,null),(859260,10179850,null,null,null); 6 ] 7 29051:20200916:084035.912 [Z3005] query failed: [1062] Duplicate entry '890157' for key 'PRIMARY' [insert into event_recovery (eventid,r_eventid,correlationid,c_eventid,userid) values (890155,10179851,null,null,null),(890157,10179853,null,null,null),(1891097,10179852,null,null,null),(10168776,10179853,null,null,null),(1891098,10179854,null,null,null),(10168942,10179852,null,null,null),(10168775,10179851,null,null,null),(10168943,10179854,null,null,null); 8 ] 9 29050:20200916:084039.438 [Z3005] query failed: [1062] Duplicate entry '857904' for key 'PRIMARY' [insert into event_recovery (eventid,r_eventid,correlationid,c_eventid,userid) values (10168892,10179855,null,null,null),(10168893,10179856,null,null,null),(857903,10179855,null,null,null),(857904,10179856,null,null,null); 10 ]
二、处理办法
SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `event_recovery`; CREATE TABLE `event_recovery` ( `eventid` bigint(20) unsigned NOT NULL, `r_eventid` bigint(20) unsigned NOT NULL, `c_eventid` bigint(20) unsigned DEFAULT NULL, `correlationid` bigint(20) unsigned DEFAULT NULL, `userid` bigint(20) unsigned DEFAULT NULL, PRIMARY KEY (`eventid`), KEY `event_recovery_1` (`r_eventid`), KEY `event_recovery_2` (`c_eventid`), CONSTRAINT `c_event_recovery_1` FOREIGN KEY (`eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE, CONSTRAINT `c_event_recovery_2` FOREIGN KEY (`r_eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE, CONSTRAINT `c_event_recovery_3` FOREIGN KEY (`c_eventid`) REFERENCES `events` (`eventid`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; SET FOREIGN_KEY_CHECKS=1;