Single-writer guard for the on-disk KB.
The disk record store and the disk KV index have no cross-process file locking:
two JVMs appending to the same logs tear them. This namespace takes an OS advisory
FileLock on <dir>/.vaelii.lock when a disk backend opens, and fails fast if
another live JVM already holds it. This matches pure's single-writer contract
(docs/storage.md) — one process holds the KB.
The lock is exclusive and ref-counted per canonical directory (the record store and
the index share one dir, so both acquire and the last release drops it). The OS
releases it when the JVM exits, so a crash leaves no stale lock to reap. Set
vaelii.disk.lock=false (system property) to disable in a trusted single-host
scenario.
Single-writer guard for the on-disk KB. The disk record store and the disk KV index have no cross-process file locking: two JVMs appending to the same logs tear them. This namespace takes an OS advisory `FileLock` on `<dir>/.vaelii.lock` when a disk backend opens, and fails fast if another live JVM already holds it. This matches pure's single-writer contract (docs/storage.md) — one process holds the KB. The lock is exclusive and ref-counted per canonical directory (the record store and the index share one dir, so both acquire and the last release drops it). The OS releases it when the JVM exits, so a crash leaves no stale lock to reap. Set `vaelii.disk.lock=false` (system property) to disable in a trusted single-host scenario.
(acquire! dir)Acquire the single-writer lock for dir. Reentrant + ref-counted per canonical
dir. Returns :acquired, :reentrant, or :disabled; throws ex-info (:type :disk-locked) when another JVM holds it.
Acquire the single-writer lock for `dir`. Reentrant + ref-counted per canonical dir. Returns :acquired, :reentrant, or :disabled; throws `ex-info` (`:type :disk-locked`) when another JVM holds it.
(disabled?)(held? dir)True when this JVM holds dir's lock (or locking is disabled).
True when this JVM holds `dir`'s lock (or locking is disabled).
(release! dir)Drop one ref on dir's lock; release the OS lock when the last ref goes. No-op
when disabled or not held by this JVM.
Drop one ref on `dir`'s lock; release the OS lock when the last ref goes. No-op when disabled or not held by this JVM.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |