Skip to content

Commit

Permalink
Provide a stale_age to mkpidlock
Browse files Browse the repository at this point in the history
Normally the pidlock should be held for a short duration; waiting for
its age to exceed the given limits of 10 seconds (for the fake gaproot,
which normally finishes in milliseconds) resp. 300 seconds (for
installing packages, which only takes a few seconds for most, but a few
bad ones can take minutes) until we consider it stale should be safe in
each use case. In fact Julia waits 5 times longer if the process
creating the pid lock file seems to be still running.

On the other hand, without a stale age, the lock file is *never*
considered stale, even if the process creating it definitely is gone,
and so the user can get stuck, which obviously is very bad. To
get unstuck they need to manually delete the lock file.
  • Loading branch information
fingolfin committed Jul 5, 2024
1 parent 48061b6 commit 45cf72f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ function install(spec::String, version::String = "";
# point PackageManager to the given pkg dir
Globals.PKGMAN_CustomPackageDir = GapObj(pkgdir)
mkpath(pkgdir)
Pidfile.mkpidlock("$pkgdir.lock") do
# pidlock timeout: 300 seconds = 5 minutes should suffice; about the
# slowest packages to install are Semigroups and NormalizInterface.
Pidfile.mkpidlock("$pkgdir.lock"; stale_age=300) do
if quiet || debug
oldlevel = Wrappers.InfoLevel(Globals.InfoPackageManager)
Wrappers.SetInfoLevel(Globals.InfoPackageManager, quiet ? 0 : 3)
Expand Down
2 changes: 1 addition & 1 deletion src/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function regenerate_gaproot()

# create the mutable gaproot
mkpath(gaproot_mutable)
Pidfile.mkpidlock("$gaproot_mutable.lock") do
Pidfile.mkpidlock("$gaproot_mutable.lock"; stale_age=10) do
# create fake sysinfo.gap
unquoted = Set(["GAParch", "GAP_ABI", "GAP_HPCGAP", "GAP_KERNEL_MAJOR_VERSION", "GAP_KERNEL_MINOR_VERSION", "GAP_OBJEXT"])
open("$gaproot_mutable/sysinfo.gap", "w") do file
Expand Down

0 comments on commit 45cf72f

Please sign in to comment.