Skip to content

Stores: lock MappingStore setitem/delitem, snapshot iteration (#68) - #73

Merged
thorwhalen merged 2 commits into
mainfrom
fix/store-lock-snapshot-68
Oct 14, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
fix/store-lock-snapshot-68

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses the three follow-ups of #68 (review of #67):

  • MappingStore.__setitem__ / __delitem__ now run under the store lock, like add / remove / update, so an update racing one of them cannot bring a deleted key back into the backing mapping.
  • MemoryStore.__iter__ (and so MappingStore) iterates a snapshot taken under the lock, and __len__ takes the lock, so a moving update can no longer raise "dictionary changed size during iteration". (MemoryStore is not a Mapping subclass and defines no items() / values(), so __iter__ was the only iteration path.)
  • The Postgres TestUpdate tests were run against a real PostgreSQL server (all of test_store_postgres.py passes), and a moving-update-under-concurrency case was added (test_moving_update_under_concurrent_readers: the id is looked up by all() and by an interval query while it alternates between two intervals).
  • Tests in tests/test_store_update.py: iteration under moving updates for both stores, and a delitem-vs-update consistency check on the backing mapping. All three fail on main and pass here.

Closes #68

🤖 Generated with Claude Code

thorwhalen and others added 2 commits October 14, 2026 12:44
…ore iteration (#68)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 39645a6 into main Oct 14, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the fix/store-lock-snapshot-68 branch October 14, 2026 12:54
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.

Store update: lock MappingStore setitem/delitem, snapshot iteration, run Postgres update tests

1 participant