-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
file locking #7176
Comments
I'm not sure what the status of support for this on Windows is, but there is both advisory and mandatory file locking. I prefer advisory file locking myself, but maybe we should support both in a portable way. There also seem to be distributed file system considerations. |
Possibly relevant or at least interesting: https://lwn.net/Articles/586904/. |
We'll want this as part of the Pkg revamp. |
Relevant libuv issue: joyent/libuv#1533. It seems like it is impossible to do this in a cross-platform way. |
Our userbase probably has a higher % of NFS usage than the general population due to research clusters / shared computing resources, so the issues on NFS would be a major concern. Relevant:
|
This would make an excellent up for grabs project, requiring mostly research into how to do locking on various platforms. |
This may just work. Use a named socket as a lock file.
Closing the named socket releases the lock. The path can be |
I was commenting in the context of parallel loading, but the locking need is the same. |
Will not work if the cache/pkg is on a shared directory, but for that we would need a truly distributed lock anyway. |
what's wrong with flock? |
Don't know the reasons but the linked libuv issue mentions that there is no cross-platform way to implement file locking. |
The issue seems to be mostly about nfs or similar shared fs. Using a socket wont do much better either. Using a socket also has the issue that the lock wont be fully released if the owner crashed |
One issue with using For us to manage locking via a file using libuv's open call via If we ignore the shared fs scenario for now, we could still go with the unix domain socket option that the acquirer can unlink if unable to connect to it. So the polling mechanism would be
|
Can use
A solution for non-shared filesystems would be a good start for now. |
#5622 says that libgit2 provides this functionality in a cross-platform way, so maybe we just need to export it? |
@stevengj: not sure why the comment there refers to atomic symlinks. As far as I can tell libgit2 uses plain old lockfiles and open/_wopen: https://github.com/libgit2/libgit2/blob/79194bcdc956406979cd27ac99198826860d3f20/src/fileops.c#L66-L77 |
I've created the Pidfile.jl package for this. We should probably keep this open until we move that into Base (for use with |
If we are to bring in Pidfile.jl, would it need to live in Base, or could it be a stdlib? I guess if it is used at the |
Pidfile is now in Base so I think this can be closed. |
More precisely, it's part of the FileWatching stdlib (#44367) |
Sometimes you want to make sure that multiple processes don't update the same file at the same time. For example, Pkg should lock the
~/.julia/REQUIRE
file when installing or removing packages, and when writing the the ~/.julia_history` file, the REPL should lock it (or use atomic operations like seek-and-write in a true append mode).The text was updated successfully, but these errors were encountered: