Skip to content

feat(storage): acquire cross-process lock on database open - #47

Merged
Patel230 merged 6 commits into
mainfrom
feat/storage-process-lock
Aug 15, 2026
Merged

feat(storage): acquire cross-process lock on database open#47
Patel230 merged 6 commits into
mainfrom
feat/storage-process-lock

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Phase 1 SQLite hardening (1/5).

  • Add ProcessLock using flock(2) on <db>.lock next to the database file
  • Acquired in NewStore(), released in Close()
  • In-memory DSNs are a no-op
  • Fast-fail with a clear error when another yaad process holds the lock
  • Add TestProcessLock

Merge order: this first, then migrations, pragma/metrics, hnsw, backup.

- New storage/lock.go: ProcessLock using flock(2) for cross-process safety
- storage/sqlite.go: Acquire lock in NewStore(), release in Close()
- Integrity check (PRAGMA integrity_check) on open
- In-memory DSNs bypass lock
- Test: TestProcessLock verifies exclusive access, release, and in-memory bypass
- Route lock release errors properly (no unchecked Close/Flock)
- golang.org/x/sys is a direct dependency (direct import), go mod tidy

CI triage on PR #47.
Patel230 added a commit that referenced this pull request Aug 15, 2026
Brings PR #47's lock wiring forward so this branch is self-contained
and merges trivially once #47 lands. CI triage on PR #50.
…kFileEx windows)

CI builds windows/amd64, where unix.Flock does not exist. lock_unix.go
(!windows) uses flock(2); lock_windows.go uses LockFileEx with
FAIL_IMMEDIATELY for the same non-blocking exclusive semantics.
@Patel230
Patel230 merged commit 6f75460 into main Aug 15, 2026
12 checks passed
@Patel230
Patel230 deleted the feat/storage-process-lock branch August 15, 2026 08:30
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.

1 participant