Skip to content

fix(store): use advisory build locks - #854

Merged
jleni merged 4 commits into
mainfrom
fix/advisory-build-locks
Aug 26, 2026
Merged

fix(store): use advisory build locks#854
jleni merged 4 commits into
mainfrom
fix/advisory-build-locks

Conversation

@jleni

@jleni jleni commented Aug 26, 2026

Copy link
Copy Markdown
Member

Fixes #821.

What changed

  • replace per-key PID marker ownership with OS advisory locks
  • use one StoreLock RAII primitive for both build-key and GC locks
  • keep lock files at stable paths to prevent unlink/inode split-brain races
  • make waiters probe advisory-lock availability instead of polling path existence
  • return immediately when a waiter finds an already committed entry
  • remove PID liveness, age-based stale recovery, and the recovery meta-lock

Tests

  • PID metadata is ignored for ownership
  • foreign/unparseable metadata cannot steal a held OS lock
  • concurrent claim has exactly one winner
  • process exit releases a held key lock
  • explicit guard drop unlocks even when a duplicated handle remains alive
  • waiter observes commit after advisory-lock release
  • waiter timeout and no-owner behavior remain bounded
  • focused mutation run: 5 caught, 1 unviable, 0 missed/timeouts
  • just test
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check

Tradeoffs and compatibility

Stable inode identity costs one small persistent lock file per encountered cache key. This is preferable to unlinking lock files, which can split contenders across different inodes; a bounded striped lock table remains an option if lock-file inode growth proves material.

All Kache processes sharing one local store should be upgraded together. Mixed PID-marker/advisory-lock versions cannot provide a sound transition protocol across PID namespaces.

@jleni
jleni force-pushed the fix/advisory-build-locks branch from adcfe96 to 98f45f2 Compare August 26, 2026 15:32
@jleni jleni closed this Aug 26, 2026
@jleni jleni reopened this Aug 26, 2026
@jleni jleni closed this Aug 26, 2026
@jleni jleni reopened this Aug 26, 2026
@jleni
jleni merged commit d08f669 into main Aug 26, 2026
20 checks passed
@jleni
jleni deleted the fix/advisory-build-locks branch August 26, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use FS advisory locks instead of pids for locking?

1 participant