objcache: stop leaking SysV semaphores on macOS, and disable quietly when they run out (#64447)
* objcache: Disable the cache quietly when opening it fails with `ENOSPC`
On macOS, LMDB locks the cache with SysV semaphores. Once the system-wide
semaphore limit is reached, opening the cache fails with `ENOSPC`, and
every Julia process on the machine printed an `objcache error` line. The
extra stderr output breaks tests and tools that expect a silent run, as on
the macOS CI machines.
Treat `ENOSPC` like the other expected conditions: disable the cache and
record why, so the REPL banner can explain it.
See https://buildkite.com/julialang/julia-ci/builds/1229#01a1852f-5b7a-48c7-b7fe-b9ee76dcd3dc
and #63789.
Assisted-by: Claude Code (Opus 5.5)
* objcache: Remove LMDB's SysV semaphores when the process exits
On Apple platforms LMDB locks the cache with a SysV semaphore set, which
only `mdb_env_close` removes, and only in the last process using the
cache. Julia never closes the environment, because the JIT keeps buffers
that point into its memory map. So every process that opened a new cache
directory left a semaphore set behind until reboot. Temporary depots are
common in tests, and the macOS CI machines regularly ran out of
semaphores.
Patch LMDB with `mdb_env_release_locks`, which does only the semaphore
part of `mdb_env_close` and leaves the memory map alone, and call it at
shutdown. Transactions started after that point would need the
semaphores, so starting one now takes a shared lock that shutdown takes
exclusively. A process that opens the cache just as the last other user
removes the semaphores retries once.
Fixes #63789
Assisted-by: Claude Code (Opus 5.5)
* objcache: Remove the SysV semaphores when several cache users exit together
The previous commit removed the semaphore set only when the exiting
process could upgrade its shared lock on the lock file to an exclusive
one. When several processes sharing a cache exit at the same time, each
sees the others' shared locks and none removes the set, which parallel
test workers and CI jobs do regularly. Now each process drops its shared
lock before trying the exclusive one, so the last of them removes the
set.
Assisted-by: Claude Code (Opus 5.5)