You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix mutation persistence in persistent backends (#553)
PR #370 removed `Referable.commit()` and all call sites in the `server`
handlers without replacing the write-back mechanism. Since then, any
mutation to an object retrieved from `LocalFileIdentifiableStore`,
`LocalFileDescriptorStore`, or `CouchDBIdentifiableStore` was silently
lost on cache eviction, visible only within the same in-process
`WeakValueDictionary` cache entry. A different uWSGI worker, or any
request after the cache entry expired, would re-read the stale on-disk
or on-database state.
There was also a compounding bug: `get_item()` / `get_identifiable_by_hash()`
always re-read from storage even on a cache hit, then called
`update_from()` on the cached object, discarding any in-memory
mutations even within the same request.
This change fixes both issues across all three backends:
- `get_identifiable_by_hash()` / `get_identifiable_by_couchdb_id()`: return the cached instance on a hit instead of overwriting it with a freshly-deserialized copy.
- `get_item()`: check the cache first and return immediately on a hit.
- Add `commit()` to `LocalFileIdentifiableStore` (re-serializes to .json), `LocalFileDescriptorStore` (same), and `CouchDBIdentifiableStore` (PUT with stored `_rev`, updates revision on success).
- `AbstractObjectStore.commit()` is added as a no-op default so in-memory stores (`DictIdentifiableStore`) require no changes.
All mutating handlers in `server/app/interfaces/repository.py` and `registry.py` now call `self.object_store.commit()` after each mutation.
- A regression test `test_mutation_persistence` is added to `sdk/test/backend/test_local_file.py`.
Fixes#552
0 commit comments