Execution of scripting in tag's value change

I had a question about running script in tag's value change. We have some application working in production, that is critical for line to work. I don't think it is a good practice, but this is how our system has been designed, and we just adapted it in the new factory. We recently had a lot of troubles with errors that accure from script in value change not finishing in time (first line of script checks if the value is 1 and then sets a acknowlage tag to true, which should happen every time, but it fails sometimes even tho the value of that tag is changing). So I wanted to know, if every tag that has a script running when value changes is put in the same queue to execute - that would explain those scripts not working sometimes. If thats the case, is there a way to prioritize running a specific UDT/scan class scripts?
Also what is the best way to save OPC tags values to database? We have recently added a lot of system.db.runUpdate/PrepQuery funcitions on tag scripts, that save desired parameters to our DB. They do it every hour, and those problems we have been having are mostly accuring on full hours (so when the insert to DB happens). We have disabled those tags for now and will monitor if we still get the error, but im pretty sure them not executing because of too many scripts running is the anserw.

Yes. And the scheduler has three threads. You must arrange for value change scripts to execute very quickly, preferably single digit milliseconds. If you must write to tags within a value change script, be sure to use system.tag.writeAsync(), not system.tag.writeBlocking().


Absolutely deadly to the proper functioning of your system. Such calls that typically need network activity must use gateway tag change events (in a project), not tag value change scripts.

(Although you can safely use the Store and Forward versions to queue Updates or Inserts.)

Thank you @pturmel

Is there anyway to check that scheduler queue/previously run scripts?

I will remake my DB inserts to be exectued by gateway tag change event. If I have a working script in tag value change will it be the same script in gateway tag change event? I'm not sure how to read tag values in gateway script, I'm guessing its the same just wanted to make sure.

Also, when using scripts on components (like focus gained or action preformed), does that script execution share queue with scheduler for tag value change?

Not that I'm aware of.

Not quite. The values handed to a gateway tag change event are slightly different from a tag's value change event. But close.