Skip to content

Conversation

@userzhy
Copy link
Contributor

@userzhy userzhy commented Dec 25, 2025

Purpose

Linked issue: close #6272

When a branch is created from a tag, the tag's snapshot information is copied to the branch directory. However, if the tag is deleted, the snapshot expiration process may clean up data files that are still needed by the branch, making the branch unqueryable.

This change implements Tag Deletion Protection: before deleting a tag, we check if any branches were created from that tag. If so, the deletion is blocked with an error message listing the referencing branches.

Changes:

  • Added branchesCreatedFromTag(String tagName) method to BranchManager interface with default empty implementation for backward compatibility
  • Implemented branchesCreatedFromTag() in FileSystemBranchManager to check each branch's tag directory for the specified tag
  • Added validation in AbstractFileStoreTable.deleteTag() to prevent deletion of tags that are still referenced by branches

Tests

  • Added testDeleteTagReferencedByBranch() in SimpleTableTestBase to verify:
    • Deleting a tag referenced by a branch throws IllegalStateException
    • The error message includes the referencing branch names
    • After deleting all referencing branches, the tag can be deleted successfully

API and Format

  • Added new method branchesCreatedFromTag(String tagName) to BranchManager interface with default implementation returning empty list, so existing implementations remain compatible
  • No storage format changes

Documentation

This is a bug fix, no new feature documentation needed.

@userzhy userzhy force-pushed the fix-branch-snapshot-expire-after-tag-delete branch from c932b6e to 27d834c Compare December 25, 2025 10:30
This closes apache#6272.

When a branch is created from a tag, the tag's snapshot information is copied
to the branch directory. However, deleting the tag could cause the snapshot
expiration process to clean up data files that are still needed by the branch,
making the branch unqueryable.

This change adds a check in deleteTag() to verify if any branches were created
from the tag before allowing deletion. If branches reference the tag, the
deletion is blocked with an error message listing the referencing branches.

Changes:
- Added branchesCreatedFromTag() method to BranchManager interface with
  default empty implementation for backward compatibility
- Implemented branchesCreatedFromTag() in FileSystemBranchManager to check
  each branch's tag directory for the specified tag
- Added validation in AbstractFileStoreTable.deleteTag() to prevent deletion
  of tags that are still referenced by branches
- Added testDeleteTagReferencedByBranch() test case to verify the fix
@userzhy userzhy force-pushed the fix-branch-snapshot-expire-after-tag-delete branch from a033ee1 to a67b459 Compare December 26, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Branch Base Snapshot Gets Expired After Deleting Referenced Tag

1 participant