Repository navigation
Description
Summary
A soft drop — the default for DELETE /ledger — permanently reserves the ledger alias, and there is no supported way to reclaim it or to recover the ledger. The only escape is a hard drop, which destroys the data the soft drop existed to preserve.
This surfaced as a report from an application on the DynamoDB nameservice that deletes ledgers and then recreates them under the same name, and gets Ledger already exists on every recreate.
Reproduction
Verified on both the file backend and real DynamoDB (LocalStack):
[dynamo soft] init → retract → init → Err(LedgerAlreadyExists("soft/db:main"))
[dynamo hard] init → purge → init → Ok(())
[file soft] drop -> Ok((Dropped, 0 artifacts))
[file soft] RECREATE FAILED: Ledger already exists: app/db:main
[file hard] RECREATE OK
Mechanism
DELETE /ledgerwithout"hard": truemaps toDropMode::Soft(fluree-db-server/src/routes/ledger.rs:298) — the default.- Soft mode calls
LedgerLifecycle::retract, notdrop_branch(fluree-db-api/src/admin.rs:657). retractmarks the meta rowretracted = trueand leaves every row in place (e.g.fluree-db-storage-aws/src/dynamodb/mod.rs:1235).- Recreating calls
init, whose DynamoDBTransactWriteItemsare conditioned onattribute_not_exists(pk)— the surviving rows cancel the transaction, which maps toLedgerAlreadyExists(dynamodb/mod.rs:1225).
Not backend-specific: the trait contract states it directly — "Returns an error if a record already exists (including retracted records)" (fluree-db-nameservice/src/lib.rs).
The actual defect
Soft drop is a one-way door. Nothing in the codebase sets retracted back to false — there is no un-retract, undrop, or reinstate path anywhere (restore_ledger in commit_transfer.rs is the unrelated .flpack restore). So the mode documented as "the default and safest option… all data files remain on disk for potential recovery":
- permanently burns the alias, and
- provides no recovery mechanism that would justify having reserved it.
docs/api/endpoints.md:1750 states the reservation but not that it is irreversible.
Either half would be defensible alone. Together they are a trap: the safe-sounding default is the one with no way back, and callers reach it by simply not passing a flag.
Ruled out
Leftover storage artifacts are not the cause, which was the first hypothesis. Removing only the nameservice records while deliberately leaving 23 artifact files (commits, index, dicts) on disk:
[orphan] RECREATE OK
[orphan] query after recreate -> []
The recreated ledger is clean and empty — the ns record is the authority for a ledger's contents, so orphaned artifacts waste space but cannot corrupt a recreate. Worth knowing on its own.
What to decide
- Should
initreclaim a retracted record? (purge-then-init whenretracted == true.) Makes delete-then-recreate work as callers expect. Cost: gives up alias reservation, which nothing currently redeems. - Or should soft drop become genuinely recoverable? — add an un-retract / undrop path, and keep
initstrict so reservation means something. - Either way, the error should name the situation and the exits.
Ledger already existson an alias the caller just deleted is actively misleading.
Doing neither (1) nor (2) leaves the default mode of a destructive operation with no route back.
Related but distinct
#1668's review raised retraction semantics on the read side: proxy get_ref/heads resolve head refs for branches a raft-backed remote would tombstone, and raft is the only backend that tombstones at all — file, DynamoDB and memory all resolve them. That is a separate failure (a read returning data it shouldn't) from this one (a write refused by a tombstone); fixing either leaves the other. The common theme — retraction is not applied consistently across backends or across the read/write surfaces — is what ties them together and probably wants settling once, deliberately.
Activity
fix(nameservice): tombstone retracted branches on the proxy active-re…
aaj3f commentedon Aug 25, 2026
Folding #1464 into this issue (closing it as the duplicate — same core defect, and this issue has the fresher repros and the decision framing). Five items from #1464 that belong in the record here so they don't get lost:
storage_nsre-init reclaims a retracted alias (storage_ns.rs:805-827) while file/memory/dynamo reject it (file.rs:833-836,memory.rs:231-235). Whatever semantics we decide, that divergence is the first thing to collapse.purgepath falls back toretract(lib.rs:633-634), so "hard" intent degrades to exactly the reservation trap this issue describes.restore_ledgerrolls back via a Soft drop (commit_transfer.rs:1654) — a failed restore can strand the alias the same way.import.rs:3590currently relies on re-init reclaim working, so a reject-semantics decision needs that call-site accounted for.DropMode::Hardsilently degrades toSoft#1596's Hard→Soft silent degrade (drop_branchretracts instead of purging whenrecord.branches > 0,admin.rs:767-770) produces exactly the retracted record that triggers this trap — and the CLI always sendshard:true(drop.rs:50). And materialize gate-fail drop is name-scoped (DropMode::Hard hits every branch); no branch-scoped hard purge #1592's missing branch-scoped hard purge is the shared primitive underneath both. I think one short design note on delete semantics (init-reclaims vs reject, un-retract path or not, branch-scoped purge) settles this issue, Dropping a vector graph source never reclaims its index blobs, andDropMode::Hardsilently degrades toSoft#1596, and materialize gate-fail drop is name-scoped (DropMode::Hard hits every branch); no branch-scoped hard purge #1592 together — they shouldn't be fixed piecemeal.fix(ledger): a retracted ledger reads as not-found on the query path
fix(ledger): a retracted ledger reads as not-found on the query path
aaj3f commentedon Aug 28, 2026
A concrete symptom for this issue's ledger, now live on main after #1716/#1739 settled the
existshalf:existsandcreatecontradict each other after a soft drop, on both backends.ledger_exists("x:main")falsecreate_ledger("x:main")LedgerAlreadyExistsretract_ledgerinserts intostate.retractedbut doesn't remove the branch fromledger.branches, andcreate_ledgerrejects onbranches.contains(&branch).initusesstorage.insert(create-if-absent) and the retracted file is still there.So a user is told the ledger doesn't exist and simultaneously can't create it — reachable from the CLI, not only raft. That's the sharpest version of the reservation trap this issue describes, and it's the shape a design note has to resolve: either re-init reclaims (the
createside moves to matchexists), or the record is genuinely reserved (andexists's new answer needs a companion story for "why can't I create it, then").Worth recording alongside: the
existssub-question is now decided — #1716 made a retracted ledger read as not-found on the query path (43d758610), and #1739 pinned it. The remaining open decisions here are init-reclaims vs reject, whether an un-retract path exists, and branch-scoped hard purge.Credit to @bplatz for the contradiction table and both mechanism traces, from the #1739 review.
bplatz commentedon Nov 14, 2026
Fixed on
nextby #1980 (merged 2026-10-13): name bindings, restorable drops and fenced writers. A drop no longer reserves the alias forever, and it can be undone. It ships in 5.0.0. Its closing reference didn't fire because the PR targetednext. The remaining edges are tracked in #2104, #2105 and #2106.