[ZBX-9950] Discovery action based host removal fails on triggers created by item discovery Created: 2015 Oct 13 Updated: 2017 May 30 Resolved: 2015 Dec 13 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 2.4.7rc1 |
Fix Version/s: | 2.4.8rc1, 3.0.0alpha5 |
Type: | Incident report | Priority: | Minor |
Reporter: | Bruno Vanters | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 1 |
Labels: | networkdiscovery, sql | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
mysql Ver 15.1 Distrib 10.0.20-MariaDB, for Linux (x86_64) using readline 5.1 |
Description |
There is a discovery based action, that removes registered hosts. [Z3005] query failed: [1451] Cannot delete or update a parent row: a foreign key constraint fails (`zabbix`.`trigger_discovery`, CONSTRAINT `c_trigger_discovery_2` FOREIGN KEY (`parent_triggerid`) REFERENCES `triggers` (`triggerid`)) [delete from triggers where (triggerid between 22917 and 22921 or triggerid in (22934,22935,22936)); The code tries to delete the triggers "triggerid between 22917 and 22921". As there is trigger_discovery table with foreign key to triggers table, the lookup of dependent records is being performed and "or triggerid in (22934,22935,22936)" clause is added. delete from triggers where triggerid in (22934,22935,22936); delete from triggers where (triggerid between 22917 and 22921 or triggerid in (22934,22935,22936)); Also if the parent triggerid is already in the original list, no clause is added, thus requiring a manual query to determine the failing triggerid: select * from trigger_discovery where parent_triggerid between 22215 and 22220; delete from triggers where triggerid=22220; delete from triggers where triggerid between 22215 and 22220; |
Comments |
Comment by Aleksandrs Saveljevs [ 2015 Oct 13 ] |
Something similar was meant to be fixed in 2.4.6 under |
Comment by Bruno Vanters [ 2015 Oct 13 ] |
Comparing DBdelete_triggers in src/libs/zbxdbhigh/host.c for nightly builds in 2.4.7 and 3.0.0 does not show any difference thus assuming that the problem persists in latest version. |
Comment by Glebs Ivanovskis (Inactive) [ 2015 Nov 16 ] |
Thank you Wano for elaborate explanation! You are absolutely right, we are trying to delete item prototypes and respective child items, trigger prototypes and respective child triggers, graph prototypes and respective child graphs in one go. It took some time for me to get familiar with respective code. This issue has absolutely nothing in common (although error messages look similar) with much more exotic |
Comment by Glebs Ivanovskis (Inactive) [ 2015 Nov 17 ] |
Fix for 2.4 available in development branch svn://svn.zabbix.com/branches/dev/ZBX-9950-24 revision 56771. Versions 2.0 and 2.2 are unaffected since foreign key restrictions were introduced for 2.4 with We will now first delete child triggers and then trigger prototypes. Same is true for graphs. |
Comment by Andris Zeila [ 2015 Dec 04 ] |
(1) src/libs/zbxdbhigh/host.c:DBdelete_trigger_hierarchy() The sql variable is not freed. glebs.ivanovskis RESOLVED in r57003. wiper CLOSED |
Comment by Andris Zeila [ 2015 Dec 04 ] |
(2) The zbx_vector_*_setdiff() function does not appear to be functioning correctly. If we pass (0, 1, 2, 3) as left and (1, 3) as right uint64 vectors, then the resulting left vector will be (2, 1) rather than (0, 2). Also the right vector should be passed as const. glebs.ivanovskis Silly mistake, got lost in increments. RESOLVED in r57004. wiper CLOSED |
Comment by Andris Zeila [ 2015 Dec 04 ] |
(3) Removal of host with host prototypes and hosts discovered by them fails. Actually it doesn't seem server handles removal of discovered hosts. Maybe we should create a new issue and mark this as tested. |
Comment by Andris Zeila [ 2015 Dec 07 ] |
Successfully tested |
Comment by Glebs Ivanovskis (Inactive) [ 2015 Dec 08 ] |
Fixed in pre-2.4.8rc1 r57071, pre-3.0.0alpha5 (trunk) r57072. |
Comment by richlv [ 2015 Dec 24 ] |
note that this development introduced more "childs" typos which hopefully will be handled through |