-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce risk of loosing/currupting data #12
Comments
I am going to implement this like suggested here for a different project: simonlast/node-persist#94 (comment) |
Another option that would probably be simpler to implement would be using the database as a pseudo application directory as in this article, which would provide atomic updates more or less for free, and avoid having to go through the whole file to read/write state. The shadowing would probably be somewhat more performant overall, just requires more work and file system stuff. |
I think the suggestion to use a database with a pseudo application directory is very good, since it will greatly improve performance. |
Fixed by #22.
However, the underlying issue of loosing data is solved, and all these improvements are performance improvements only. |
If the software or the PC crashes the queue might have been in the middle of writing data to the file system, which could lead to a corrupted file.
To prevent this, the queue could write the data to a shadow file, wait for a file system sync, and then atomically rename the new file to the actual file name.
A solution to the problem could be to use this algorithm: https://stackoverflow.com/a/7957634
But with the following changes:
The text was updated successfully, but these errors were encountered: