[ZBX-5218] Editing trigger prototype expression for already discovered triggers is generating orphaned triggers Created: 2012 Jun 20  Updated: 2017 May 30  Resolved: 2012 Jun 21

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 2.0.0, 2.1.0
Fix Version/s: 2.0.2rc1, 2.1.0

Type: Incident report Priority: Blocker
Reporter: Oleksii Zagorskyi Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: events, lld, orphaned, trigger
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File orphaned_triggers_zabbix_server.log    
Issue Links:
Duplicate
is duplicated by ZBX-5587 PHP Fatal error: Out of memory (allo... Closed

 Description   

We have one poller configured to simplify debugging, discovery rule update interval - 60 seconds.

Short scenario is:

  • a LLD discovery works; items, triggers already generated.

...

  • in one moment a trigger prototype expression has been changed from:
    Unknown macro: {it3}

    <5

  • In next execution of discovery rule we get (note insertion wrong functions and deleting them together with functions existing before):

23079:20120620:143154.400 query [txnlev:1] [insert into functions (functionid,itemid,triggerid,function,parameter) values (15207,26700,221169,'last','0'),(15208,26701,221170,'last','0');
]
23079:20120620:143154.401 query [txnlev:1] [update triggers set description='Free disk space is less than 10% on volume C:
',expression='

{15207}

<5',priority=2,comments='',url='',type=0,flags=4 where triggerid=221169;
update trigger_discovery set name='Free disk space is less than 10% on volume

{#FSNAME}' where triggerid=221169 and parent_triggerid=221158;
delete from functions where triggerid=221169;
update triggers set description='Free disk space is less than 10% on volume D:
',expression='{15208}<5',priority=2,comments='',url='',type=0,flags=4 where triggerid=221170;
update trigger_discovery set name='Free disk space is less than 10% on volume {#FSNAME}

' where triggerid=221170 and parent_triggerid=221158;
delete from functions where triggerid=221170;
]

  • In next execution of discovery rule we get (note creation new triggers, trigger_discovery, functions records):

23079:20120620:143254.432 query [txnlev:1] [insert into triggers (triggerid,description,expression,priority,status,comments,url,type,value,value_flags,flags,error) values (221171,'Free disk space is less than 10% on volume C:
','

{15209}

<5',2,0,'','',0,0,1,4,'Trigger just added. No status update so far.'),(221172,'Free disk space is less than 10% on volume D:
','

{15210}

<5',2,0,'','',0,0,1,4,'Trigger just added. No status update so far.');
]
23079:20120620:143254.433 query [txnlev:1] [insert into trigger_discovery (triggerdiscoveryid,triggerid,parent_triggerid,name) values (13,221171,221158,'Free disk space is less than 10% on volume

{#FSNAME}'), (14,221172,221158,'Free disk space is less than 10% on volume {#FSNAME}

');
]
23079:20120620:143254.433 query [txnlev:1] [insert into functions (functionid,itemid,triggerid,function,parameter) values (15209,26700,221171,'last','0'),(15210,26701,221172,'last','0');
]

Note that between two discovery executions there are NO visible and working triggers for the host(s) !!!
It can be even accidentally noticeable because update interval for rules usually can be enough big.

In the result we have orphaned triggers (which were before) in the DB (triggers without functions) and if those triggers generated events - it will be visible in the events page if select All for host groups and hosts.
In this case there are visible scary PHP errors bottom of the page.

In the attachment you can see all these queries with all related parts with DebugLevel=4

To find such triggers here is a simple SQL:
select * from triggers where triggerid not in (select triggerid from functions)

To delete orphaned event (if they are) and triggers here is two simple SQLs (order is important):
delete from events where objectid in (select triggerid from triggers where triggerid not in (select triggerid from functions))
delete from triggers where triggerid not in (select triggerid from functions)



 Comments   
Comment by Oleksii Zagorskyi [ 2012 Jun 20 ]

(1) Note - in every production DB there is one such WEB trigger which came from data.sql
Maybe it should be deleted from DB by upgrade patches for a next major version?

<Sasha> RESOLVED in r28388. (WEB trigger removed from data.tmpl)
I think we shouldn't add validation and fixing of data in upgrade patches. Triggers without functions won't affect system operation in any way.

<richlv> including the frontend ? wouldn't it bork up something like trigger count somewhere (monitoring, config...) or anything else ?

Comment by Oleksii Zagorskyi [ 2012 Jun 20 ]

(2) Please check also behavior of discovered graphs for similar cases. Maybe there is also something that should/could be improved?

<Sasha> WON'T FIX graphs works as expected

Comment by Alexander Vladishev [ 2012 Jun 21 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-5218

Comment by dimir [ 2012 Jun 22 ]

Successfully tested!

Comment by dimir [ 2012 Jun 25 ]

Fix assignee.

Comment by dimir [ 2012 Jun 29 ]

Fixed in pre-2.0.2 r28566, pre-2.1.0 r28567.

Comment by Oleksii Zagorskyi [ 2012 Jul 03 ]

Just small conclusion of this fix.
After changing trigger expression (any expression change), frontend recreates new trigger's functions (delete old, create new) for trigger prototypes. IDs of trigger prototypes remain the same.

With this fix server is doing the same - after next discovery it recreates just trigger functions, without changing IDs of discovered triggers.

That's fine because we can use discovered triggers in action conditions and do not afraid that they will be deleted (as condition of course) after changing the expression in the prototype.

THANKS!

Generated at Wed Apr 24 13:16:02 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.