fix(storage): add first-writer-wins write intent conflict detection for AP transactions - #153
Merged
liuuys merged 7 commits intoMay 29, 2026
Merged
Conversation
…or AP transactions Prevent concurrent transactions from silently overwriting each other's write intent on the same edge, which caused committed values to be lost when interleaved with an aborting transaction. - set_edge_property_in_txn / delete_edge_in_txn: check edge.commit_ts for an external txn_id before overwriting, return WriteWriteConflict - commit_at: validate all undo entries before setting self.commit_ts so a failed commit can still be aborted; promote all matching property versions instead of only last_mut(); return explicit errors for missing edge_id_map / block / offset mismatches - abort: verify write intent ownership before restoring commit_ts; update edge block min_ts/max_ts on rollback - Tests: sequential abort-restore test, sequential write-conflict test with specific error type assertion, deterministic 3-barrier concurrent test that guarantees WriteWriteConflict detection
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens AP MVCC transaction correctness by adding first-writer-wins detection for write intents on edges, and by hardening commit/abort bookkeeping to avoid losing committed updates under interleavings with aborting transactions.
Changes:
- Add write-write conflict detection in AP edge mutation paths so a second writer can’t overwrite an existing uncommitted write intent.
- Rework
commit_at/abortto validate and enforce write-intent ownership, and to promote/rollback versions more consistently. - Add new integration tests covering sequential abort-restore, sequential write-conflict, and a deterministic concurrent barrier scenario.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
minigu/storage/src/ap/olap_graph.rs |
Adds write-intent ownership checks to edge set/delete in txn to detect write-write conflicts. |
minigu/storage/src/ap/transaction.rs |
Validates undo entries before committing; promotes all matching property versions; adds intent-ownership checks during abort and updates block ts metadata. |
minigu/storage/tests/ap/transaction_test.rs |
Adds/updates tests for abort-restore behavior and write-write conflict detection, including a barrier-coordinated concurrent scenario. |
.gitignore |
Ignores local .claude/ files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…arly conflict check - commit_at: use TransactionError::InvalidState for missing edge_id_map / block / eid mismatch (internal invariant errors), keep WriteWriteConflict only for genuine owner mismatch - abort: clone undo entries and drop undo_buffer lock before acquiring edges/property locks, fixing a lock-order inversion with write paths that lock edges first then push_undo - set_edge_property_in_txn: move write-intent conflict check to right after edge lookup, before scanning property columns, so conflicting writers fail fast without extra property work
Use SetPropsOp.indices from the undo entry to iterate only the property columns that were actually touched, instead of scanning all columns for every SetEdgeProps operation. Also skip min_ts/max_ts update when no version was promoted (both CreateEdge and SetEdgeProps), preventing spurious max_ts inflation on untouched columns.
# Conflicts: # minigu/storage/tests/ap/transaction_test.rs
WhiteGive-base
approved these changes
May 29, 2026
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.
Prevent concurrent transactions from silently overwriting each other's write intent on the same edge, which caused committed values to be lost when interleaved with an aborting transaction.
fix(storage): add first-writer-wins write intent conflict detection for AP transactions
Type
feat: (new feature)fix: (bug fix)docs: (doc update)refactor: (refactor code)test: (test code)chore: (other updates)Scope
query: (query engine)parser: (frontend parser)planner: (frontend planner)optimizer: (query optimizer)executor: (execution engine)op: (operators)storage: (storage engine)mvcc: (multi version concurrency control)schema: (graph model and topology)tool: (tools)cli: (cli)sdk: (sdk)none: (N/A)Description
Issue: #
Checklist
masterbranch.