Skip to content
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

Pkg.add race condition #5622

Closed
jiahao opened this issue Jan 30, 2014 · 6 comments
Closed

Pkg.add race condition #5622

jiahao opened this issue Jan 30, 2014 · 6 comments
Labels
packages Package management and loading
Milestone

Comments

@jiahao
Copy link
Member

jiahao commented Jan 30, 2014

Somewhat perverse, but if you Pkg.add in one Julia instance and while that is going, start another Julia instance and Pkg.add something else, it deletes all the previously pulled packages from the first instance.

Example:

julia> Pkg.add("GSL") #Instance 1
INFO: Cloning cache of BinDeps from git://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of GSL from git://github.com/jiahao/GSL.jl.git
INFO: Cloning cache of Homebrew from git://github.com/JuliaLang/Homebrew.jl.git
INFO: Cloning cache of URIParser from git://github.com/loladiro/URIParser.jl.git
INFO: Installing BinDeps v0.2.12
INFO: Installing GSL v0.1.1
INFO: Installing Homebrew v0.0.4
INFO: Installing URIParser v0.0.1
INFO: Building Homebrew
INFO: Cloning brew from https://github.com/staticfloat/homebrew.git
... (builds)
julia> Pkg.add("Example") #Instance 2
INFO: Cloning cache of Example from git://github.com/JuliaLang/Example.jl.git
INFO: Installing Example v0.0.0
INFO: Removing BinDeps v0.2.12
INFO: Removing GSL v0.1.1
INFO: Removing Homebrew v0.0.4
INFO: Removing URIParser v0.0.1
INFO: Package database updated

(GSL build in Instance 1 dies horribly a short while later)

@JeffBezanson
Copy link
Member

I don't think we intended to guard against this.

@mlubin
Copy link
Member

mlubin commented Jan 31, 2014

Given that Pkg commands are not quite instantaneous, I think this is a relatively common issue that users could run into.

@StefanKarpinski
Copy link
Member

We should probably use file locking to avoid this sort of race condition. Until now, I've just let it go, but obviously it would be better to handle it correctly. @loladiro, @vtjnash – what's the status of file locking APIs that libuv gives us? Do we have a single API that will work across platforms or do we need to implement that ourselves?

@staticfloat
Copy link
Member

Doesn't git already solve this for us? If I try to git commit something while I'm already git commit'ing something, it fails, giving me this error:

$ git commit -a
fatal: Unable to create '/tmp/repo/.git/index.lock': File exists.

Would it not be simpler to roll this into Pkg once we're using libgit2 directly?

@jakebolewski
Copy link
Member

@staticfloat you are right. libgit2 does implement a cross platform locking mechanism
(see https://github.com/libgit2/libgit2/blob/79194bcdc956406979cd27ac99198826860d3f20/src/fileops.c#L66) which uses atomic symlinks. I'll update LibGit2.jl to incoporate this so we can ultimately leverage this in Pkg.

@malmaud
Copy link
Contributor

malmaud commented Oct 14, 2015

I'm speculatively removing the parallel tag since this doesn't seem to concern parallel computation.

@malmaud malmaud removed the parallelism Parallel or distributed computation label Oct 14, 2015
This was referenced Jul 7, 2016
@vchuravy vchuravy added this to the 0.6.x milestone May 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Package management and loading
Projects
None yet
Development

No branches or pull requests

8 participants