You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It locks the file.txt for 10 seconds, and during this time I shouldn't be able to write the file from other processes(if I understand it correctly), but I can open the file in windows "notepad" and change the text.
Here is the code I run in parallel, and it also does rewrite the file.txt :
I was searching for a solution of AWS EFS advisory locking mechanism inside Node.js and just find this library.
As I understand the mechanics of the library, every thread, process, application or machine must access the shared file-system with this library, because it uses mkdir and mtime system functions to provide the locking behaviour. These guarantee atomicity of operations. If you lock a file with proper-lockfile, but then access the same file directly (even using Node.js), then you are not using the locking behaviour, you're just "jumping over it". This is because it works like an advisory lock in PostgreSQL, that is, it works if every party respects the mechanism, but is not enforced by the system.
I'm able to write to a file despite the library is working. Here is my "locking" code:
It locks the file.txt for 10 seconds, and during this time I shouldn't be able to write the file from other processes(if I understand it correctly), but I can open the file in windows "notepad" and change the text.
Here is the code I run in parallel, and it also does rewrite the file.txt :
So, what does the lib do?
Thanks!
The text was updated successfully, but these errors were encountered: