11-02-2021 02:36 PM - edited 11-02-2021 02:50 PM
Hello,
I have a custom method to replace a single record in a datalog file, by first reading the preceding section and writing it to a temp file, then writing the updated record, followed by the remaining records. The original file is then deleted, and the temp record moved to the original location. At sporadic times, this replacement method is causing a corruption of the datalog file:
when using Set Datalog Position, at offset 0, I receive an error code 4, and at offset 1 I receive an error code 116.
(This error started to occur after moving to a Windows 2016 server. )
Attached is a code sample.
I have not been able to replicate the error on my own machine. Based on activity logs, the best I can tell is that this issue occurs when one user is writing to the datalog file while another user is attempting to update a record in the file. I'm wonder if this is an issue with the Deny Access.vi, which is noted in documentation to not work with datalog files. However, Labivew does let me use it with datalog files. Perhaps it doesn't work as it should. Does anyone know of another possible cause of these errors?
Does anyone have an alternative? I'm aware the of Set Permissions option, but this only marks the file as Read Only, which is too easily changed.
For questions regarding why datalog data is being type casted, or why we're using deny access see these two topics:
11-02-2021 04:44 PM
I've not used Datalog files, myself, but they appear to be prone to corruption if opened (and closed) by more than one person at a time. It appears that a few decades ago (possibly before Windows XP), LabVIEW had the ability to "lock" a file, allowing "first come, first served" access. This doesn't appear to be available now. In addition, you've placed the file on a Server, where anyone can access it. You need some form of Version Control on these Files, or some form of File Locking.
Bob Schor
11-03-2021 08:30 AM
Hi Bob,
Any idea why this file lock is no longer available through LabView on Datalog files?
If I use Windows API to lock the file, I would not be able to edit the file from within my application unless I continue to use the handle returned by the Windows API, correct? Which would mean creating my own set of file read/write vis. It just seems so odd to not allow file locking for datalog files as part of a native function of Labview.
I feel like I'm missing some key information here.