Garbage Historian value getting looged in database

Hello all,

We are stuck in an unexpected issue and are evaluating cause.

We have s7-300 machine connected to our ignition application giving 2 tag values namely prod_count & status with history enabled. We have written tag event script & quality event script to check plc make and write value to line status.
We have seen that when machine status changes to 1, the prod_count history value is stored with older value sometime and then our OEE calculations get disrupted.
So, like when current prod count is 10001 and status changes to 0 prod_count new value is 9500 and when status value is 1 this value goes to 10002. so we have to check why is it behaving like.
Appreciate your time in reading this long issue.
Ignition - 8.1.18

Simple error in timing assumptions on your part. OPC subscriptions don't guarantee any particular order of delivery, so the arrival of a trigger in one tag doesn't mean another tag will already be up-to-date too.

The answer, in Ignition, is to subscribe for a trigger, but use an OPC read after the trigger to get all other values to be saved. You can script this, or use a SQL bridge module's transaction group set to OPC read mode. The tag historian cannot do this.