10-02-2024 09:25 AM
Hi all,
I've come across a curious problem. So I have a test bench which collects measurements, puts it into a queue to be saved into local txt files. A second queue saves the same data into an SQL databank.
The reason for two separate queues was that writing into the SQL databank had a slight delay, and would sometimes freeze the program. With the queues the data could still be written locally if the SQL databank went offline for some reason or so and the program could still run.
Recently I noticed that the data was not being written into the SQL Databank even though the locally saved files contained all the data. The program has two modes, let's call them Mode 1 and 2, which are separate VIs called into the subpanel of the main VI (only one at a time). Both Mode 1 and 2 have this same structure of data saving. Only Mode 1 has this problem while Mode 2 does not. All the queues in both Mode 1 and 2 are named with different names so that there's no identical name for a queue in different subVis.
What is even more curious, is that several PCs use the same .exe and yet the behavior was only present on some PCs. On my development PC, the problem did not occur when I used the .exe but did when I was in the enviromental mode. At first I suspected a race condition which might have caused this behavior. However after placing probes on the error and queue wires. I noticed that the some of the while loops were not even being executed (see labels in sample code) after working on an initial run. I find that strange because the while loops should have at least started before throwing an error (if one occured). It's even weirder that I still manage to exit all the loops. After rebuilding the exe, it worked for a while and then the problem started again. If it's a memory leak I feel it should have also crashed when Mode 2 is used (which doesn't seem to happen)
Unfortunately the VI is far too large and complex, so I'm attaching a simplified version (LV2023 and LV2018) for how it saves data. When running it an Error 1 GPIB occurs, which doesn't happen in the real program, so I don't know where that came from...
Thank you in advance.
10-03-2024 07:12 AM
Your code working as expected here. The error 1 you reported is caused by releasing the notifier before the top loop executes Get Notifier Status. To prevent this error, wire the error out from that loop to the sequence you are using to synchronize data flow.
I suggest wiring the errors for all Obtain Queue and Obtain Notifier. If any of those throw an error, you likely don't want to start the program.
You may want to try adding small delays in the WriteDataToSQL and WriteDataToLocal cases to simulate your application timing.
Good luck!
10-07-2024 09:50 AM
Instead of having 2 queues and daisy chaining the data, you could send a User Event and have both react simultaneously.