fix(graph): roll back on COMMIT failure in batched link_edges#6
Merged
Conversation
The batched edge writer rolled back on a mid-batch execution error but not when COMMIT itself failed — it just returned the error, leaving the transaction open and risking a dangling transaction/lock on the connection. Make the COMMIT path symmetric with the mid-batch path: on commit failure, best-effort ROLLBACK then return the error with context. Bumps version to 0.1.5.
Review Summary by QodoRoll back on COMMIT failure in batched link_edges
WalkthroughsDescription• Add rollback on COMMIT failure in batched link_edges • Prevent dangling transactions/locks on commit errors • Make error handling symmetric for mid-batch and commit failures • Bump version to 0.1.5 Diagramflowchart LR
A["Batch execution"] --> B{"Result OK?"}
B -->|Yes| C["Execute COMMIT"]
B -->|No| D["ROLLBACK + return error"]
C --> E{"COMMIT success?"}
E -->|Yes| F["Return OK"]
E -->|No| G["ROLLBACK + return error"]
D --> H["Error handled"]
G --> H
F --> I["Transaction complete"]
File Changes1. src/graph/ladybug_store.rs
|
Code Review by Qodo
1. Unrelated Cargo.toml version bump
|
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.
Addresses a Qodo review finding on the batched edge writer (#5).
Problem
LadybugGraphStore::link_edgesrolls back on a mid-batch execution error, but theCOMMITpath just returned the error without rolling back. A failedCOMMITleaves the transaction open, risking a dangling transaction/lock on the connection — asymmetric with the mid-batch error handling.Fix
Make the
COMMITpath symmetric: on commit failure, do a best-effortROLLBACK(ignoring rollback errors) and return the commit error with context.Kept the simple symmetric form rather than an RAII guard — lbug transactions are plain
query("BEGIN"/"COMMIT"/"ROLLBACK")calls with no transaction handle type, so a guard would add indirection without much benefit at this scale.Tests
Full suite (79 tests),
cargo fmt --check, andcargo clippy --all-targetsall green. The commit-success path is covered by the existingladybug_link_edges_batch_roundtripssmoke test; the commit-failure branch isn't reliably triggerable without faking a backend error, so no brittle test was added for it.Bumps version to 0.1.5.