Background:
I’m making an API call using Ignitions scripting module, the response of which is a JSON structure with roughly 200 items. I’m splitting the structure up and inserting them as rows into a SQL server on the same SQL Instance as my Ignition DB.
=================================================================
Problem:
1. I initially used a sleep function to throttle the amount of outgoing calls to limit tractions to SQL. This sleep function caused a clock drift on the gateway. This caused a desync between Ignition and the backend SQL instance and everything started populating in Store & Forward.
a. This approach is discouraged.
b. Recovery was to disable / reenable SQL connection, and or bounce the gateway.
2. Removing the sleep function, script runs fine but Transactional Group records start getting stuck in Store & Forward.
a. In this case I suspect a performance spike SQL side since I cant throttle connection.
b. SQL server is still responsive, other services are not impact.
c. Checked query performance runs at .0386 ms roughly.
=================================================================
Problem Statement:
Gateway clock drift / SQL performance spikes seem to trap Transactional Group records in Store / Forwards.
1. Not sure how to notify the group when this happens.
2. Manual recovery required?
=================================================================
Test Case:
1. To try to get a bit more detail on the issue I tried to replicate the issue locally on my PC with a local instance of Ignition / SQL.
2. I set up a transactional group, and locked a DB on the SQL instance to see if records would get stuck in Store and Forward… No luck
o I ran the same script locally and no issue on the Ignition instance.
o Mind you the scale is a lot smaller.
=================================================================
Question:
1. For the use case of inserting (X) number of records from an API response, what is the best way to throttle input SQL side?
o I don’t believe invoke later works scripting side.
o I cant delay the active thread without causing clock drift on the gateway.
o I could cache results with one script and process the records with a secondary script. I’ve been actively discouraged to make files for this approach.
§ If a file was made, potentially could do a SQL merge to reduce burden SQL side.
o Potentially could limit the scope via the API call, but given the number of records preference would be to have the delay roughly around 50 ms per call not seconds.
2. For the Ignition Gateway, do I need to be concerned about long running scripts adding to the clock drift?
a. I thought the gateway was multithreaded, but it was acting as if it was executing scripts procedurally on a single thread.