[ZBX-10608] actions/condition caching in 3.0 caused wrong AND/OR expression evaluation in some cases Created: 2016 Apr 01  Updated: 2017 May 30  Resolved: 2016 Apr 05

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 3.0.0
Fix Version/s: 3.0.2rc1, 3.2.0alpha1

Type: Incident report Priority: Blocker
Reporter: Oleksii Zagorskyi Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: actions, cache, conditions, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate

 Description   

Previously when processing conditions they were taken from database with "order by conditiontype" and this block of code was working correctly:

case CONDITION_EVAL_TYPE_AND_OR:
				if (old_type == condition->conditiontype)
				{
					if (SUCCEED == condition_result)
						ret = SUCCEED;
				}
				else
				{
					if (FAIL == ret)
						goto clean;

					ret = condition_result;
					old_type = condition->conditiontype;
				}

				break;

Now, in 3.0, conditions are taken from configuration cache where they, seems, are sorted by "conditionid" instead of "conditiontype".

If a condition type A will be evaluated to FAIL after evaluation of another condition type B, then that FAIL simply overwrites possible SUCCESS of earlier evaluated condition type A.

As a result - an action which worked in 2.4 stops to work in 3.0 (for sure!) or vice versa (I guess).



 Comments   
Comment by Oleksii Zagorskyi [ 2016 Apr 01 ]

I.e. the bug is reproducible depending on when an action condition was added to configuration.
It's hard to predict which action are affected or not.

As a workaround before the fix, it's possible to copy automatically generated expression, like "(A and B and (C or D) and (E or F))", change "Type of calculation" to "Custom expression", paste the expression and save the action.
This workaround tested and it works, credits go to wiper

Comment by Andris Zeila [ 2016 Apr 01 ]

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

Comment by Oleksii Zagorskyi [ 2016 Apr 01 ]

