[ZBX-22659] query failed due to primary key constraint: [1062] Duplicate entry '183334929' for key 'PRIMARY' Created: 2023 Apr 12 Updated: 2023 Jun 22 Resolved: 2023 Jun 22 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 6.0.16 |
Fix Version/s: | None |
Type: | Problem report | Priority: | Trivial |
Reporter: | Marco Hofmann | Assignee: | Elina Kuzyutkina (Inactive) |
Resolution: | Won't fix | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Debian 11 |
Attachments: |
![]() |
Description |
Version is 6.2.7 was we haven't migrated to 6.4, yet. Steps to reproduce:
mysql -u root -p zabbix < /usr/share/zabbix-sql-scripts/mysql/history_pk_prepare.sql This worked without any issues (we know of)
Result: Since then, many, but not all trigger events, don't close anymore. Our event problems list grows bigger every day. Se the following examples of services that are of type 0 running, but the problem persists: In the Zabbix Server log, we see the following error a lot, and I suspect a connection: 1261:20230412:105626.256 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183364615' for key 'PRIMARY' 1260:20230412:105626.258 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183455685' for key 'PRIMARY' 1261:20230412:105630.278 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183491625' for key 'PRIMARY' 1259:20230412:105630.281 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183909559' for key 'PRIMARY' 1260:20230412:105631.287 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183458684' for key 'PRIMARY' 1258:20230412:105631.289 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183618546' for key 'PRIMARY' 1260:20230412:105634.304 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183493894' for key 'PRIMARY' 1261:20230412:105635.306 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183386042' for key 'PRIMARY' 1260:20230412:105637.316 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183780765' for key 'PRIMARY' 1258:20230412:105637.325 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183722694' for key 'PRIMARY' 1259:20230412:105639.320 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183479570' for key 'PRIMARY' 1259:20230412:105639.322 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183491625' for key 'PRIMARY' 1261:20230412:105640.332 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183707372' for key 'PRIMARY' 1258:20230412:105642.344 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183465442' for key 'PRIMARY' 1260:20230412:105644.351 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183894241' for key 'PRIMARY' Expected: Problem Events should close as normal, when the condition is met. Notes: The very first time the issue was in the logs was here, one day before the planned datacenter downtime: 14234:20230406:141103.642 [Z3008] query failed due to primary key constraint: [1062] Duplicate entry '183334929' for key 'PRIMARY' Since then, this error has been logged thousands of times. I know this might be much to ask, but the error message is not helpful at all. Could you please give us any hint, what to search for in the database, so we can start troubleshooting that issue? |
Comments |
Comment by Marco Hofmann [ 2023 Apr 26 ] |
We partly solved that issue. We had millions of unrelated entries in our event table. So eventids were lingering in that table, that shouldn't be there, which prevented issues from being closed. We executed the following query to prune that table from the biggest part of old entries, but not all unnecessary entries have been deleted. DELETE FROM event_recovery WHERE eventid NOT IN (SELECT eventid FROM events); DELETE FROM `event_recovery` WHERE `eventid` IS NOT NULL AND `r_eventid` NOT IN (SELECT `eventid` FROM `events` WHERE `value` = 0); Manually: (DELETE FROM `event_recovery` WHERE eventid = <event ID>) We still don't know where this comes from. But from all I can tell, it had nothing to do with the primary key change, nor the upgrade from 6.0 to 6.2. I'm not sure if it's related to |
Comment by Ricardo Canani [ 2023 May 25 ] |
Would it be related to |
Comment by Elina Kuzyutkina (Inactive) [ 2023 Jun 22 ] |
Hi, Regards, Elina |
Comment by Marco Hofmann [ 2023 Jun 22 ] |
elina.kuzyutkina But Housekeeper does delete from the events table? That's why I thought |