[ZBX-3920] trigger addDependencies() creates duplicates Created: 2011 Jul 05 Updated: 2017 May 30 Resolved: 2012 Oct 05 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 1.8.4 |
Fix Version/s: | 2.0.4rc1, 2.1.0 |
Type: | Incident report | Priority: | Minor |
Reporter: | Sheldon Hearn | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 2 |
Labels: | api | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
MySQL RDBMS using InnoDB engine for tables |
Issue Links: |
|
Description |
The API method trigger.addDependencies does not check whether dependencies exist prior to adding them, and there is no unique constraint across trigger_depends.triggerid_up and trigger_depends.triggerid_down to prevent the addition. We had poorly written code that was unconditionally adding a dependency over and over, e.g.
The problem is, when we checked what this was doing, through the API, it looked like trigger.addDependencies was being very clever, and doing nothing if the dependency already existed:
No matter how many times we added the same dependency with trigger.addDependencies, trigger.get would show us the dependency only once. However, each call to trigger.addDependencies added another row to the trigger_depends table. By the time we noticed what was happening, we had over half a million rows in the trigger_depends table, the increasing every half an hour when our script was run from cron. We have subsequently modified our code to "include_dependencies" in the trigger.get request, and only trigger.addDependencies if the dependencies we want are missing. This reduces the likelihood of duplicate rows in trigger_depends table considerably. Possible solutions that occur to me include: 1) Make trigger.addDependencies() fail when it receives a request to add an already existing dependency. |
Comments |
Comment by Alexey Fukalov [ 2012 Sep 24 ] |
(1) oleg.egorov RESOLVED Vedmak some code corrections needed as we discussed. oleg.egorov RESOLVED Vedmak CLSOED |
Comment by Alexey Fukalov [ 2012 Sep 24 ] |
(2)
if($DplTriggers){
$UnqTriggers = array_unique($trigger['dependencies']);
oleg.egorov Vedmak CLSOED |
Comment by Alexey Fukalov [ 2012 Sep 28 ] |
(3) oleg.egorov RESOLVED Vedmak seems there is still needed separate select as discussed. oleg.egorov RESOLVED |
Comment by Alexey Fukalov [ 2012 Oct 04 ] |
Vedmak as discussed, select logic and error message should be changed. oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-3920 r30669 Vedmak seems it doesn't catch db duplicates, show message about insert sql failure. Vedmak Please review my changes in r30671 ,can be merged if everything is ok. oleg.egorov CLOSED |
Comment by Oleg Egorov (Inactive) [ 2012 Oct 05 ] |
Fixed in pre-2.0.4 r30672 and pre-2.1.0 (trunk) r30673. |