Repository navigation
fix: Make hard ledger drop fully clean up on S3 + DynamoDB - #1243
Merged
Merged
Conversation
DynamoDbNameService now overrides Publisher::purge with a real delete-all-rows sweep (factored helper shared with drop_branch). The sweep runs regardless of the conditional meta-delete outcome so a half-completed purge is recovered on replay. S3Storage list_prefix variants now parse `fluree:s3://...` through the same path used by reads/writes/deletes, so callers can pass fluree addresses and have the configured bucket prefix correctly applied. drop_artifacts enumerates per-subprefix (commit/, txn/, index/, config/, and optionally @shared/dicts/) so TieredStorage routes commit/txn lists to the commit tier and index/config lists to the index tier. Cross- branch @shared/dicts/ is only wiped when no other non-retracted branches remain. Partial list failures now surface as warnings and trigger a CID-walk cleanup pass instead of being silently treated as success. Adds a LocalStack integration test that writes commits, hard-drops, and asserts artifacts are gone, the NS record is purged, and the alias can be re-initialized.
Set a default context so the bucket also has `config/` artifacts before the drop, and assert their absence afterward. Extend the post-drop straggler filter to include `config/` and `@shared/dicts/` so the test fails fast if any enumerated subprefix is missed in the future. Updated the test header to list the full subprefix set drop_artifacts enumerates.
Merged
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.
Hard-dropping a ledger on the AWS stack (S3 storage + DynamoDB nameservice) was silently behaving like a soft drop: the alias remained unreusable in DynamoDB and 0 artifacts were deleted in S3. This PR fixes four cooperating bugs so
drop_ledger(.., DropMode::Hard)actually clears the ledger end-to-end.Bugs fixed
1.
DynamoDbNameService::purgewas missing — fell back toretractPublisher::purgehas a default impl that delegates toretract(), which only flipsmeta.retracted = true.DynamoDbNameServicenever overrode it, sohead/index/config/statusrows were left behind andpublish_ledger_init(which usesattribute_not_exists(pk)per row) couldn't recreate the alias.Fix: Override
purge()to delete every row underpk. Factored adelete_all_rows_for_pkhelper that's also reused bydrop_branch. The helper always sweeps non-meta rows regardless of the conditional-meta-delete outcome, so a purge that crashed mid-sweep is recovered on the next call.2.
S3Storage::list_prefix*didn't parse fluree addressesReads, writes, and deletes route through
address_to_key(which stripsfluree:s3://). The list APIs didn't, so a caller passingfluree:s3://ledger/main/ended up querying S3 withfluree-data/fluree:s3://ledger/main/— a literal substring that never matches real keys. Result: list returned 0 → fast-path drop deleted nothing.Fix: New
build_list_prefixhelper that runs the sameparse_fluree_addresspath. Applied to all four list entry points (StorageRead::list_prefix,StorageList::list_prefix,list_prefix_paginated,list_prefix_with_metadata). Six unit tests covering scheme stripping, trailing-slash preservation, empty input, and bucket-prefix trimming.3.
TieredStoragerouting missed entire tiers on a ledger-root listTieredStorage::list_prefixroutes by substring:/commit/or/txn/→ commit tier; everything else → index tier. A ledger-root prefix likefluree:s3://ledger/main/contains neither, so a single root-level list misses the whole commit bucket in split commit/index deployments. The originaldrop_artifactsalso missed{prefix}/config/(whereContentKind::LedgerConfigblobs — config + default-context — are written).Fix:
drop_artifactsnow enumerates per-subprefix:commit/,txn/,index/,config/, and conditionally{ledger}/@shared/dicts/. Each list call routes to the correct tier.4. Partial list failures were silently treated as success
The original "if any subprefix listed OK, declare success" branch could purge the nameservice while leaving an entire artifact class behind if one tier returned an error.
Fix: Failures are collected as warnings on the
DropReport. When any subprefix errors, a CID-walk cleanup pass runs after the fast path (releaseis idempotent on already-deleted CIDs). The nameservice is only purged oncedrop_artifactshas had its best shot.Branch safety
@shared/dicts/is only wiped whenis_last_live_branchreturns true (usesNameService::list_branchesto confirm no sibling branches remain). Branch-scopeddrop_branch/purge_branchalways passfalse.drop_ledger's doc-comment now calls out that hard-dropping a parent branch while child branches are still alive will delete commit/index artifacts the children may resolve through the branched content store. Drop child branches first.