Repository navigation
Bulk loads exclude regular updates (pometry-storage#425) - #2861
Merged
Merged
Conversation
GraphStore owns a bulk_loader_lock. WriteLockedGraph takes the write guard for its lifetime, so a bulk load or WAL replay excludes every regular update. transaction_manager() now returns a TransactionGuard that holds a read_recursive guard, so regular updates still run concurrently with each other. import_node_internal and load_graph_props_from_df take it explicitly, and vacuum takes the read guard. Fixes Pometry/pometry-storage#425 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fabubaker
reviewed
Oct 15, 2026
Comment on lines
+309
to
+318
| /// Recursive, so a regular update nested in another does not wait behind a queued bulk load. | ||
| pub fn bulk_load_read(&self) -> RwLockReadGuard<'_, ()> { | ||
| self.bulk_loader_lock.read_recursive() | ||
| } | ||
|
|
||
| /// Write guard held for the whole of a bulk load or WAL replay. | ||
| pub fn bulk_load_write(&self) -> RwLockWriteGuard<'_, ()> { | ||
| self.bulk_loader_lock.write() | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Minor but calling these bulk_load_shared and bulk_load_exclusive conveys the intention more precisely
Contributor
There was a problem hiding this comment.
Or maybe even rename bulk_loader_lock -> write_lock - then write_lock_shared for the regular updates and write_lock_exclusive for the bulk loaders?
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.
Fixes Pometry/pometry-storage#425. See ADR-0001 in pometry-storage.
Summary
Every regular update (add/delete edge, add node, set node type, node/edge/graph properties and metadata) already calls
transaction_manager()first and keeps it to the end, so they now hold the read guard for their full duration with no call-site changes. WAL recovery goes throughwrite_lock()and so holds the write guard.Evidence
New tests in
io_tests/df_loaders.rs:WriteLockedGraphtakes a read guard instead): both fail. The exclusion test fails with "ran while the graph was write locked for a bulk load". The concurrency test fails with wrong node/edge counts in one run and deadlocks (60s timeout) in another.test_io67 passed / 6 ignored,test_lib113 passed / 3 ignored,test_graphs200 passed,test_nodes_edges39 passed / 1 ignored.db4-storage,db4-graphandraphtory-storagetests pass.cargo check --workspace --testsis clean here and in pometry-storage.Merge Danger
Door: two-way
Revert the commit to restore the old behaviour; nothing is persisted.
Blast Radius: mutations
read_recursive, a steady stream of regular updates can delay a bulk load from starting.vacuum) from inside a bulk load, on the same thread, now deadlocks. No such call exists today; the doc comment ontransaction_manager()says so.load_graph_props_from_dfholds the read guard for the whole load, so a concurrent bulk load waits for it.🤖 Generated with Claude Code