Skip to content

bug: soft-dropped ledger names are permanently reserved on some nameservices; init/purge semantics are inconsistent #1464

Closed as not planned

Description

@bplatz

Observed

Against a Lambda-fronted deployment: after fluree drop <ledger> --remote <r> --force succeeds and the ledger disappears from fluree remote ledgers, re-creating the same name keeps returning 409 Conflict: Ledger '<x>' already exists — indefinitely. The name is invisible in listings but unusable, with no error message explaining why.

Mechanism (reference server)

Soft drop (LedgerLifecycle::retract) leaves a retracted NsRecord by design — the trait docs say the alias "cannot be reused until purge is called" (fluree-db-nameservice/src/lib.rs:567-602). Listings hide it (routes/ledger.rs:458 skips r.retracted), but Fluree::create_ledger → ledger_admin().init() rejects it, surfacing only the generic LedgerExists 409 (fluree-db-api/src/error.rs:236). Three compounding defects:

  1. The nameservice impls disagree on init over a retracted record:
    • StorageNameService::init reclaims it — overwrites the retracted record and cleans the index sidecar (storage_ns.rs:774-789).
    • FileNameService::init (file.rs:803-807) and MemoryNameService::init (memory.rs:222-226) reject it.
  2. The trait's default purge falls back to retract (lib.rs:599-601) — a backend that doesn't override purge can never actually free a name through that surface.
  3. restore_ledger's failure rollback is a Soft drop (fluree-db-api/src/commit_transfer.rs:1633) — one failed .flpack restore tombstones a name that "did not previously exist" (the comment there states that invariant), blocking all subsequent creates on reject-semantics nameservices. Relatedly, the bulk-import path assumes reclaim is allowed (fluree-db-api/src/import.rs:2907-2913 logs "re-initializing retracted ledger" then calls init()), which fails on File/Memory NS.

Note: the CLI always requests hard: true for remote drops (fluree-db-cli/src/commands/drop.rs, drop_resource(name, true)), so a persistent tombstone additionally implies the deployment downgraded the hard drop or hit the default-purge fallback — but the inconsistent reference semantics above are a bug regardless of backend.

Proposed fix

  1. Unify init on the reclaim semantics: port the retracted-overwrite behavior from StorageNameService::init into FileNameService::init and MemoryNameService::init, and fix the trait doc. This also fixes the import.rs re-init path and makes soft-drop mean "recoverable until the name is reused".
  2. If tombstone-as-reservation is intentionally kept for some backends: add NameServiceError::LedgerRetracted(id) and map it to a 409 whose message names the state and the remedy (e.g. "ledger '' was soft-deleted; drop with hard=true to free the name"). The current silent "already exists" for an invisible ledger is wrong either way.
  3. Make restore_ledger's rollback a Hard drop so failed restores never leave a reserving tombstone.

Activity

  1. added
    bug
    on Jul 11, 2026
  2. aaj3f commented on Aug 25, 2026

    @aaj3f
    Contributor

    Consolidating during backlog housekeeping: this and #1670 describe the same core defect, and #1670 is the fresher statement of it (verified file + DynamoDB repro mechanisms, plus the decision framing we actually need to resolve it). So I'm closing this one as the duplicate and moving the bug label over.

    Before closing, the five things this issue carries that #1670 didn't yet are being folded into #1670 so nothing is lost: (a) the storage_ns init-reclaims vs file/memory/dynamo reject divergence (storage_ns.rs:805-827 vs file.rs:833-836, memory.rs:231-235); (b) the default purge→retract fallback (lib.rs:633-634); (c) the restore_ledger Soft rollback trap (commit_transfer.rs:1654); (d) import.rs:3590's reliance on re-init reclaim; (e) the init/purge-semantics inconsistency framing itself.

    Everything continues in #1670.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions