Skip to content

Close graph-lock gaps in GraphModel.Serialization - #289

Merged
mbastian merged 3 commits into
masterfrom
fix/serialization-read-lock-gap
Aug 25, 2026
Merged

mbastian merged 3 commits into
masterfrom
fix/serialization-read-lock-gap

Conversation

@mbastian

Copy link
Copy Markdown
Member

Summary

  • serializeGraphStore() previously relied on incidental locking from NodeStore/EdgeStore iterators, which only cover the node loop and the edge loop individually and drop the lock between them (and never covered the configuration/columns/time-store/views sections at all). It now holds the read lock for the entire method, making a serialized snapshot atomic against concurrent structural mutation.
  • deserializeGraphStore() had no lock coverage at all — it writes directly into NodeStore/EdgeStore, bypassing GraphStore's own auto-locked addNode()/addEdge(). It now holds the write lock for the entire method.

Both changes are internal to Serialization; no public API or on-disk format changes.

Test plan

  • Added testSerializeGraphStoreHoldsReadLockForEntireDuration: uses a DataOutput that blocks on its first write so a concurrent writeLock() attempt can be asserted to block until serialization completes. Verified it fails on the pre-fix code and passes after.
  • Added testDeserializeGraphStoreHoldsWriteLockForEntireDuration: mirrors the above with a blocking DataInput and a concurrent readLock() attempt. Verified red/green the same way.
  • Full suite passes (1638 tests).

🤖 Generated with Claude Code

Previously the only locking came incidentally from NodeStore/EdgeStore
iterators, which release the lock between the node and edge loops and
leave the configuration/columns/time store/views sections unprotected,
so a serialized graph could observe a torn state under concurrent
mutation.
…Store

deserializeNode/deserializeEdge write directly into NodeStore/EdgeStore,
bypassing GraphStore's own auto-locked addNode()/addEdge(), so
deserialization had no lock coverage at all and could race with a
concurrent reader on the same graph model.
@mbastian mbastian added this to the 0.8.7 milestone Aug 25, 2026
@mbastian
mbastian merged commit a5e35c2 into master Aug 25, 2026
1 check passed
MattArtzAnthro pushed a commit to MattArtzAnthro/graphstore that referenced this pull request Aug 28, 2026
* Hold the graph read lock for the entire duration of serializeGraphStore

Previously the only locking came incidentally from NodeStore/EdgeStore
iterators, which release the lock between the node and edge loops and
leave the configuration/columns/time store/views sections unprotected,
so a serialized graph could observe a torn state under concurrent
mutation.

* Hold the graph write lock for the entire duration of deserializeGraphStore

deserializeNode/deserializeEdge write directly into NodeStore/EdgeStore,
bypassing GraphStore's own auto-locked addNode()/addEdge(), so
deserialization had no lock coverage at all and could race with a
concurrent reader on the same graph model.

* Cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant