Open giordano opened 3 years ago
I don't think any effort has gone into making package operations threadsafe. Would probably make sense to just have a "global package lock" that prevents more than one package operation from being in progress at a time.
This is an issue for Pluto users, since starting two notebooks at the same time is fairly common. This also means that we can't run notebooks in parallel inside github actions.
I can implement this lock in the future built-in Pkg stuff, but users who manage their environment manually (by calling Pkg.activate
) will still be affected.
Are the notebooks run in the same process?
Thanks for pointing that out -- no, it's on separate processes, so my guess is that this issue is present in any form of parallelism on the same file system. Maybe the registry update process?
There's two levels of potential synchronization needed: same process and inter-process. In the one process, we can just put a global lock at the entrance to Pkg APIs. Locking between processes is much harder; we could use a mechanism like flock
but that doesn't work on all file systems (notoriously not on NFS, iirc). We also don't need to lock between processes all the time. Since many of the things that Pkg installs are immutable, it's often fine if two processes are doing it concurrently as long as we use the pattern of creating a temp version in the same file system and then only move it into place at the last moment. That way one of the two processes "wins" by going last, but it doesn't matter since they both install identical content.
This package (solves and) references more discussions about this issue: https://github.com/simonbyrne/PkgLock.jl
In Yggdrasil, where we happen to install the same packages in parallel, we have often issues with files that disappear. Last example:
So
Pkg.add
deletes files?