Skip to content

Commit a6ba71f

Browse files
set stale_age on cachefile lock
1 parent 779acf7 commit a6ba71f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

base/loading.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,11 +2824,15 @@ global parse_pidfile_hook
28242824
# with different preferences at the same time.
28252825
compilecache_pidfile_path(pkg::PkgId) = compilecache_path(pkg, UInt64(0)) * ".pidfile"
28262826

2827-
# allows processes to wait if another process is precompiling a given source already
2828-
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String)
2827+
# Allows processes to wait if another process is precompiling a given source already.
2828+
# The lock file is deleted and precompilation will proceed after `stale_age` seconds if
2829+
# - the locking process no longer exists
2830+
# - the lock is held by another host, since processes cannot be checked remotely
2831+
# or after `stale_age * 25` seconds if it does still exist.
2832+
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String; stale_age=60)
28292833
if @isdefined(mkpidlock_hook) && @isdefined(trymkpidlock_hook) && @isdefined(parse_pidfile_hook)
28302834
pidfile = compilecache_pidfile_path(pkg)
2831-
cachefile = invokelatest(trymkpidlock_hook, f, pidfile)
2835+
cachefile = invokelatest(trymkpidlock_hook, f, pidfile; stale_age)
28322836
if cachefile === false
28332837
pid, hostname, age = invokelatest(parse_pidfile_hook, pidfile)
28342838
verbosity = isinteractive() ? CoreLogging.Info : CoreLogging.Debug
@@ -2839,7 +2843,7 @@ function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String)
28392843
end
28402844
# wait until the lock is available, but don't actually acquire it
28412845
# returning nothing indicates a process waited for another
2842-
return invokelatest(mkpidlock_hook, Returns(nothing), pidfile)
2846+
return invokelatest(mkpidlock_hook, Returns(nothing), pidfile; stale_age)
28432847
end
28442848
return cachefile
28452849
else

0 commit comments

Comments
 (0)