Skip to content

Creating a branch at a past point holds the erasure admission lock through a full replay #2333

Open

Description

@bplatz

Problem

Creating a branch at a past point of its source (fluree branch create rewind --at t:5) holds the erasure admission lock while it replays the ledger's history, which blocks every erasure on the server for as long as the replay takes.

Branch creation takes the admission lock's read side (fluree-db-api/src/ledger/loading.rs, create_branch) so that an erasure accepted or published at the same moment cannot miss the new branch. Accepting or publishing an erasure takes it exclusively. The lock is one per server, not per ledger.

A branch made at a past point copies no index: it replays its commits from genesis. When the ledger's removal journal holds removals, creation also calls retract_removed_at_branch_point (retention/lineage.rs): the branch point can predate a removal, so a removed value may be current there. It loads the unlisted branch's state (load_unlisted_state, a full replay up to the point) and retracts those occurrences before the branch is listed. All of it runs under the read lock.

So on a ledger with a long history:

  • every erasure request and publication on the server, for any ledger, waits for the replay;
  • the lock is fair, so branch creations queued behind a waiting erasure wait too.

Scope: file storage with erasure available, branches created with --at, ledgers whose journal holds removals. It is a stall, not a correctness problem.

Possible fixes

  • Build the branch's state at the point from the newest index at or before it plus the commits after it, as HistoricalLedgerView does, instead of replaying from genesis.
  • Or load the state and find the occurrences to retract before taking the lock, then under the lock check that no removal or erasure arrived meanwhile (journal generation, erasure index version), redoing the work only if one did.

Test

A branch created --at a point before a removal on a ledger with many commits must not hold an erasure request for longer than the lock check, and must still retract the removed value at the branch point (the existing branch-point retraction tests in it_retention_history.rs cover the latter).

Follow-up from #2280.

Activity

  1. added
    P3
    area:transact
    performance
    on Nov 11, 2026
  2. added this to the 5.0.0 milestone on Nov 12, 2026
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

    P3area:transactperformance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions