[ZBX-19871] Trigger use old data from dependent item Created: 2021 Aug 27  Updated: 2021 Sep 30  Resolved: 2021 Sep 30

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 5.4.3
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Yurii Polenok Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: dependentitems, expressions, history, problem, trigger
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-08-27-13-37-49-120.png     PNG File image-2021-08-27-13-40-49-406.png     PNG File image-2021-09-22-18-50-29-244.png     PNG File image-2021-09-22-18-50-47-705.png    
Issue Links:
Duplicate
duplicates ZBXNEXT-6284 Ability to use multiple dependent ite... Open

 Description   

Steps to reproduce:

  1. Create an item and its dependent items.
  2. Create a trigger that uses two dependent items.
  3. Wait for problem.

 

Result:

 

Event details:

Event Database blocker(s) | "AUTOMATION":"*****":"TX", "BACKEND":"****":"TX", "AUTOMATION":"*****":"TX" + 1 more blockers
Description ...
response:
"APP":"******":"TX"

History:

Database blockers List (first item in expression)

Timestamp   Value
2021-08-27 10:20:17  1630059617 "APP":"******":"TX"
2021-08-26 18:08:17  1630001297 []

 

Database blockers Shortened List (second item in expression)

Timestamp   Value
2021-08-27 10:20:17 1630059617 "APP":"******":"TX"
2021-08-25 09:38:17 1629884297 "AUTOMATION":"*****":"TX", "BACKEND":"****":"TX", "AUTOMATION":"*****":"TX" + 1 more blockers

Expected:
Trigger name uses the latest value from history.

Event Database blocker(s) | "APP":"******":"TX"


 Comments   
Comment by Yurii Polenok [ 2021 Sep 22 ]

Hi
Any news?

Comment by Oleksii Zagorskyi [ 2021 Sep 22 ]

I could not reproduce it on a more simple scenario, where key point is ti use dependent item in trigger and {ITEM.LASTVALUE} macro in trigger name.

It's strange that for 2nd item in expression you do a comparison (>0) which should work for numeric items, while on history we see that the item collected Str/Text values.
It means that something is strange in your case.

Please try to reproduce the issue with more simple setup, with simple dependent item, without any preprocessing steps etc. Then step by step change it to be similar like in production to find out what exactly fails. I suppose this way you will find a misconfiguration on your side.
 

Comment by Yurii Polenok [ 2021 Sep 22 ]

I need to use in the trigger the information from the second item, for this I added it to the expression. Since this is a text item, I use length(*last(/Template/item))> 0*.
Dependent items were originally created to use preprocessing, I am not using anything too specific here.
If the trigger expression uses dependent items, then the trigger must fire only after the data from all dependent items has been successfully saved to the database. In my case, the data from the first item has already been saved, the trigger fired, after the unknown number of milliseconds the data from the second item was written, and as a result we get an incorrect alert.
It is difficult to reproduce it, usually everything works fine.

First item:

json = JSON.parse(value);
if (json.length === 0) {
    return value;
} else {
    res = ""; 
    json.forEach(function (o) {
        res += JSON.stringify(o.BLOCKER)+":"+
            JSON.stringify(o.BLOCKED_OBJ)+":"+
            JSON.stringify(o.LOCK_TYPE)+"\n";
    });
    return res;
}

Second item:

json = JSON.parse(value);

function getValue(data) {
    res = "";
    data.forEach(function (o) {
        res += JSON.stringify(o.BLOCKER)+":"+
               JSON.stringify(o.BLOCKED_OBJ)+":"+
               JSON.stringify(o.LOCK_TYPE)+", ";
    });
    return res.slice(0, -2);
}
if (json.length > 3) {
    res = getValue(json.slice(0, 3));
    res += " + "+(json.length-3)+" more blockers";
} else {
    res = getValue(json);
}
return res;
Comment by Oleksii Zagorskyi [ 2021 Sep 22 ]

Ok, I did not spot length() function, that's ok for 2nd part of expression.

Well, it's about trigger processing refactoring, which is not a bug.

If you have logical dependencies of  two items (disregarding that they are dependent on the same master) used in single expression, you should not use so sensitive function like last().
Order of items processing is not guaranteed, different history syncers may work on write cache,  so order of parts of expression evaluation is also not guaranteed.

Comment by Oleksii Zagorskyi [ 2021 Sep 22 ]

I do not have other suggestions than close it as Won't fix.

Comment by Oleksii Zagorskyi [ 2021 Sep 30 ]

I feel like it's duplicate of ZBXNEXT-6284.
Closing as duplicate.

Generated at Fri Apr 04 16:53:45 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.