Skip to content

[bug] Cross-parent move_node is non-transactional — a mid-op failure orphans the node #1429

Closed

Description

@mstomar125

Severity: high · Confidence: high

Moving to a different parent (sqlite_store.rs:1559-1571) runs two separate db.execute calls with no enclosing transaction: DELETE the old has_child edge, then INSERT the new one. If the INSERT fails (constraint/IO/crash/cancel) the DELETE is already committed → node left with no has_child edge (silently orphaned root). Sibling functions move_children_to_parent and delete_subtree_atomic correctly wrap their multi-statement mutations in a transaction; this path does not.

Fix: wrap delete-old + insert-new (and the make-root delete) in one tx + commit().


Found via the 2026-06-18 multi-repo bug-hunt sweep. Confidence/severity from the sweep + spot-verification.

Activity

  1. mstomar125 commented on Jun 24, 2026

    @mstomar125
    ContributorAuthor

    Resolved in #1453 (Batch A). Wrapped the cross-parent delete-old + insert-new has_child edges in one transaction() + commit() so a mid-op INSERT failure can no longer leave the node orphaned (no parent edge). Make-root / same-parent-reorder are single statements, already atomic. New test test_move_node_cross_parent_leaves_exactly_one_edge; cargo fmt + clippy -D warnings clean.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions