ZABBIX BUGS AND ISSUES
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-10608

actions/condition caching in 3.0 caused wrong AND/OR expression evaluation in some cases

    Details

      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).

        Activity

        Hide
        Oleksiy Zagorskyi added a comment - - edited

        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 Andris Zeila

        Show
        Oleksiy Zagorskyi added a comment - - edited 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 Andris Zeila
        Hide
        Andris Zeila added a comment -

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

        Show
        Andris Zeila added a comment - Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-10608
        Hide
        Oleksiy Zagorskyi added a comment -

        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()
        
        Show
        Oleksiy Zagorskyi added a comment - 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()
        Hide
        Glebs Ivanovskis added a comment - - edited

        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.

        Show
        Glebs Ivanovskis added a comment - - edited 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 .
        Hide
        Andris Zeila added a comment -

        Reviewd r59257, looks good

        Show
        Andris Zeila added a comment - Reviewd r59257, looks good
        Hide
        Andris Zeila added a comment -

        Released in:

        • pre-3.0.2rc1 r59261
        • pre-3.1.0 r59262
        Show
        Andris Zeila added a comment - Released in: pre-3.0.2rc1 r59261 pre-3.1.0 r59262

          People

          • Assignee:
            Unassigned
            Reporter:
            Oleksiy Zagorskyi
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: