# Tag Change Missed Events

**URL:** <https://forum.inductiveautomation.com/t/tag-change-missed-events/37764>\
**Category:** Ignition\
**Created:** [August 15, 2020, 6:36pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764 "2020-08-15T18:36:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 15, 2020, 6:36pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/1 "2020-08-15T18:36:41Z")

</div>

What does the missed events parameter mean in a tag change script?  
Does it mean that one script failed to execute because it changed so fast?

I have several tags that change at fast at most 10 per second. Does the missed event true mean it failed to a tag change script on a a change?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 16, 2020, 3:14pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/2 "2020-08-16T15:14:58Z")

</div>

Each tag has a queue, size 5, that change events get put into and pulled out of for execution. If your script is taking too long to execute and changes are happening quickly this queue will overflow and that flag will get set.

When an overflow happens the oldest event (the head of the queue) is discarded to make room.

---

<div class="post-metadata">

**Author:** ![PRAMANJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pramanj/32/66935_2.png) [@PRAMANJ](https://forum.inductiveautomation.com/u/PRAMANJ)\
**Post date:** [August 16, 2020, 6:14pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/3 "2020-08-16T18:14:46Z")

</div>

> [@Kevin.Herron](#):
>
> When an overflow happens the oldest event (the head of the queue) is discarded to make room.

Hope it means tag change event on same tag not any of the tags where tag change is registered? If I have 1000 tags registered for tag change event trigger in gateway, assuming they all call the same function for processing (e.g. write to DB) , hope the events will be queued (assuming same tag doesn't change too fast or chatter ).

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 17, 2020, 8:16pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/4 "2020-08-17T20:16:33Z")

</div>

Kevin, is there any way to increase that to something larger than 5?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 17, 2020, 8:21pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/5 "2020-08-17T20:21:04Z")

</div>

You can add this property as an additional parameter in ignition.conf:

`-Dignition.tags.scriptqueuemaxsize=10`

I would verify that you’re actually missing events first by printing a warning if that missed even parameter is set.

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 17, 2020, 8:49pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/6 "2020-08-17T20:49:43Z")

</div>

Are you saying testing whether that flag is true or not?

If so, i get an email every time that flag is true, if missEvents: send email,  
and i have been getting alot of emails

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 17, 2020, 8:52pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/7 "2020-08-17T20:52:53Z")

</div>

That kind of suggests that your tag event script needs some tuning to run faster. What exactly is that script doing?

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 17, 2020, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/8 "2020-08-17T21:00:19Z")

</div>

I have UDP message OPC tags that when they change, a script runs. Originally i had that tag change script parse the message. That took too long.  
Now that script writes the message to a memory tag and lets that memory tag do the parsing on the memory tag.  
I have a counter to indirectly write to a different memory tag when the OPC tag changes. I have a range of 1 to 1000 tags available. When it hits 1000, it starts over. This is not going back to zero that fast.

The email of the missed events is on the memory tag and not the OPC tag. Its a bit strange how thats happening because the counter would have to go around twice for that to happened.

The problem we have is we have 100+ devices reporting UDP and sometimes those devices can report very fast and at the same time. So i thought since i got the missed event flag that this was happening.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 17, 2020, 9:13pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/9 "2020-08-17T21:13:32Z")

</div>

Sounds like a job for a direct jython UDP listener thread (using java’s networking classes) that pushes the raw packets into thread pool work queue of your own. Careful use of script module top level globals and function definitions can keep the parsing code efficient. (You really do not want your fast path to _ **ever** _ execute a `def` statement.)

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 18, 2020, 3:17am UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/10 "2020-08-18T03:17:57Z")

</div>

I added this code below to check how long my tag change scripts are taking to parse the messages. I am storing those in a data set. This is running very very fast, i don’t see why i’m getting missed events with the tag change scripts running that fast.

Unless i get 5+ messages at the exact same time

```auto
import time
start_time = time.time()

# Parsing code here

time.time() - start_time

```

0.0090000629425  
0.00899982452393  
0.0149998664856  
0.0160000324249  
0.0090000629425  
0.0160000324249

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [August 18, 2020, 9:33am UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/11 "2020-08-18T09:33:49Z")

</div>

> [@Kevin.Herron](#):
>
> Each tag has a queue, size 5, that change events get put into and pulled out of for execution. If your script is taking too long to execute and changes are happening quickly this queue will overflow and that flag will get set.

That's interesting. So if a script is running, the updates are still queued according to the scan class/tag group settings. I thought a long running script just delayed the scan class timing until it was done running.

But if the updates happen faster than the scan class, Ignition will never know about the change, and also won't queue the changes. Is that correct?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 18, 2020, 12:58pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/12 "2020-08-18T12:58:11Z")

</div>

> [@Sanderd17](#):
>
> But if the updates happen faster than the scan class, Ignition will never know about the change, and also won’t queue the changes. Is that correct?

The only thing that might get missed are script invocations for in between values, but Ignition will still have had the value pass through the tag.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 18, 2020, 12:59pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/13 "2020-08-18T12:59:57Z")

</div>

Another tag script performance piece that may be affecting OP is that there is a dedicated thread pool size 3 that all tag change scripts are executed on. So in addition to having a per-tag queue of size 5 that events will sit in, there’s only ever 3 tag change scripts executing at once.

This is where you can really get into trouble with long running scripts (as @pturmel hinted), because if you have 3 long running scripts then nothing else is executing until at least one of them finishes.

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 18, 2020, 1:07pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/14 "2020-08-18T13:07:14Z")

</div>

Running 3 scripts at the same time is unfortunate. My scripts are running fast, less than 1, in low ms, and we will always have 50 to 100 + UDP devices sending messages all the time. The data comes in as a long string of text that i have to parse.

My chances of 3 tag change scripts running at the same time is probably very likely. If there are 5 in queue for multiple tags (30 +) at a time, each tag could be maxed out at 5 in the queue waiting for other 3 tags to finished executing their tag change scripts?

Any other feedback on handling this is much appreciated, even if we have to go about parsing this UDP message differently than we are.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 18, 2020, 1:12pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/15 "2020-08-18T13:12:26Z")

</div>

> [@jramirez3](#):
>
> If there are 5 in queue for multiple tags (30 +) at a time, each tag could be maxed out at 5 in the queue waiting for other 3 tags to finished executing their tag change scripts?

I think that could be possible, especially if you have _any_ other tag change scripts that might be slower.

You can also influence this thread pool size with a setting:  
`-Dignition.tags.scriptthreads=N`

You could also consider using the "legacy" project-based tag change scripts, which don't have any kind of queue or thread pool involved and doesn't drop events AFAIK.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 18, 2020, 1:21pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/16 "2020-08-18T13:21:01Z")

</div>

> [@Kevin.Herron](#):
>
> project-based tag change scripts

These are my first choice in all cases (so far).

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 18, 2020, 1:51pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/17 "2020-08-18T13:51:40Z")

</div>

Are you saying the scripts that are stored in the project library and not the shared script library?  
I don’t think that’s what you mean because tags are gateway scoped and if i’m calling a project scope it won’t know where to find it.

---

<div class="post-metadata">

**Author:** ![PRAMANJ](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pramanj/32/66935_2.png) [@PRAMANJ](https://forum.inductiveautomation.com/u/PRAMANJ)\
**Post date:** [August 18, 2020, 2:31pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/18 "2020-08-18T14:31:50Z")

</div>

> [@Kevin.Herron](#):
>
> Another tag script performance piece that may be affecting OP is that there is a dedicated thread pool size 3 that all tag change scripts are executed on. So in addition to having a per-tag queue of size 5 that events will sit in, there’s only ever 3 tag change scripts executing at once.

I think this answers my question asked earlier. If I understand it correctly, the queue of 5 events is for a single tag, and there can be 3 such queues (which can be increased with some configuration settings) for 3 different tag changes near-simultaneously. I guess the three threads (if any) will be switched only after the queue of 5 (if any) in each is completed. Is my understanding correct?

> [@Kevin.Herron](#):
>
> You could also consider using the “legacy” project-based tag change scripts, which don’t have any kind of queue or thread pool involved and doesn’t drop events AFAIK.

I would also like to know more about it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 18, 2020, 2:37pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/19 "2020-08-18T14:37:43Z")

</div>

No. Go to project scripting, gateway events. The tag change events there are part of the project and can use both project and shared script modules. They also allow a single event script to subscribe to many tags. If you search the forum you can find many examples of me touting gateway tag change event scripts and criticizing tag events.

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [August 18, 2020, 3:38pm UTC](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764/20 "2020-08-18T15:38:25Z")

</div>

I see what you’re talking about.

From the Gateway tag Change events, how do i detect missed events?

[Next page](https://forum.inductiveautomation.com/t/tag-change-missed-events/37764.md?page=2)