Succesfully tested.
Before:

 32301:20160401:194849.226 In process_actions() events_num:1
 32301:20160401:194849.226 In zbx_dc_get_actions_eval()
 32301:20160401:194849.226 End of zbx_dc_get_actions_eval() actions:1
 32301:20160401:194849.226 In check_action_conditions() actionid:3
 32301:20160401:194849.226 In check_action_condition() actionid:3 conditionid:5 cond.value:''
 32301:20160401:194849.226 In check_trigger_condition()
 32301:20160401:194849.226 query [txnlev:1] [select count(*) from hosts h,items i,functions f,triggers t where h.hostid=i.hostid and h.maintenance_status=0 and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=13561]
 32301:20160401:194849.226 End of check_trigger_condition():SUCCEED
 32301:20160401:194849.226 End of check_action_condition():SUCCEED
 32301:20160401:194849.226 In check_action_condition() actionid:3 conditionid:6 cond.value:'1'
 32301:20160401:194849.226 In check_trigger_condition()
 32301:20160401:194849.226 End of check_trigger_condition():SUCCEED
 32301:20160401:194849.226 End of check_action_condition():SUCCEED
 32301:20160401:194849.226 In check_action_condition() actionid:3 conditionid:13 cond.value:'4'
 32301:20160401:194849.226 In check_trigger_condition()
 32301:20160401:194849.226 End of check_trigger_condition():SUCCEED
 32301:20160401:194849.226 End of check_action_condition():SUCCEED
 32301:20160401:194849.226 In check_action_condition() actionid:3 conditionid:14 cond.value:'4'
 32301:20160401:194849.226 In check_trigger_condition()
 32301:20160401:194849.226 query [txnlev:1] [select distinct hg.groupid from hosts_groups hg,hosts h,items i,functions f,triggers t where hg.hostid=h.hostid and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid
 32301:20160401:194849.226 End of check_trigger_condition():FAIL
 32301:20160401:194849.226 End of check_action_condition():FAIL
 32301:20160401:194849.226 In check_action_condition() actionid:3 conditionid:15 cond.value:'2'
 32301:20160401:194849.226 In check_trigger_condition()
 32301:20160401:194849.226 query [txnlev:1] [select distinct hg.groupid from hosts_groups hg,hosts h,items i,functions f,triggers t where hg.hostid=h.hostid and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid
 32301:20160401:194849.226 End of check_trigger_condition():SUCCEED
 32301:20160401:194849.227 End of check_action_condition():SUCCEED
 32301:20160401:194849.227 In check_action_condition() actionid:3 conditionid:18 cond.value:'5'
 32301:20160401:194849.227 In check_trigger_condition()
 32301:20160401:194849.227 End of check_trigger_condition():FAIL
 32301:20160401:194849.227 End of check_action_condition():FAIL
 32301:20160401:194849.227 End of check_action_conditions():FAIL
 32301:20160401:194849.227 query [txnlev:1] [select actionid,triggerid,itemid from escalations where eventid is not null and actionid=3]
 32301:20160401:194849.227 End of process_actions()

After:

 32540:20160401:194944.652 In process_actions() events_num:1
 32540:20160401:194944.652 In zbx_dc_get_actions_eval()
 32540:20160401:194944.652 End of zbx_dc_get_actions_eval() actions:1
 32540:20160401:194944.652 In check_action_conditions() actionid:3
 32540:20160401:194944.652 In check_action_condition() actionid:3 conditionid:14 cond.value:'4'
 32540:20160401:194944.652 In check_trigger_condition()
 32540:20160401:194944.652 query [txnlev:1] [select distinct hg.groupid from hosts_groups hg,hosts h,items i,functions f,triggers t where hg.hostid=h.hostid and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid
 32540:20160401:194944.652 End of check_trigger_condition():FAIL
 32540:20160401:194944.652 End of check_action_condition():FAIL
 32540:20160401:194944.652 In check_action_condition() actionid:3 conditionid:15 cond.value:'2'
 32540:20160401:194944.652 In check_trigger_condition()
 32540:20160401:194944.653 query [txnlev:1] [select distinct hg.groupid from hosts_groups hg,hosts h,items i,functions f,triggers t where hg.hostid=h.hostid and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid
 32540:20160401:194944.653 End of check_trigger_condition():SUCCEED
 32540:20160401:194944.653 End of check_action_condition():SUCCEED
 32540:20160401:194944.653 In check_action_condition() actionid:3 conditionid:13 cond.value:'4'
 32540:20160401:194944.653 In check_trigger_condition()
 32540:20160401:194944.653 End of check_trigger_condition():SUCCEED
 32540:20160401:194944.653 End of check_action_condition():SUCCEED
 32540:20160401:194944.653 In check_action_condition() actionid:3 conditionid:18 cond.value:'5'
 32540:20160401:194944.653 In check_trigger_condition()
 32540:20160401:194944.653 End of check_trigger_condition():FAIL
 32540:20160401:194944.653 End of check_action_condition():FAIL
 32540:20160401:194944.653 In check_action_condition() actionid:3 conditionid:6 cond.value:'1'
 32540:20160401:194944.653 In check_trigger_condition()
 32540:20160401:194944.653 End of check_trigger_condition():SUCCEED
 32540:20160401:194944.653 End of check_action_condition():SUCCEED
 32540:20160401:194944.653 In check_action_condition() actionid:3 conditionid:5 cond.value:''
 32540:20160401:194944.653 In check_trigger_condition()
 32540:20160401:194944.653 query [txnlev:1] [select count(*) from hosts h,items i,functions f,triggers t where h.hostid=i.hostid and h.maintenance_status=0 and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=13561]
 32540:20160401:194944.653 End of check_trigger_condition():SUCCEED
 32540:20160401:194944.653 End of check_action_condition():SUCCEED
 32540:20160401:194944.653 End of check_action_conditions():SUCCEED
 32540:20160401:194944.653 In DCget_nextid() table:'escalations' num:1
 32540:20160401:194944.653 query [txnlev:1] [select max(escalationid) from escalations where escalationid between 0 and 9223372036854775807]
 32540:20160401:194944.653 End of DCget_nextid() table:'escalations' [1:1]
 32540:20160401:194944.653 query [txnlev:1] [insert into escalations (escalationid,actionid,status,triggerid,itemid,eventid,r_eventid) values (1,3,0,13561,null,18,null);
]
32540:20160401:194944.653 End of process_actions()
Comment by Glebs Ivanovskis (Inactive) [ 2016 Apr 04 ]

Successfully TESTED

Code looks good to me, just added a small comment in r59253.
Please review my suggestion of a simple performance improvement in r59257.

More improvements are possible but changes will be too complicated for a bug fix. Created a separate ZBXNEXT-3229.

Comment by Andris Zeila [ 2016 Apr 04 ]

Reviewd r59257, looks good

Comment by Andris Zeila [ 2016 Apr 04 ]

Released in:

  • pre-3.0.2rc1 r59261
  • pre-3.1.0 r59262
Generated at Fri Apr 26 20:42:09 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.