Repository navigation
Close graph-lock gaps in GraphModel.Serialization - #289
Merged
Merged
Conversation
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.
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
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.
Summary
serializeGraphStore()previously relied on incidental locking fromNodeStore/EdgeStoreiterators, 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 intoNodeStore/EdgeStore, bypassingGraphStore's own auto-lockedaddNode()/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
testSerializeGraphStoreHoldsReadLockForEntireDuration: uses aDataOutputthat blocks on its first write so a concurrentwriteLock()attempt can be asserted to block until serialization completes. Verified it fails on the pre-fix code and passes after.testDeserializeGraphStoreHoldsWriteLockForEntireDuration: mirrors the above with a blockingDataInputand a concurrentreadLock()attempt. Verified red/green the same way.🤖 Generated with Claude Code