Expand description
Store locking for clink invocations (issue #194).
Every invocation loads the whole store, changes it in memory and saves it
back. Two invocations that overlap would each save their own copy, and the
later save would drop the writes of the earlier one. A StoreLock makes
that read-modify-write exclusive: writers take it exclusively, readers
share it, and a waiter gives up with a “store is locked” error naming the
owner once --lock-timeout passes.
--lock | Lock | Released by |
|---|---|---|
flock | flock/LockFileEx on <db>.lock | the operating system when the holder exits |
pid | the directory <db>.lock.d | the holder; a waiter breaks it when the owner process is gone |
none | nothing | - |
An exclusive flock holder writes its owner record to <db>.lock.owner
and removes it on release, so that waiters and --lock-status can name
it. The record is a file of its own because on Windows the lock keeps
every other process from reading <db>.lock itself.
Structs§
- Lock
Owner - Who holds a store lock.
- Store
Lock - Locks held for one invocation; dropping it releases them.
- Store
Lock Options - The parsed
--lock,--no-lockand--lock-timeoutoptions.
Enums§
- Liveness
- Whether the owner of a lock still runs, as far as this host can tell.
- Store
Lock Kind - The
--lockmechanism.
Constants§
- DEFAULT_
LOCK_ TIMEOUT_ MS - How long a waiter waits by default, in milliseconds.
Functions§
- lock_
dir_ path <db>.lock.d.- lock_
order - The stores of one invocation without duplicates, in the order every process locks them: sorted by absolute path. Each keeps the spelling it was given, which is what messages show.
- lock_
status --lock-status: one line per store and lock kind, without taking or creating any lock that is not already there.- owner_
file_ path <db>.lock.owner: the record of the exclusiveflockholder.