DB connection fault during event

I have a tag event script which contains several prepared queries that pull in data to be used within the script. However, sometimes the db connection is faulted for a little under a minute before coming back online.

Since I need this db values to continue running my event script, would it be wise in considering some exception handling where I would loop the prepared query with a time.sleep(10) command several times before giving up and ending the event script?

Alternatively, I am thinking that maybe a simple check that the db is connected at the start of the script preventing the rest of it from running might be better. Does anyone have a similar situation and which route did you take?

I think you know the answer. :roll_eyes:

Gather all of your data at the beginning of the script. If any of that fails, don't run the rest. If necessary, set a flag in a memory tag to try again. (Not necessary if a timer event--those will run again anyways--and the script conditions to execute remain true.)

Is it really the database randomly faulting or is it possible these queries are taking so long there is a timeout exception happening? If this is the case you can probably mitigate this with well placed indexes or lengthening how long Ignition waits before it considers it a timeout.

1 Like

I have several tag change events in a UDT, and I already moved some of the in script queries to query bound tags. I haven't always had the best luck with query tags, which is why I initially avoiding using them in this UDT, but for the very repetitive ones it helps to simplify the events.
The db is definitely losing connection to the gateway, and not because of any small,indexed query's I am running.

And Thanks for the idea Phil.