Repository navigation
Stores: lock(key), an exclusive named lock (#70) - #74
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
store.lock(key): an exclusive, named context manager scoped to the store's data (forPostgresStore, its owner and project). Needed by reeleehq/reelee#632.IntervalAnnotationStore.lock(key)in the protocol, with the semantics documented there: same key excludes, different keys do not, a dead holder releases it, not re-entrant.PostgresStore: session-levelpg_advisory_lockkeyed on a 64-bit blake2b hash of owner + project + key (length-prefixed parts, so no concatenation collisions), on a dedicated connection and released infinally; a crashed holder frees it when its connection drops.SqliteStore: a file lock (flock,msvcrton Windows) on a sidecar file per key beside the.annot; excludes threads and other processes on the host.:memory:falls back to a process-local lock.MemoryStore/MappingStore: process-local named locks; copies and pickles get fresh locks.lacing/store/locking.py.Tests:
tests/test_store_lock.py(all in-process backends, plus a cross-process SQLite case) andTestLockintests/test_store_postgres.py, run against a real PostgreSQL server: two connections contend for one key (second blocks until the first releases), different keys and different projects do not contend, release on exception. Full suite: 906 passed.Closes #70
🤖 Generated with Claude Code